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