blob: 46a0d748fb76f30d4f0484807152248a032a0aad [file] [log] [blame]
Scott Baker8461e152019-10-01 14:44:30 -07001// Package etypeID provides Kerberos 5 encryption type assigned numbers.
2package etypeID
3
4// Kerberos encryption type assigned numbers.
5const (
6 //RESERVED : 0
7 DES_CBC_CRC int32 = 1
8 DES_CBC_MD4 int32 = 2
9 DES_CBC_MD5 int32 = 3
10 DES_CBC_RAW int32 = 4
11 DES3_CBC_MD5 int32 = 5
12 DES3_CBC_RAW int32 = 6
13 DES3_CBC_SHA1 int32 = 7
14 DES_HMAC_SHA1 int32 = 8
15 DSAWITHSHA1_CMSOID int32 = 9
16 MD5WITHRSAENCRYPTION_CMSOID int32 = 10
17 SHA1WITHRSAENCRYPTION_CMSOID int32 = 11
18 RC2CBC_ENVOID int32 = 12
19 RSAENCRYPTION_ENVOID int32 = 13
20 RSAES_OAEP_ENV_OID int32 = 14
21 DES_EDE3_CBC_ENV_OID int32 = 15
22 DES3_CBC_SHA1_KD int32 = 16
23 AES128_CTS_HMAC_SHA1_96 int32 = 17
24 AES256_CTS_HMAC_SHA1_96 int32 = 18
25 AES128_CTS_HMAC_SHA256_128 int32 = 19
26 AES256_CTS_HMAC_SHA384_192 int32 = 20
27 //UNASSIGNED : 21-22
28 RC4_HMAC int32 = 23
29 RC4_HMAC_EXP int32 = 24
30 CAMELLIA128_CTS_CMAC int32 = 25
31 CAMELLIA256_CTS_CMAC int32 = 26
32 //UNASSIGNED : 27-64
33 SUBKEY_KEYMATERIAL int32 = 65
34 //UNASSIGNED : 66-2147483647
35)
36
37// ETypesByName is a map of EncType names to their assigned EncType number.
38var ETypesByName = map[string]int32{
39 "des-cbc-crc": DES_CBC_CRC,
40 "des-cbc-md4": DES_CBC_MD4,
41 "des-cbc-md5": DES_CBC_MD5,
42 "des-cbc-raw": DES_CBC_RAW,
43 "des3-cbc-md5": DES3_CBC_MD5,
44 "des3-cbc-raw": DES3_CBC_RAW,
45 "des3-cbc-sha1": DES3_CBC_SHA1,
46 "des3-hmac-sha1": DES_HMAC_SHA1,
47 "des3-cbc-sha1-kd": DES3_CBC_SHA1_KD,
48 "des-hmac-sha1": DES_HMAC_SHA1,
49 "dsaWithSHA1-CmsOID": DSAWITHSHA1_CMSOID,
50 "md5WithRSAEncryption-CmsOID": MD5WITHRSAENCRYPTION_CMSOID,
51 "sha1WithRSAEncryption-CmsOID": SHA1WITHRSAENCRYPTION_CMSOID,
52 "rc2CBC-EnvOID": RC2CBC_ENVOID,
53 "rsaEncryption-EnvOID": RSAENCRYPTION_ENVOID,
54 "rsaES-OAEP-ENV-OID": RSAES_OAEP_ENV_OID,
55 "des-ede3-cbc-Env-OID": DES_EDE3_CBC_ENV_OID,
56 "aes128-cts-hmac-sha1-96": AES128_CTS_HMAC_SHA1_96,
57 "aes128-cts": AES128_CTS_HMAC_SHA1_96,
58 "aes128-sha1": AES128_CTS_HMAC_SHA1_96,
59 "aes256-cts-hmac-sha1-96": AES256_CTS_HMAC_SHA1_96,
60 "aes256-cts": AES256_CTS_HMAC_SHA1_96,
61 "aes256-sha1": AES256_CTS_HMAC_SHA1_96,
62 "aes128-cts-hmac-sha256-128": AES128_CTS_HMAC_SHA256_128,
63 "aes128-sha2": AES128_CTS_HMAC_SHA256_128,
64 "aes256-cts-hmac-sha384-192": AES256_CTS_HMAC_SHA384_192,
65 "aes256-sha2": AES256_CTS_HMAC_SHA384_192,
66 "arcfour-hmac": RC4_HMAC,
67 "rc4-hmac": RC4_HMAC,
68 "arcfour-hmac-md5": RC4_HMAC,
69 "arcfour-hmac-exp": RC4_HMAC_EXP,
70 "rc4-hmac-exp": RC4_HMAC_EXP,
71 "arcfour-hmac-md5-exp": RC4_HMAC_EXP,
72 "camellia128-cts-cmac": CAMELLIA128_CTS_CMAC,
73 "camellia128-cts": CAMELLIA128_CTS_CMAC,
74 "camellia256-cts-cmac": CAMELLIA256_CTS_CMAC,
75 "camellia256-cts": CAMELLIA256_CTS_CMAC,
76 "subkey-keymaterial": SUBKEY_KEYMATERIAL,
77}
78
79// EtypeSupported resolves the etype name string to the etype ID.
80// If zero is returned the etype is not supported by gokrb5.
81func EtypeSupported(etype string) int32 {
82 // Slice of supported enctype IDs
83 s := []int32{
84 AES128_CTS_HMAC_SHA1_96,
85 AES256_CTS_HMAC_SHA1_96,
86 AES128_CTS_HMAC_SHA256_128,
87 AES256_CTS_HMAC_SHA384_192,
88 DES3_CBC_SHA1_KD,
89 RC4_HMAC,
90 }
91 id := ETypesByName[etype]
92 if id == 0 {
93 return id
94 }
95 for _, sid := range s {
96 if id == sid {
97 return id
98 }
99 }
100 return 0
101}