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

ParseAndroidStorage correctly parses distributed credentials

parent faf6a34e
......@@ -68,6 +68,11 @@ func verifyManagerIsUnmarshaled(t *testing.T) {
assert.NotNil(t, cred, "Credential should exist")
assert.NotNil(t, cred.Attributes[0], "Metadata attribute of irma-demo.RU.studentCard should not be nil")
cred, err = Manager.credential(NewCredentialTypeIdentifier("test.test.mijnirma"), 0)
assert.NoError(t, err, "could not fetch credential")
assert.NotNil(t, cred, "Credential should exist")
assert.NotNil(t, cred.Signature.KeyshareP)
assert.NotEmpty(t, Manager.CredentialInfoList())
assert.True(t,
......
......@@ -109,7 +109,12 @@ func (cm *CredentialManager) ParseAndroidStorage() (err error) {
}{}
xml.Unmarshal(bytes, &parsedxml)
parsedjson := make(map[string][]*gabi.Credential)
parsedjson := make(map[string][]*struct {
Signature *gabi.CLSignature `json:"signature"`
Pk *gabi.PublicKey `json:"-"`
Attributes []*big.Int `json:"attributes"`
SharedPoints []*big.Int `json:"public_sks"`
})
cm.keyshareServers = make(map[SchemeManagerIdentifier]*keyshareServer)
for _, xmltag := range parsedxml.Strings {
if xmltag.Name == "credentials" {
......@@ -136,7 +141,14 @@ func (cm *CredentialManager) ParseAndroidStorage() (err error) {
for _, list := range parsedjson {
cm.secretkey = list[0].Attributes[0]
for _, gabicred := range list {
for _, oldcred := range list {
gabicred := &gabi.Credential{
Attributes: oldcred.Attributes,
Signature: oldcred.Signature,
}
if oldcred.SharedPoints != nil && len(oldcred.SharedPoints) > 0 {
gabicred.Signature.KeyshareP = oldcred.SharedPoints[0]
}
cred := newCredential(gabicred)
if cred.CredentialType() == nil {
return errors.New("cannot add unknown credential type")
......
This diff is collapsed.
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