2 Unix SMB/CIFS implementation.
4 Kerberos utility functions
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2012
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "krb5_samba.h"
25 #include "librpc/gen_ndr/netlogon.h"
27 const krb5_enctype
*samba_all_enctypes(void)
29 /* TODO: Find a way not to have to use a fixed list */
30 static const krb5_enctype enctypes
[] = {
33 ENCTYPE_AES128_CTS_HMAC_SHA1_96
,
34 ENCTYPE_AES256_CTS_HMAC_SHA1_96
,
41 /* Translate between the IETF encryption type values and the Microsoft
42 * msDS-SupportedEncryptionTypes values */
43 uint32_t kerberos_enctype_to_bitmap(krb5_enctype enc_type_enum
)
45 switch (enc_type_enum
) {
46 case ENCTYPE_DES_CBC_CRC
:
48 case ENCTYPE_DES_CBC_MD5
:
50 case ENCTYPE_ARCFOUR_HMAC
:
51 return ENC_RC4_HMAC_MD5
;
52 case ENCTYPE_AES128_CTS_HMAC_SHA1_96
:
53 return ENC_HMAC_SHA1_96_AES128
;
54 case ENCTYPE_AES256_CTS_HMAC_SHA1_96
:
55 return ENC_HMAC_SHA1_96_AES256
;
61 /* Translate between the Microsoft msDS-SupportedEncryptionTypes values
62 * and the IETF encryption type values */
63 krb5_enctype
ms_suptype_to_ietf_enctype(uint32_t enctype_bitmap
)
65 switch (enctype_bitmap
) {
67 return ENCTYPE_DES_CBC_CRC
;
69 return ENCTYPE_DES_CBC_MD5
;
70 case ENC_RC4_HMAC_MD5
:
71 return ENCTYPE_ARCFOUR_HMAC
;
72 case ENC_HMAC_SHA1_96_AES128
:
73 return ENCTYPE_AES128_CTS_HMAC_SHA1_96
;
74 case ENC_HMAC_SHA1_96_AES256
:
75 return ENCTYPE_AES256_CTS_HMAC_SHA1_96
;
81 /* Return an array of krb5_enctype values */
82 krb5_error_code
ms_suptypes_to_ietf_enctypes(TALLOC_CTX
*mem_ctx
,
83 uint32_t enctype_bitmap
,
84 krb5_enctype
**enctypes
)
86 unsigned int i
, j
= 0;
87 *enctypes
= talloc_zero_array(mem_ctx
, krb5_enctype
,
88 (8 * sizeof(enctype_bitmap
)) + 1);
92 for (i
= 0; i
< (8 * sizeof(enctype_bitmap
)); i
++) {
93 uint32_t bit_value
= (1 << i
) & enctype_bitmap
;
94 if (bit_value
& enctype_bitmap
) {
95 (*enctypes
)[j
] = ms_suptype_to_ietf_enctype(bit_value
);
96 if (!(*enctypes
)[j
]) {