Commit d04f8ab6 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Temporarily revert upgrade of protocol

parent 6b3112b6
......@@ -112,16 +112,17 @@ func (id *SchemeManagerIdentifier) UnmarshalText(text []byte) error {
return nil
}
// MarshalText implements encoding.TextMarshaler.
func (id IssuerIdentifier) MarshalText() ([]byte, error) {
return []byte(id.String()), nil
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (id *IssuerIdentifier) UnmarshalText(text []byte) error {
*id = NewIssuerIdentifier(string(text))
return nil
}
// TODO enable this when updating protocol
//// MarshalText implements encoding.TextMarshaler.
//func (id IssuerIdentifier) MarshalText() ([]byte, error) {
// return []byte(id.String()), nil
//}
//
//// UnmarshalText implements encoding.TextUnmarshaler.
//func (id *IssuerIdentifier) UnmarshalText(text []byte) error {
// *id = NewIssuerIdentifier(string(text))
// return nil
//}
// MarshalText implements encoding.TextMarshaler.
func (id CredentialTypeIdentifier) MarshalText() ([]byte, error) {
......
......@@ -5,12 +5,9 @@ import (
"crypto/sha256"
"encoding/base64"
"errors"
"fmt"
"math/big"
"strconv"
"strings"
"github.com/mhe/gabi"
)
......@@ -69,23 +66,24 @@ type publicKeyIdentifier struct {
Counter uint `json:"counter"`
}
func (pki *publicKeyIdentifier) UnmarshalText(text []byte) error {
str := string(text)
index := strings.LastIndex(str, "-")
if index == -1 {
return errors.New("Invalid publicKeyIdentifier")
}
counter, err := strconv.Atoi(str[index+1:])
if err != nil {
return err
}
*pki = publicKeyIdentifier{Issuer: str[:index], Counter: uint(counter)}
return nil
}
func (pki *publicKeyIdentifier) MarshalText() (text []byte, err error) {
return []byte(fmt.Sprintf("%s-%d", pki.Issuer, pki.Counter)), nil
}
// TODO enable this when updating protocol
//func (pki *publicKeyIdentifier) UnmarshalText(text []byte) error {
// str := string(text)
// index := strings.LastIndex(str, "-")
// if index == -1 {
// return errors.New("Invalid publicKeyIdentifier")
// }
// counter, err := strconv.Atoi(str[index+1:])
// if err != nil {
// return err
// }
// *pki = publicKeyIdentifier{Issuer: str[:index], Counter: uint(counter)}
// return nil
//}
//
//func (pki *publicKeyIdentifier) MarshalText() (text []byte, err error) {
// return []byte(fmt.Sprintf("%s-%d", pki.Issuer, pki.Counter)), nil
//}
type proofPCommitmentMap struct {
Commitments map[publicKeyIdentifier]*gabi.ProofPCommitment `json:"c"`
......@@ -379,10 +377,15 @@ func (ks *keyshareSession) Finish(challenge *big.Int, responses map[SchemeManage
return
}
message := gabi.IssueCommitmentMessage{Proofs: list, Nonce2: ks.session.(*IssuanceRequest).state.nonce2}
message.ProofPjwts = map[string]string{}
for manager, response := range responses {
message.ProofPjwts[manager.String()] = response
for _, response := range responses {
message.ProofPjwt = response
break
}
// TODO for new protocol version
//message.ProofPjwts = map[string]string{}
//for manager, response := range responses {
// message.ProofPjwts[manager.String()] = response
//}
ks.sessionHandler.KeyshareDone(message)
}
}
......
package irmago
import (
"encoding/json"
"errors"
"math/big"
"github.com/mhe/gabi"
)
func (pki *publicKeyIdentifier) MarshalJSON() ([]byte, error) {
temp := struct {
Issuer map[string]string `json:"issuer"`
Counter uint `json:"counter"`
}{
Issuer: map[string]string{"identifier": pki.Issuer},
Counter: pki.Counter,
}
return json.Marshal(temp)
}
func (comms *proofPCommitmentMap) UnmarshalJSON(bytes []byte) error {
comms.Commitments = map[publicKeyIdentifier]*gabi.ProofPCommitment{}
temp := struct {
C [][]*json.RawMessage `json:"c"`
}{}
if err := json.Unmarshal(bytes, &temp); err != nil {
return err
}
for _, raw := range temp.C {
tempPkID := struct {
Issuer struct {
Identifier string `json:"identifier"`
} `json:"issuer"`
Counter uint `json:"counter"`
}{}
comm := gabi.ProofPCommitment{}
if err := json.Unmarshal([]byte(*raw[0]), &tempPkID); err != nil {
return err
}
if err := json.Unmarshal([]byte(*raw[1]), &comm); err != nil {
return err
}
pkid := publicKeyIdentifier{Issuer: tempPkID.Issuer.Identifier, Counter: tempPkID.Counter}
comms.Commitments[pkid] = &comm
}
return nil
}
func (si *SessionInfo) UnmarshalJSON(b []byte) error {
temp := &struct {
Jwt string `json:"jwt"`
Nonce *big.Int `json:"nonce"`
Context *big.Int `json:"context"`
Keys [][]interface{} `json:"keys"`
}{}
err := json.Unmarshal(b, temp)
if err != nil {
return err
}
si.Jwt = temp.Jwt
si.Nonce = temp.Nonce
si.Context = temp.Context
si.Keys = make(map[IssuerIdentifier]int, len(temp.Keys))
for _, item := range temp.Keys {
var idmap map[string]interface{}
var idstr string
var counter float64
var ok bool
if idmap, ok = item[0].(map[string]interface{}); !ok {
return errors.New("Failed to deserialize session info")
}
if idstr, ok = idmap["identifier"].(string); !ok {
return errors.New("Failed to deserialize session info")
}
if counter, ok = item[1].(float64); !ok {
return errors.New("Failed to deserialize session info")
}
id := NewIssuerIdentifier(idstr)
si.Keys[id] = int(counter)
}
return nil
}
......@@ -43,7 +43,7 @@ type session struct {
// Supported protocol versions. Minor version numbers should be reverse sorted.
var supportedVersions = map[int][]int{
3: {0},
2: {2, 1},
}
func calcVersion(qr *Qr) (string, error) {
......
......@@ -157,7 +157,7 @@ func sessionHelper(t *testing.T, jwtcontents interface{}, url string, init bool)
parseAndroidStorage(t)
}
url = "http://localhost:8081/irma_api_server/api/v3/" + url
url = "http://localhost:8081/irma_api_server/api/v2/" + url
//url = "https://demo.irmacard.org/tomcat/irma_api_server/api/v2/" + url
headerbytes, err := json.Marshal(&map[string]string{"alg": "none", "typ": "JWT"})
......
......@@ -9,7 +9,7 @@
<en>A test scheme manager with a scheme manager.</en>
<nl>Een test-scheme manager met een keyshare server.</nl>
</Description>
<KeyshareServer>http://localhost:8080/irma_keyshare_server/api/v2</KeyshareServer>
<KeyshareServer>http://localhost:8080/irma_keyshare_server/api/v1</KeyshareServer>
<KeyshareWebsite>http://localhost:8080/irma_keyshare_server/mijnirma/</KeyshareWebsite>
<KeyshareAttribute>test.test.mijnirma.email</KeyshareAttribute>
<Contact>https://privacybydesign.foundation/</Contact>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment