Commit 8641506d authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Support multiple issuer publickeys

parent 094367b9
package irmago
import "encoding/xml"
import (
"encoding/xml"
"github.com/mhe/gabi"
)
// SchemeManagerDescription describes a scheme manager.
type SchemeManagerDescription struct {
......@@ -64,3 +68,31 @@ func (id *IssuerDescription) Identifier() *IssuerIdentifier {
}
return id.identifier
}
// CurrentPublicKey returns the latest known public key of the issuer identified by this instance.
func (id *IssuerDescription) CurrentPublicKey() *gabi.PublicKey {
return id.Identifier().CurrentPublicKey()
}
// PublicKey returns the specified public key of the issuer identified by this instance.
func (id *IssuerDescription) PublicKey(index int) *gabi.PublicKey {
return id.Identifier().PublicKey(index)
}
// CurrentPublicKey returns the latest known public key of the issuer identified by this instance.
func (i *IssuerIdentifier) CurrentPublicKey() *gabi.PublicKey {
keys := MetaStore.publickeys[i.string]
if keys == nil || len(keys) == 0 {
return nil
}
return keys[len(keys)-1]
}
// PublicKey returns the specified public key of the issuer identified by this instance.
func (i *IssuerIdentifier) PublicKey(index int) *gabi.PublicKey {
keys := MetaStore.publickeys[i.string]
if keys == nil || index >= len(keys) {
return nil
}
return keys[index]
}
package irmago
import "testing"
import (
"fmt"
"testing"
)
func TestParseStore(t *testing.T) {
err := MetaStore.ParseFolder("testdata/irma_configuration")
if err != nil {
t.Fatal(err)
}
fmt.Printf("%+v\n", MetaStore.issuers["irma-demo.MijnOverheid"].CurrentPublicKey())
}
......@@ -15,7 +15,7 @@ var MetaStore = ConfigurationStore{
make(map[string]*SchemeManagerDescription),
make(map[string]*IssuerDescription),
make(map[string]*CredentialDescription),
make(map[string]*gabi.PublicKey),
make(map[string][]*gabi.PublicKey),
}
// ConfigurationStore keeps track of scheme managers, issuers, credential types and public keys.
......@@ -24,7 +24,7 @@ type ConfigurationStore struct {
managers map[string]*SchemeManagerDescription
issuers map[string]*IssuerDescription
credentials map[string]*CredentialDescription
publickeys map[string]*gabi.PublicKey
publickeys map[string][]*gabi.PublicKey
}
// ParseFolder populates the current store by parsing the specified irma_configuration folder,
......@@ -72,7 +72,7 @@ func (store *ConfigurationStore) parseKeysFolder(issuer *IssuerIdentifier, path
if err != nil {
return err
}
MetaStore.publickeys[issuer.string] = pk
MetaStore.publickeys[issuer.string] = append(MetaStore.publickeys[issuer.string], pk)
}
return nil
}
......
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