forked from bifurcation/mint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.go
127 lines (108 loc) · 3.47 KB
/
common.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package mint
var (
draftVersionImplemented = 11
// Flags for some minor compat issues
allowEmptyEncryptedExtensions = false
allowWrongVersionNumber = false
allowPKCS1 = true
)
// enum {...} ContentType;
type recordType byte
const (
recordTypeAlert recordType = 21
recordTypeHandshake recordType = 22
recordTypeApplicationData recordType = 23
)
// enum {...} HandshakeType;
type handshakeType byte
const (
// Omitted: *_RESERVED
handshakeTypeClientHello handshakeType = 1
handshakeTypeServerHello handshakeType = 2
handshakeTypeSessionTicket handshakeType = 4
handshakeTypeHelloRetryRequest handshakeType = 6
handshakeTypeEncryptedExtensions handshakeType = 8
handshakeTypeCertificate handshakeType = 11
handshakeTypeCertificateRequest handshakeType = 13
handshakeTypeCertificateVerify handshakeType = 15
handshakeTypeServerConfiguration handshakeType = 17
handshakeTypeFinished handshakeType = 20
handshakeTypeKeyUpdate handshakeType = 24
)
// uint8 CipherSuite[2];
type cipherSuite uint16
const (
// REQUIRED
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 cipherSuite = 0xC02B
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipherSuite = 0xC02F
// RECOMMENDED
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 cipherSuite = 0xC02C
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 cipherSuite = 0xCCA9
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 cipherSuite = 0xC030
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 cipherSuite = 0xCCA8
)
// enum {...} HashAlgorithm
type hashAlgorithm uint8
const (
// Omitted: *_RESERVED
hashAlgorithmSHA1 hashAlgorithm = 2
hashAlgorithmSHA256 hashAlgorithm = 4
hashAlgorithmSHA384 hashAlgorithm = 5
hashAlgorithmSHA512 hashAlgorithm = 6
)
// enum {...} SignatureAlgorithm
type signatureAlgorithm uint8
const (
// Omitted: *_RESERVED
signatureAlgorithmRSA signatureAlgorithm = 1
signatureAlgorithmDSA signatureAlgorithm = 2
signatureAlgorithmECDSA signatureAlgorithm = 3
signatureAlgorithmRSAPSS signatureAlgorithm = 4
signatureAlgorithmEdDSA signatureAlgorithm = 5
)
// struct {
// HashAlgorithm hash;
// SignatureAlgorithm signature;
// } SignatureAndHashAlgorithm;
//
type signatureAndHashAlgorithm struct {
hash hashAlgorithm
signature signatureAlgorithm
}
// enum {...} ExtensionType
type helloExtensionType uint16
const (
extensionTypeUnknown helloExtensionType = 0xffff
extensionTypeServerName helloExtensionType = 0
extensionTypeSupportedGroups helloExtensionType = 10
extensionTypeSignatureAlgorithms helloExtensionType = 13
extensionTypeKeyShare helloExtensionType = 40 // Provisional value, from NSS
extensionTypeDraftVersion helloExtensionType = 0xff02 // Required for NSS
)
// enum {...} NamedGroup
type namedGroup uint16
const (
namedGroupUnknown namedGroup = 0
// Elliptic Curve Groups.
namedGroupP256 namedGroup = 23
namedGroupP384 namedGroup = 24
namedGroupP521 namedGroup = 25
// ECDH functions.
namedGroupX25519 namedGroup = 29
namedGroupX448 namedGroup = 30
// Signature-only curves.
namedGroupEd25519 namedGroup = 31
namedGroupEd448 namedGroup = 32
// Finite field groups.
namedGroupFF2048 namedGroup = 256
namedGroupFF3072 namedGroup = 257
namedGroupFF4096 namedGroup = 258
namedGroupFF6144 namedGroup = 259
namedGroupFF8192 namedGroup = 250
)
type marshaler interface {
Marshal() ([]byte, error)
}
type unmarshaler interface {
Unmarshal([]byte) (int, error)
}