Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
8641506d
Commit
8641506d
authored
Jun 04, 2017
by
Sietse Ringers
Browse files
Support multiple issuer publickeys
parent
094367b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
descriptions.go
View file @
8641506d
package
irmago
package
irmago
import
"encoding/xml"
import
(
"encoding/xml"
"github.com/mhe/gabi"
)
// SchemeManagerDescription describes a scheme manager.
// SchemeManagerDescription describes a scheme manager.
type
SchemeManagerDescription
struct
{
type
SchemeManagerDescription
struct
{
...
@@ -64,3 +68,31 @@ func (id *IssuerDescription) Identifier() *IssuerIdentifier {
...
@@ -64,3 +68,31 @@ func (id *IssuerDescription) Identifier() *IssuerIdentifier {
}
}
return
id
.
identifier
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
]
}
irmago_test.go
View file @
8641506d
package
irmago
package
irmago
import
"testing"
import
(
"fmt"
"testing"
)
func
TestParseStore
(
t
*
testing
.
T
)
{
func
TestParseStore
(
t
*
testing
.
T
)
{
err
:=
MetaStore
.
ParseFolder
(
"testdata/irma_configuration"
)
err
:=
MetaStore
.
ParseFolder
(
"testdata/irma_configuration"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
fmt
.
Printf
(
"%+v
\n
"
,
MetaStore
.
issuers
[
"irma-demo.MijnOverheid"
]
.
CurrentPublicKey
())
}
}
store.go
View file @
8641506d
...
@@ -15,7 +15,7 @@ var MetaStore = ConfigurationStore{
...
@@ -15,7 +15,7 @@ var MetaStore = ConfigurationStore{
make
(
map
[
string
]
*
SchemeManagerDescription
),
make
(
map
[
string
]
*
SchemeManagerDescription
),
make
(
map
[
string
]
*
IssuerDescription
),
make
(
map
[
string
]
*
IssuerDescription
),
make
(
map
[
string
]
*
CredentialDescription
),
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.
// ConfigurationStore keeps track of scheme managers, issuers, credential types and public keys.
...
@@ -24,7 +24,7 @@ type ConfigurationStore struct {
...
@@ -24,7 +24,7 @@ type ConfigurationStore struct {
managers
map
[
string
]
*
SchemeManagerDescription
managers
map
[
string
]
*
SchemeManagerDescription
issuers
map
[
string
]
*
IssuerDescription
issuers
map
[
string
]
*
IssuerDescription
credentials
map
[
string
]
*
CredentialDescription
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,
// ParseFolder populates the current store by parsing the specified irma_configuration folder,
...
@@ -72,7 +72,7 @@ func (store *ConfigurationStore) parseKeysFolder(issuer *IssuerIdentifier, path
...
@@ -72,7 +72,7 @@ func (store *ConfigurationStore) parseKeysFolder(issuer *IssuerIdentifier, path
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
MetaStore
.
publickeys
[
issuer
.
string
]
=
pk
MetaStore
.
publickeys
[
issuer
.
string
]
=
append
(
MetaStore
.
publickeys
[
issuer
.
string
],
pk
)
}
}
return
nil
return
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment