forked from tstranex/u2f
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmessages.go
92 lines (79 loc) · 2.78 KB
/
messages.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Go FIDO U2F Library
// Copyright 2015 The Go FIDO U2F Library Authors. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package u2f
import (
"encoding/json"
)
// U2F message transport types
const U2FTransportBT string = "bt"
const U2FTransportBLE string = "ble"
const U2FTransportNFC string = "nfc"
const U2FTransportUSB string = "usb"
// JwkKey represents a public key used by a browser for the Channel ID TLS
// extension.
type JwkKey struct {
KTy string `json:"kty"`
Crv string `json:"crv"`
X string `json:"x"`
Y string `json:"y"`
}
// ClientData as defined by the FIDO U2F Raw Message Formats specification.
type ClientData struct {
Typ string `json:"typ"`
Challenge string `json:"challenge"`
Origin string `json:"origin"`
CIDPublicKey json.RawMessage `json:"cid_pubkey"`
}
// RegisterRequest defines a registration challenge to the token
type registerRequest struct {
Version string `json:"version"`
Challenge string `json:"challenge"`
AppID string `json:"appId,omitempty"`
}
// RegisteredKey represents a U2F key registered to the account
type registeredKey struct {
Version string `json:"version"`
KeyHandle string `json:"keyHandle"`
Transports string `json:"transports,omitempty"`
AppID string `json:"appId,omitempty"`
}
// Represents U2F Registration Request
// This message is passed to the browser for registration
type RegisterRequestMessage struct {
AppID string `json:"appId"`
RegisterRequests []registerRequest `json:"registerRequests"`
RegisteredKeys []registeredKey `json:"registeredKeys"`
}
// RegisterResponse is the structure returned by the token/u2f implementation
type RegisterResponse struct {
RegistrationData string `json:"registrationData"`
ClientData string `json:"clientData"`
}
// Represents a U2F Signature Request.
// This message is passed to the browser for authentication
type SignRequestMessage struct {
AppID string `json:"appId"`
Challenge string `json:"challenge"`
RegisteredKeys []registeredKey `json:"registeredKeys"`
}
// SignResponse as defined by the FIDO U2F Javascript API.
type SignResponse struct {
KeyHandle string `json:"keyHandle"`
SignatureData string `json:"signatureData"`
ClientData string `json:"clientData"`
}
// TrustedFacets as defined by the FIDO AppID and Facet Specification.
type TrustedFacets struct {
Version struct {
Major int `json:"major"`
Minor int `json:"minor"`
} `json:"version"`
Ids []string `json:"ids"`
}
// TrustedFacetsEndpoint is a container of TrustedFacets.
// It is used as the response for an appId URL endpoint.
type TrustedFacetsEndpoint struct {
TrustedFacets []TrustedFacets `json:"trustedFacets"`
}