-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfido.go
61 lines (48 loc) · 2.07 KB
/
fido.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package k6fido
import (
"encoding/json"
"fmt"
)
type SendUafResponse struct {
UafResponse string `json:"uafResponse"`
Context string `json:"context"`
}
// Externally visible: Generates Fido Registration Response
func (k6fido *K6Fido) GenerateRegistrationResponse(aaid string, uafRequest string,
trustedFacetId string, overriddenSignature string, signatureSignData string,
privKey string, pubKey string, keyId string) (string, error) {
fidoRegistrationUafRequest := NewFidoRegistrationReturnUafRequest(uafRequest)
fidoRegistrationResponse := FidoRegistrationResponse{
facetId: trustedFacetId,
returnUafRequest: *fidoRegistrationUafRequest,
}
sendUafResponse, err := fidoRegistrationResponse.Build(aaid, overriddenSignature, signatureSignData, privKey, pubKey, keyId)
if err != nil {
return "", fmt.Errorf("Failed to build registration response: %v", err)
}
fidoRegistrationResponseString, err := json.Marshal(sendUafResponse)
if err != nil {
return "", fmt.Errorf("Failed to unmarshall ufa response: %v", err)
}
return string(fidoRegistrationResponseString), nil
}
// Externally visible: Generates Fido Authentication Response
func (k6fido *K6Fido) GenerateAuthenticationResponse(aaid string, uafRequest string,
trustedFacetId string, overriddenSignature string, signatureSignData string,
privKey string, pubKey string, username string, keyId string) (string, error) {
fidoAuthenticationUafRequest := NewFidoAuthenticationReturnUafRequest(uafRequest)
fidoAuthenticationResponse := FidoAuthenticationResponse{
facetId: trustedFacetId,
returnUafRequest: *fidoAuthenticationUafRequest,
username: username,
}
sendUafResponse, err := fidoAuthenticationResponse.Build(aaid, overriddenSignature, signatureSignData, privKey, pubKey, keyId)
if err != nil {
return "", fmt.Errorf("Failed to build authentication response: %v", err)
}
fidoRegistrationResponseString, err := json.Marshal(sendUafResponse)
if err != nil {
return "", fmt.Errorf("Failed to marshall send ufa response: %v", err)
}
return string(fidoRegistrationResponseString), nil
}