-
Notifications
You must be signed in to change notification settings - Fork 25
/
helper.go
50 lines (42 loc) · 1.16 KB
/
helper.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
package pkcs1
// Cipher 列表
var pemCiphers = map[string]Cipher{
"DESCBC": CipherDESCBC,
"DESEDE3CBC": Cipher3DESCBC,
"AES128CBC": CipherAES128CBC,
"AES192CBC": CipherAES192CBC,
"AES256CBC": CipherAES256CBC,
"SM4CBC": CipherSM4CBC,
"DESCFB": CipherDESCFB,
"DESEDE3CFB": Cipher3DESCFB,
"AES128CFB": CipherAES128CFB,
"AES192CFB": CipherAES192CFB,
"AES256CFB": CipherAES256CFB,
"SM4CFB": CipherSM4CFB,
"DESOFB": CipherDESOFB,
"DESEDE3OFB": Cipher3DESOFB,
"AES128OFB": CipherAES128OFB,
"AES192OFB": CipherAES192OFB,
"AES256OFB": CipherAES256OFB,
"SM4OFB": CipherSM4OFB,
"DESCTR": CipherDESCTR,
"DESEDE3CTR": Cipher3DESCTR,
"AES128CTR": CipherAES128CTR,
"AES192CTR": CipherAES192CTR,
"AES256CTR": CipherAES256CTR,
"SM4CTR": CipherSM4CTR,
}
// 获取 Cipher 类型
func GetPEMCipher(name string) Cipher {
if cipher, ok := pemCiphers[name]; ok {
return cipher
}
return nil
}
// 检测 Cipher 类型
func CheckPEMCipher(name string) bool {
if _, ok := pemCiphers[name]; ok {
return true
}
return false
}