-
Notifications
You must be signed in to change notification settings - Fork 61
/
cipher_aes.go
84 lines (75 loc) · 1.96 KB
/
cipher_aes.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
package pkcs8
import (
"crypto/aes"
"encoding/asn1"
)
var (
oidAES128CBC = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 2}
oidAES128GCM = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 6}
oidAES192CBC = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 22}
oidAES192GCM = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 26}
oidAES256CBC = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 42}
oidAES256GCM = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 46}
)
func init() {
RegisterCipher(oidAES128CBC, func() Cipher {
return &AES128CBC
})
RegisterCipher(oidAES128GCM, func() Cipher {
return &AES128GCM
})
RegisterCipher(oidAES192CBC, func() Cipher {
return &AES192CBC
})
RegisterCipher(oidAES192GCM, func() Cipher {
return &AES192GCM
})
RegisterCipher(oidAES256CBC, func() Cipher {
return &AES256CBC
})
RegisterCipher(oidAES256GCM, func() Cipher {
return &AES256GCM
})
}
// AES128CBC is the 128-bit key AES cipher in CBC mode.
var AES128CBC = cipherWithBlock{
ivSize: aes.BlockSize,
keySize: 16,
newBlock: aes.NewCipher,
oid: oidAES128CBC,
}
// AES128GCM is the 128-bit key AES cipher in GCM mode.
var AES128GCM = cipherWithGCM{
nonceSize: 12,
keySize: 16,
newBlock: aes.NewCipher,
oid: oidAES128GCM,
}
// AES192CBC is the 192-bit key AES cipher in CBC mode.
var AES192CBC = cipherWithBlock{
ivSize: aes.BlockSize,
keySize: 24,
newBlock: aes.NewCipher,
oid: oidAES192CBC,
}
// AES192GCM is the 912-bit key AES cipher in GCM mode.
var AES192GCM = cipherWithGCM{
nonceSize: 12,
keySize: 24,
newBlock: aes.NewCipher,
oid: oidAES192GCM,
}
// AES256CBC is the 256-bit key AES cipher in CBC mode.
var AES256CBC = cipherWithBlock{
ivSize: aes.BlockSize,
keySize: 32,
newBlock: aes.NewCipher,
oid: oidAES256CBC,
}
// AES256GCM is the 256-bit key AES cipher in GCM mode.
var AES256GCM = cipherWithGCM{
nonceSize: 12,
keySize: 32,
newBlock: aes.NewCipher,
oid: oidAES256GCM,
}