2019-11-11 16:04:53 +01:00
|
|
|
package pkcs8
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/aes"
|
|
|
|
"encoding/asn1"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
oidAES128CBC = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 2}
|
2020-06-27 16:45:12 +02:00
|
|
|
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}
|
2019-11-11 16:04:53 +01:00
|
|
|
oidAES256CBC = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 42}
|
2020-06-27 16:45:12 +02:00
|
|
|
oidAES256GCM = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 46}
|
2019-11-11 16:04:53 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RegisterCipher(oidAES128CBC, func() Cipher {
|
|
|
|
return AES128CBC
|
|
|
|
})
|
2020-06-27 16:45:12 +02:00
|
|
|
RegisterCipher(oidAES128GCM, func() Cipher {
|
|
|
|
return AES128GCM
|
|
|
|
})
|
|
|
|
RegisterCipher(oidAES192CBC, func() Cipher {
|
|
|
|
return AES192CBC
|
|
|
|
})
|
|
|
|
RegisterCipher(oidAES192GCM, func() Cipher {
|
|
|
|
return AES192GCM
|
|
|
|
})
|
2019-11-11 16:04:53 +01:00
|
|
|
RegisterCipher(oidAES256CBC, func() Cipher {
|
|
|
|
return AES256CBC
|
|
|
|
})
|
2020-06-27 16:45:12 +02:00
|
|
|
RegisterCipher(oidAES256GCM, func() Cipher {
|
|
|
|
return AES256GCM
|
|
|
|
})
|
2019-11-11 16:04:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// AES128CBC is the 128-bit key AES cipher in CBC mode.
|
|
|
|
var AES128CBC = cipherWithBlock{
|
|
|
|
ivSize: aes.BlockSize,
|
|
|
|
keySize: 16,
|
|
|
|
newBlock: aes.NewCipher,
|
|
|
|
oid: oidAES128CBC,
|
|
|
|
}
|
|
|
|
|
2020-06-27 16:45:12 +02:00
|
|
|
// AES128GCM is the 128-bit key AES cipher in GCM mode.
|
|
|
|
var AES128GCM = cipherWithBlock{
|
|
|
|
ivSize: aes.BlockSize,
|
|
|
|
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 = cipherWithBlock{
|
|
|
|
ivSize: aes.BlockSize,
|
|
|
|
keySize: 24,
|
|
|
|
newBlock: aes.NewCipher,
|
|
|
|
oid: oidAES192GCM,
|
|
|
|
}
|
|
|
|
|
2019-11-11 16:04:53 +01:00
|
|
|
// AES256CBC is the 256-bit key AES cipher in CBC mode.
|
|
|
|
var AES256CBC = cipherWithBlock{
|
|
|
|
ivSize: aes.BlockSize,
|
|
|
|
keySize: 32,
|
|
|
|
newBlock: aes.NewCipher,
|
|
|
|
oid: oidAES256CBC,
|
|
|
|
}
|
2020-06-27 16:45:12 +02:00
|
|
|
|
|
|
|
// AES256GCM is the 256-bit key AES cipher in GCM mode.
|
|
|
|
var AES256GCM = cipherWithBlock{
|
|
|
|
ivSize: aes.BlockSize,
|
|
|
|
keySize: 32,
|
|
|
|
newBlock: aes.NewCipher,
|
|
|
|
oid: oidAES256GCM,
|
|
|
|
}
|