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
1b853dc0
Commit
1b853dc0
authored
Jun 21, 2018
by
Sietse Ringers
Browse files
Rename client.credentials -> .credentialsCache
parent
42a3acc2
Changes
3
Hide whitespace changes
Inline
Side-by-side
irmaclient/client.go
View file @
1b853dc0
...
...
@@ -42,7 +42,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
...
...
@@ -52,12 +52,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
...
...
@@ -126,7 +126,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
,
...
...
@@ -231,11 +231,11 @@ func (client *Client) addCredential(cred *credential, storeAttributes bool) (err
// 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
{
...
...
@@ -272,10 +272,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
}
}
...
...
@@ -352,10 +352,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
}
...
...
@@ -426,10 +426,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
...
...
@@ -769,8 +769,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/irmaclient_test.go
View file @
1b853dc0
...
...
@@ -2,10 +2,10 @@ package irmaclient
import
(
"encoding/json"
"errors"
"math/big"
"os"
"testing"
"errors"
"github.com/mhe/gabi"
"github.com/privacybydesign/irmago"
...
...
@@ -99,9 +99,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/updates.go
View file @
1b853dc0
...
...
@@ -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
}
...
...
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