Skip to content
GitLab
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
4d97255d
Commit
4d97255d
authored
Jun 21, 2018
by
David Venhoek
Browse files
Merge branch 'master' into david-pinchange
parents
b02aa5fd
1b853dc0
Changes
9
Hide whitespace changes
Inline
Side-by-side
doc.go
View file @
4d97255d
// Package irmago is work in progress on an IRMA client in Go.
//It will (de)serialize credentials from/to storage,
// and be the client (like the IRMA Android app,
// https://github.com/credentials/irma_android_cardemu) in the IRMA protocol (see
// https://credentials.github.io/protocols/irma-protocol).
// Package irma contains generic IRMA strucs and logic of use to all IRMA participants.
// It parses irma_configuration folders to scheme managers, issuers, credential types and public keys,
// it contains various messages from the IRMA protocol, and parses IRMA metadata attributes.
package
irma
identifiers.go
View file @
4d97255d
...
...
@@ -111,6 +111,9 @@ func (id CredentialTypeIdentifier) IssuerIdentifier() IssuerIdentifier {
// CredentialTypeIdentifier returns the CredentialTypeIdentifier of the attribute identifier.
func
(
id
AttributeTypeIdentifier
)
CredentialTypeIdentifier
()
CredentialTypeIdentifier
{
if
id
.
IsCredential
()
{
return
NewCredentialTypeIdentifier
(
id
.
String
())
}
return
NewCredentialTypeIdentifier
(
id
.
Parent
())
}
...
...
irmaclient/client.go
View file @
4d97255d
...
...
@@ -43,7 +43,7 @@ type Client struct {
// Stuff we manage on disk
secretkey
*
secretKey
attributes
map
[
irma
.
CredentialTypeIdentifier
][]
*
irma
.
AttributeList
credentials
map
[
irma
.
CredentialTypeIdentifier
]
map
[
int
]
*
credential
credentials
Cache
map
[
irma
.
CredentialTypeIdentifier
]
map
[
int
]
*
credential
keyshareServers
map
[
irma
.
SchemeManagerIdentifier
]
*
keyshareServer
paillierKeyCache
*
paillierPrivateKey
logs
[]
*
LogEntry
...
...
@@ -53,12 +53,12 @@ type Client struct {
storage
storage
// Other state
Preferences
Preferences
Configuration
*
irma
.
Configuration
irmaConfigurationPath
string
androidStoragePath
string
handler
ClientHandler
state
*
issuanceState
Preferences
Preferences
Configuration
*
irma
.
Configuration
irmaConfigurationPath
string
androidStoragePath
string
handler
ClientHandler
state
*
issuanceState
}
// SentryDSN should be set in the init() function
...
...
@@ -128,7 +128,7 @@ func New(
}
cm
:=
&
Client
{
credentials
:
make
(
map
[
irma
.
CredentialTypeIdentifier
]
map
[
int
]
*
credential
),
credentials
Cache
:
make
(
map
[
irma
.
CredentialTypeIdentifier
]
map
[
int
]
*
credential
),
keyshareServers
:
make
(
map
[
irma
.
SchemeManagerIdentifier
]
*
keyshareServer
),
attributes
:
make
(
map
[
irma
.
CredentialTypeIdentifier
][]
*
irma
.
AttributeList
),
irmaConfigurationPath
:
irmaConfigurationPath
,
...
...
@@ -226,18 +226,18 @@ func (client *Client) addCredential(cred *credential, storeAttributes bool) (err
}
// If this is a singleton credential type, ensure we have at most one by removing any previous instance
if
!
id
.
Empty
()
&&
cred
.
CredentialType
()
.
IsSingleton
&&
len
(
client
.
cred
s
(
id
))
>
0
{
if
!
id
.
Empty
()
&&
cred
.
CredentialType
()
.
IsSingleton
&&
len
(
client
.
attr
s
(
id
))
>
0
{
client
.
remove
(
id
,
0
,
false
)
// Index is 0, because if we're here we have exactly one
}
// Append the new cred to our attributes and credentials
client
.
attributes
[
id
]
=
append
(
client
.
attrs
(
id
),
cred
.
AttributeList
())
if
!
id
.
Empty
()
{
if
_
,
exists
:=
client
.
credentials
[
id
];
!
exists
{
client
.
credentials
[
id
]
=
make
(
map
[
int
]
*
credential
)
if
_
,
exists
:=
client
.
credentials
Cache
[
id
];
!
exists
{
client
.
credentials
Cache
[
id
]
=
make
(
map
[
int
]
*
credential
)
}
counter
:=
len
(
client
.
attributes
[
id
])
-
1
client
.
credentials
[
id
][
counter
]
=
cred
client
.
credentials
Cache
[
id
][
counter
]
=
cred
}
if
err
=
client
.
storage
.
StoreSignature
(
cred
);
err
!=
nil
{
...
...
@@ -274,10 +274,10 @@ func (client *Client) remove(id irma.CredentialTypeIdentifier, index int, storen
}
// Remove credential
if
creds
,
exists
:=
client
.
credentials
[
id
];
exists
{
if
creds
,
exists
:=
client
.
credentials
Cache
[
id
];
exists
{
if
_
,
exists
:=
creds
[
index
];
exists
{
delete
(
creds
,
index
)
client
.
credentials
[
id
]
=
creds
client
.
credentials
Cache
[
id
]
=
creds
}
}
...
...
@@ -354,10 +354,10 @@ func (client *Client) attrs(id irma.CredentialTypeIdentifier) []*irma.AttributeL
// creds returns cm.credentials[id], initializing it to an empty map if neccesary
func
(
client
*
Client
)
creds
(
id
irma
.
CredentialTypeIdentifier
)
map
[
int
]
*
credential
{
list
,
exists
:=
client
.
credentials
[
id
]
list
,
exists
:=
client
.
credentials
Cache
[
id
]
if
!
exists
{
list
=
make
(
map
[
int
]
*
credential
)
client
.
credentials
[
id
]
=
list
client
.
credentials
Cache
[
id
]
=
list
}
return
list
}
...
...
@@ -428,10 +428,10 @@ func (client *Client) credential(id irma.CredentialTypeIdentifier, counter int)
if
err
!=
nil
{
return
nil
,
err
}
client
.
credentials
[
id
][
counter
]
=
cred
client
.
credentials
Cache
[
id
][
counter
]
=
cred
}
return
client
.
credentials
[
id
][
counter
],
nil
return
client
.
credentials
Cache
[
id
][
counter
],
nil
}
// Methods used in the IRMA protocol
...
...
@@ -771,8 +771,8 @@ func (client *Client) keyshareChangePinWorker(managerID irma.SchemeManagerIdenti
transport
:=
irma
.
NewHTTPTransport
(
kss
.
URL
)
message
:=
keyshareChangepin
{
Username
:
kss
.
Username
,
OldPin
:
kss
.
HashedPin
(
oldPin
),
NewPin
:
kss
.
HashedPin
(
newPin
),
OldPin
:
kss
.
HashedPin
(
oldPin
),
NewPin
:
kss
.
HashedPin
(
newPin
),
}
res
:=
&
keysharePinStatus
{}
...
...
irmaclient/doc.go
0 → 100644
View file @
4d97255d
// Package irmaclient implements an IRMA client, that can manage and use IRMA attributes.
// It (de)serializes them from/to storage, acts as the client in the IRMA protocol
// (see https://credentials.github.io/protocols/irma-protocol), and also in the IRMA
// keyshare protocol (see http://credentials.github.io/protocols/keyshare-protocol).
package
irmaclient
irmaclient/irmaclient_test.go
View file @
4d97255d
...
...
@@ -2,10 +2,10 @@ package irmaclient
import
(
"encoding/json"
"errors"
"math/big"
"os"
"testing"
"errors"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
...
...
@@ -107,9 +107,10 @@ func verifyClientIsUnmarshaled(t *testing.T, client *Client) {
func
verifyCredentials
(
t
*
testing
.
T
,
client
*
Client
)
{
var
pk
*
gabi
.
PublicKey
var
err
error
for
credtype
,
credsmap
:=
range
client
.
credentials
{
for
index
,
cred
:=
range
credsmap
{
for
credtype
,
credsmap
:=
range
client
.
attributes
{
for
index
,
attrs
:=
range
credsmap
{
cred
,
err
:=
client
.
credential
(
attrs
.
CredentialType
()
.
Identifier
(),
index
)
require
.
NoError
(
t
,
err
)
pk
,
err
=
cred
.
PublicKey
()
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
...
...
irmaclient/session_test.go
View file @
4d97255d
...
...
@@ -8,11 +8,12 @@ import (
"testing"
"time"
"math/big"
"github.com/go-errors/errors"
"github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/test"
"github.com/stretchr/testify/require"
"math/big"
)
type
TestHandler
struct
{
...
...
@@ -210,6 +211,14 @@ func TestDisclosureSession(t *testing.T) {
sessionHelper
(
t
,
jwtcontents
,
"verification"
,
nil
)
}
func
TestNoAttributeDisclosureSession
(
t
*
testing
.
T
)
{
id
:=
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard"
)
name
:=
"testsp"
jwtcontents
:=
getDisclosureJwt
(
name
,
id
)
sessionHelper
(
t
,
jwtcontents
,
"verification"
,
nil
)
}
func
TestIssuanceSession
(
t
*
testing
.
T
)
{
id
:=
irma
.
NewAttributeTypeIdentifier
(
"irma-demo.RU.studentCard.studentID"
)
name
:=
"testip"
...
...
@@ -370,8 +379,8 @@ func keyshareSessions(t *testing.T, client *Client) {
func
TestKeyshareChangePin
(
t
*
testing
.
T
)
{
client
:=
parseStorage
(
t
)
require
.
NoError
(
t
,
client
.
keyshareChangePinWorker
(
irma
.
NewSchemeManagerIdentifier
(
"test"
),
"12345"
,
"54321"
))
;
require
.
NoError
(
t
,
client
.
keyshareChangePinWorker
(
irma
.
NewSchemeManagerIdentifier
(
"test"
),
"54321"
,
"12345"
))
;
require
.
NoError
(
t
,
client
.
keyshareChangePinWorker
(
irma
.
NewSchemeManagerIdentifier
(
"test"
),
"12345"
,
"54321"
))
require
.
NoError
(
t
,
client
.
keyshareChangePinWorker
(
irma
.
NewSchemeManagerIdentifier
(
"test"
),
"54321"
,
"12345"
))
test
.
ClearTestStorage
(
t
)
}
...
...
irmaclient/updates.go
View file @
4d97255d
...
...
@@ -198,7 +198,7 @@ func (client *Client) ParseAndroidStorage() (present bool, err error) {
}
}
if
len
(
client
.
credentials
)
>
0
{
if
len
(
client
.
credentials
Cache
)
>
0
{
if
err
=
client
.
storage
.
StoreAttributes
(
client
.
attributes
);
err
!=
nil
{
return
}
...
...
irmameta/irmameta.go
View file @
4d97255d
// irmameta parses and prints info about the specified metadata attribute.
package
main
import
(
...
...
@@ -15,7 +16,7 @@ import (
func
main
()
{
if
len
(
os
.
Args
)
!=
3
{
fmt
.
Println
(
"Usage: irmago metadata_attribute_in_decimal
path_to_irma_configuration
"
)
fmt
.
Println
(
"Usage: irmago
path_to_irma_configuration
metadata_attribute_in_decimal"
)
}
metaint
,
ok
:=
new
(
big
.
Int
)
.
SetString
(
os
.
Args
[
2
],
10
)
...
...
schememgr/main.go
View file @
4d97255d
// schememgr manages signatures on IRMA scheme managers.
// It can generate public-private keypairs for signing their directory structures,
// as well as creating and verifying these signatures.
package
main
import
"github.com/privacybydesign/irmago/schememgr/cmd"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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