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
c0a1415d
Commit
c0a1415d
authored
Oct 11, 2017
by
Sietse Ringers
Browse files
Add PinHandler interface to keyshare and manager api
parent
9f7626c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
keyshare.go
View file @
c0a1415d
...
...
@@ -17,7 +17,7 @@ import (
// KeysharePinRequestor is used to asking the user for his PIN.
type
KeysharePinRequestor
interface
{
RequestPin
(
remainingAttempts
int
,
callback
func
(
proceed
bool
,
pin
string
)
)
RequestPin
(
remainingAttempts
int
,
callback
PinHandler
)
}
type
keyshareSessionHandler
interface
{
...
...
@@ -203,7 +203,7 @@ func startKeyshareSession(
// Ask for a pin, repeatedly if necessary, and either continue the keyshare protocol
// with authorization, or stop the keyshare protocol and inform of failure.
func
(
ks
*
keyshareSession
)
VerifyPin
(
attempts
int
)
{
ks
.
pinRequestor
.
RequestPin
(
attempts
,
func
(
proceed
bool
,
pin
string
)
{
ks
.
pinRequestor
.
RequestPin
(
attempts
,
PinHandler
(
func
(
proceed
bool
,
pin
string
)
{
success
,
attemptsRemaining
,
blocked
,
err
:=
ks
.
verifyPinAttempt
(
pin
)
if
err
!=
nil
{
ks
.
sessionHandler
.
KeyshareError
(
err
)
...
...
@@ -222,7 +222,7 @@ func (ks *keyshareSession) VerifyPin(attempts int) {
}
// Not successful but no error and not yet blocked: try again
ks
.
VerifyPin
(
attemptsRemaining
)
})
})
)
}
// Verify the specified pin at each of the keyshare servers involved in the specified session.
...
...
session.go
View file @
c0a1415d
...
...
@@ -17,6 +17,8 @@ import (
// and specifying the attributes to be disclosed.
type
PermissionHandler
func
(
proceed
bool
,
choice
*
DisclosureChoice
)
type
PinHandler
func
(
proceed
bool
,
pin
string
)
// A Handler contains callbacks for communication to the user.
type
Handler
interface
{
StatusUpdate
(
action
Action
,
status
Status
)
...
...
@@ -31,7 +33,7 @@ type Handler interface {
RequestSignaturePermission
(
request
SignatureRequest
,
ServerName
string
,
callback
PermissionHandler
)
RequestSchemeManagerPermission
(
manager
*
SchemeManager
,
callback
func
(
proceed
bool
))
RequestPin
(
remainingAttempts
int
,
callback
func
(
proceed
bool
,
pin
string
)
)
RequestPin
(
remainingAttempts
int
,
callback
PinHandler
)
}
// A session is an IRMA session.
...
...
session_test.go
View file @
c0a1415d
...
...
@@ -69,7 +69,7 @@ func (th TestHandler) RequestSignaturePermission(request SignatureRequest, Serve
func
(
th
TestHandler
)
RequestSchemeManagerPermission
(
manager
*
SchemeManager
,
callback
func
(
proceed
bool
))
{
callback
(
true
)
}
func
(
th
TestHandler
)
RequestPin
(
remainingAttempts
int
,
callback
func
(
proceed
bool
,
pin
string
)
)
{
func
(
th
TestHandler
)
RequestPin
(
remainingAttempts
int
,
callback
PinHandler
)
{
callback
(
true
,
"12345"
)
}
...
...
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