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
634bebc7
Commit
634bebc7
authored
May 02, 2018
by
Koen van Ingen
Browse files
Save manual session logs and other small fixes
parent
648ea1eb
Changes
5
Hide whitespace changes
Inline
Side-by-side
irma_signature.go
View file @
634bebc7
...
...
@@ -22,28 +22,9 @@ func (im *IrmaSignedMessage) GetNonce() *big.Int {
}
func
(
im
*
IrmaSignedMessage
)
MatchesNonceAndContext
(
request
*
SignatureRequest
)
bool
{
// TODO: string comparison needed?
return
im
.
Nonce
.
String
()
==
request
.
Nonce
.
String
()
&&
im
.
Context
.
String
()
==
request
.
Context
.
String
()
&&
im
.
GetNonce
()
.
String
()
==
request
.
GetNonce
()
.
String
()
}
// Create an IrmaSignedMessage struct and check if type assertions hold
// bool is false if type assertion failed
func
SignedMessageFromSession
(
session
IrmaSession
,
message
interface
{})
(
*
IrmaSignedMessage
,
bool
)
{
signature
,
ok1
:=
message
.
(
gabi
.
ProofList
)
request
,
ok2
:=
session
.
(
*
SignatureRequest
)
if
!
ok1
||
!
ok2
{
return
nil
,
false
}
return
&
IrmaSignedMessage
{
Signature
:
&
signature
,
Nonce
:
request
.
Nonce
,
Context
:
request
.
Context
,
Message
:
request
.
Message
,
},
true
return
im
.
Nonce
.
Cmp
(
request
.
Nonce
)
==
0
&&
im
.
Context
.
Cmp
(
request
.
Context
)
==
0
&&
im
.
GetNonce
()
.
Cmp
(
request
.
GetNonce
())
==
0
}
// Convert a Nonce to a nonce of a signature session
...
...
irmaclient/logs.go
View file @
634bebc7
...
...
@@ -41,7 +41,15 @@ func (session *session) createLogEntry(response interface{}) (*LogEntry, error)
var
ok
bool
switch
entry
.
Type
{
case
irma
.
ActionSigning
:
entry
.
SignedMessage
=
[]
byte
(
session
.
jwt
.
(
*
irma
.
SignatureRequestorJwt
)
.
Request
.
Request
.
Message
)
if
session
.
IsInteractive
()
{
entry
.
SignedMessage
=
[]
byte
(
session
.
jwt
.
(
*
irma
.
SignatureRequestorJwt
)
.
Request
.
Request
.
Message
)
}
else
{
request
,
ok
:=
session
.
irmaSession
.
(
*
irma
.
SignatureRequest
)
if
!
ok
{
return
nil
,
errors
.
New
(
"Session does not contain a valid Signature Request"
)
}
entry
.
SignedMessage
=
[]
byte
(
request
.
Message
)
}
fallthrough
case
irma
.
ActionDisclosing
:
if
prooflist
,
ok
=
response
.
(
gabi
.
ProofList
);
!
ok
{
...
...
irmaclient/session.go
View file @
634bebc7
...
...
@@ -487,12 +487,18 @@ func (session *session) sendResponse(message interface{}) {
switch
session
.
Action
{
case
irma
.
ActionSigning
:
irmaSignature
,
ok
:=
irma
.
SignedMessageFromSession
(
session
.
irmaSession
,
message
)
request
,
ok
:=
session
.
irmaSession
.
(
*
irma
.
SignatureRequest
)
if
!
ok
{
session
.
fail
(
&
irma
.
SessionError
{
ErrorType
:
irma
.
ErrorSerialization
,
Info
:
"Type assertion failed"
})
return
}
irmaSignature
,
err
:=
request
.
SignatureFromMessage
(
message
)
if
err
!=
nil
{
session
.
fail
(
&
irma
.
SessionError
{
ErrorType
:
irma
.
ErrorSerialization
,
Info
:
"Type assertion failed"
})
return
}
messageJson
,
err
=
json
.
Marshal
(
irmaSignature
)
if
err
!=
nil
{
session
.
fail
(
&
irma
.
SessionError
{
ErrorType
:
irma
.
ErrorSerialization
,
Err
:
err
})
...
...
@@ -509,8 +515,8 @@ func (session *session) sendResponse(message interface{}) {
session
.
fail
(
&
irma
.
SessionError
{
ErrorType
:
irma
.
ErrorRejected
,
Info
:
string
(
response
)})
return
}
log
,
_
=
session
.
createLogEntry
(
message
.
(
gabi
.
ProofList
))
// TODO err // TODO: also for non-interactive sessions?
}
log
,
_
=
session
.
createLogEntry
(
message
.
(
gabi
.
ProofList
))
// TODO err
case
irma
.
ActionDisclosing
:
var
response
disclosureResponse
if
err
=
session
.
transport
.
Post
(
"proofs"
,
&
response
,
message
);
err
!=
nil
{
...
...
requests.go
View file @
634bebc7
...
...
@@ -8,6 +8,7 @@ import (
"encoding/json"
"github.com/go-errors/errors"
"github.com/mhe/gabi"
)
// SessionRequest contains the context and nonce for an IRMA session.
...
...
@@ -333,6 +334,21 @@ func (sr *SignatureRequest) UnmarshalJSON(b []byte) error {
return
err
}
func
(
sr
*
SignatureRequest
)
SignatureFromMessage
(
message
interface
{})
(
*
IrmaSignedMessage
,
error
)
{
signature
,
ok
:=
message
.
(
gabi
.
ProofList
)
if
!
ok
{
return
nil
,
errors
.
Errorf
(
"Type assertion failed"
)
}
return
&
IrmaSignedMessage
{
Signature
:
&
signature
,
Nonce
:
sr
.
Nonce
,
Context
:
sr
.
Context
,
Message
:
sr
.
Message
,
},
nil
}
// Check if Timestamp is before other Timestamp. Used for checking expiry of attributes
func
(
t
Timestamp
)
Before
(
u
Timestamp
)
bool
{
return
time
.
Time
(
t
)
.
Before
(
time
.
Time
(
u
))
...
...
verify.go
View file @
634bebc7
...
...
@@ -141,15 +141,6 @@ func (proofResult *ProofResult) ContainsAttribute(attrId AttributeTypeIdentifier
return
false
}
// Get string value of disclosed attribute, or nil if request attribute isn't disclosed in this credential
//func (cred *DisclosedCredential) GetAttributeValue(id AttributeTypeIdentifier) string {
// attr := cred.Attributes[id]
// if attr != nil {
// return string(attr.Bytes())
// }
// return ""
//}
func
(
cred
*
DisclosedCredential
)
IsExpired
()
bool
{
return
cred
.
metadataAttribute
.
Expiry
()
.
Before
(
time
.
Now
())
}
...
...
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