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
38779f80
Commit
38779f80
authored
Oct 03, 2017
by
Sietse Ringers
Browse files
Catch some more errors
parent
de9c0201
Changes
8
Hide whitespace changes
Inline
Side-by-side
attributes.go
View file @
38779f80
...
...
@@ -374,7 +374,9 @@ func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error {
Label
string
`json:"label"`
Attributes
interface
{}
`json:"attributes"`
}{}
json
.
Unmarshal
(
bytes
,
&
temp
)
if
err
:=
json
.
Unmarshal
(
bytes
,
&
temp
);
err
!=
nil
{
return
err
}
disjunction
.
Label
=
temp
.
Label
switch
temp
.
Attributes
.
(
type
)
{
...
...
@@ -383,7 +385,9 @@ func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error {
Label
string
`json:"label"`
Attributes
map
[
string
]
string
`json:"attributes"`
}{}
json
.
Unmarshal
(
bytes
,
&
temp
)
if
err
:=
json
.
Unmarshal
(
bytes
,
&
temp
);
err
!=
nil
{
return
err
}
for
str
,
value
:=
range
temp
.
Attributes
{
id
:=
NewAttributeTypeIdentifier
(
str
)
disjunction
.
Attributes
=
append
(
disjunction
.
Attributes
,
id
)
...
...
@@ -394,7 +398,9 @@ func (disjunction *AttributeDisjunction) UnmarshalJSON(bytes []byte) error {
Label
string
`json:"label"`
Attributes
[]
string
`json:"attributes"`
}{}
json
.
Unmarshal
(
bytes
,
&
temp
)
if
err
:=
json
.
Unmarshal
(
bytes
,
&
temp
);
err
!=
nil
{
return
err
}
for
_
,
str
:=
range
temp
.
Attributes
{
disjunction
.
Attributes
=
append
(
disjunction
.
Attributes
,
NewAttributeTypeIdentifier
(
str
))
}
...
...
configstore.go
View file @
38779f80
...
...
@@ -230,7 +230,6 @@ func (store *ConfigurationStore) Copy(source string, parse bool) error {
return
err
}
// TODO skip existing scheme managers? individual files?
err
:=
filepath
.
Walk
(
source
,
filepath
.
WalkFunc
(
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
path
==
source
{
...
...
irmago_test.go
View file @
38779f80
...
...
@@ -29,7 +29,7 @@ func TestMain(m *testing.M) {
type
IgnoringKeyshareHandler
struct
{}
func
(
i
*
IgnoringKeyshareHandler
)
StartRegistration
(
m
*
SchemeManager
,
callback
func
(
e
,
p
string
))
{
func
(
i
*
IgnoringKeyshareHandler
)
StartRegistration
(
m
*
SchemeManager
,
callback
func
(
e
,
p
string
)
error
)
{
}
func
parseStorage
(
t
*
testing
.
T
)
*
CredentialManager
{
...
...
keyshare.go
View file @
38779f80
...
...
@@ -98,7 +98,7 @@ type proofPCommitmentMap struct {
// KeyshareHandler is used for asking the user for his email address and PIN,
// for registering at a keyshare server.
type
KeyshareHandler
interface
{
StartRegistration
(
manager
*
SchemeManager
,
registrationCallback
func
(
email
,
pin
string
))
StartRegistration
(
manager
*
SchemeManager
,
registrationCallback
func
(
email
,
pin
string
)
error
)
}
const
(
...
...
manager.go
View file @
38779f80
...
...
@@ -139,8 +139,8 @@ func NewCredentialManager(
if
keyshareHandler
==
nil
{
return
nil
,
errors
.
New
(
"Keyshare server found but no KeyshareHandler was given"
)
}
keyshareHandler
.
StartRegistration
(
unenrolled
[
0
],
func
(
email
,
pin
string
)
{
cm
.
KeyshareEnroll
(
unenrolled
[
0
]
.
Identifier
(),
email
,
pin
)
keyshareHandler
.
StartRegistration
(
unenrolled
[
0
],
func
(
email
,
pin
string
)
error
{
return
cm
.
KeyshareEnroll
(
unenrolled
[
0
]
.
Identifier
(),
email
,
pin
)
})
default
:
return
nil
,
errors
.
New
(
"Too many keyshare servers"
)
...
...
@@ -209,7 +209,9 @@ func (cm *CredentialManager) remove(id CredentialTypeIdentifier, index int, stor
attrs
:=
list
[
index
]
cm
.
attributes
[
id
]
=
append
(
list
[
:
index
],
list
[
index
+
1
:
]
...
)
if
storenow
{
cm
.
storage
.
StoreAttributes
(
cm
.
attributes
)
if
err
:=
cm
.
storage
.
StoreAttributes
(
cm
.
attributes
);
err
!=
nil
{
return
err
}
}
// Remove credential
...
...
@@ -520,7 +522,9 @@ func (cm *CredentialManager) ConstructCredentials(msg []*gabi.IssueSignatureMess
if
err
!=
nil
{
return
err
}
cm
.
addCredential
(
newcred
,
true
)
if
err
=
cm
.
addCredential
(
newcred
,
true
);
err
!=
nil
{
return
err
}
}
return
nil
...
...
session.go
View file @
38779f80
...
...
@@ -289,6 +289,6 @@ func (session *session) sendResponse(message interface{}) {
log
,
_
=
session
.
createLogEntry
(
message
)
// TODO err
}
session
.
credManager
.
addLogEntry
(
log
,
true
)
// TODO err
_
=
session
.
credManager
.
addLogEntry
(
log
,
true
)
// TODO err
session
.
Handler
.
Success
(
session
.
Action
)
}
transport.go
View file @
38779f80
...
...
@@ -102,8 +102,8 @@ func (transport *HTTPTransport) request(url string, method string, result interf
}
if
res
.
StatusCode
!=
200
{
apierr
:=
&
ApiError
{}
json
.
Unmarshal
(
body
,
apierr
)
if
apierr
.
ErrorName
==
""
{
// Not an ApiErrorMessage
err
=
json
.
Unmarshal
(
body
,
apierr
)
if
err
!=
nil
||
apierr
.
ErrorName
==
""
{
// Not an ApiErrorMessage
return
&
SessionError
{
ErrorType
:
ErrorServerResponse
,
Status
:
res
.
StatusCode
}
}
if
verbose
{
...
...
@@ -139,5 +139,5 @@ func (transport *HTTPTransport) Get(url string, result interface{}) error {
// Delete performs a DELETE.
func
(
transport
*
HTTPTransport
)
Delete
()
{
transport
.
request
(
""
,
http
.
MethodDelete
,
nil
,
nil
)
_
=
transport
.
request
(
""
,
http
.
MethodDelete
,
nil
,
nil
)
}
updates.go
View file @
38779f80
...
...
@@ -42,21 +42,19 @@ func (cm *CredentialManager) update() error {
// Perform all new updates
for
i
:=
len
(
cm
.
updates
);
i
<
len
(
credentialManagerUpdates
);
i
++
{
err
=
credentialManagerUpdates
[
i
](
cm
)
u
pdate
:=
update
{
u
:=
update
{
When
:
Timestamp
(
time
.
Now
()),
Number
:
i
,
Success
:
err
==
nil
,
}
if
err
!=
nil
{
str
:=
err
.
Error
()
u
pdate
.
Error
=
&
str
u
.
Error
=
&
str
}
cm
.
updates
=
append
(
cm
.
updates
,
u
pdate
)
cm
.
updates
=
append
(
cm
.
updates
,
u
)
}
cm
.
storage
.
StoreUpdates
(
cm
.
updates
)
return
nil
return
cm
.
storage
.
StoreUpdates
(
cm
.
updates
)
}
// ParseAndroidStorage parses an Android cardemu.xml shared preferences file
...
...
@@ -85,7 +83,9 @@ func (cm *CredentialManager) ParseAndroidStorage() (present bool, err error) {
Content
string
`xml:",chardata"`
}
`xml:"string"`
}{}
xml
.
Unmarshal
(
bytes
,
&
parsedxml
)
if
err
=
xml
.
Unmarshal
(
bytes
,
&
parsedxml
);
err
!=
nil
{
return
}
parsedjson
:=
make
(
map
[
string
][]
*
struct
{
Signature
*
gabi
.
CLSignature
`json:"signature"`
...
...
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