xref: /illumos-gate/usr/src/uts/common/gssapi/mechs/krb5/crypto/cksumtypes.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 /*
9  * Copyright (C) 1998 by the FundsXpress, INC.
10  *
11  * All rights reserved.
12  *
13  * Export of this software from the United States of America may require
14  * a specific license from the United States Government.  It is the
15  * responsibility of any person or organization contemplating export to
16  * obtain such a license before exporting.
17  *
18  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
19  * distribute this software and its documentation for any purpose and
20  * without fee is hereby granted, provided that the above copyright
21  * notice appear in all copies and that both that copyright notice and
22  * this permission notice appear in supporting documentation, and that
23  * the name of FundsXpress. not be used in advertising or publicity pertaining
24  * to distribution of the software without specific, written prior
25  * permission.  FundsXpress makes no representations about the suitability of
26  * this software for any purpose.  It is provided "as is" without express
27  * or implied warranty.
28  *
29  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
30  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
31  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  */
33 
34 #include <k5-int.h>
35 #include <hash_provider.h>
36 #include <keyhash_provider.h>
37 #include <cksumtypes.h>
38 
39 struct krb5_cksumtypes krb5_cksumtypes_list[] = {
40     { CKSUMTYPE_CRC32, KRB5_CKSUMFLAG_NOT_COLL_PROOF,
41       "crc32", "CRC-32",
42       NULL, NULL, &krb5_hash_crc32, 0,
43 #ifdef _KERNEL
44       NULL,
45       CRYPTO_MECH_INVALID
46 #endif /* _KERNEL */
47 },
48 
49     { CKSUMTYPE_DESCBC, 0,
50       "des-cbc", "DES cbc mode",
51       ENCTYPE_DES_CBC_CRC, &krb5_keyhash_descbc,
52       NULL,  NULL,
53 #ifdef _KERNEL
54       NULL,
55       CRYPTO_MECH_INVALID
56 #endif /* _KERNEL */
57 },
58 
59     { CKSUMTYPE_RSA_MD5, 0,
60       "md5", "RSA-MD5",
61       NULL, NULL, &krb5int_hash_md5, 0,
62 #ifdef _KERNEL
63       SUN_CKM_MD5,
64       CRYPTO_MECH_INVALID
65 #endif /* _KERNEL */
66 },
67     { CKSUMTYPE_RSA_MD5_DES, 0,
68       "md5-des", "RSA-MD5 with DES cbc mode",
69       ENCTYPE_DES_CBC_CRC, &krb5_keyhash_md5des,
70       NULL, NULL,
71 #ifdef _KERNEL
72       SUN_CKM_MD5,
73       CRYPTO_MECH_INVALID
74 #endif /* _KERNEL */
75 },
76 
77     { CKSUMTYPE_NIST_SHA, 0,
78       "sha", "NIST-SHA",
79       NULL, NULL, &krb5_hash_sha1, 0,
80 #ifdef _KERNEL
81       SUN_CKM_SHA1,
82       CRYPTO_MECH_INVALID
83 #endif /* _KERNEL */
84 },
85 
86     { CKSUMTYPE_HMAC_SHA1_DES3, KRB5_CKSUMFLAG_DERIVE,
87       "hmac-sha1-des3", "HMAC-SHA1 DES3 key",
88       NULL, NULL, &krb5_hash_sha1, 0,
89 #ifdef _KERNEL
90       SUN_CKM_SHA1_HMAC,
91       CRYPTO_MECH_INVALID
92 #endif /* _KERNEL */
93  },
94     { CKSUMTYPE_HMAC_SHA1_DES3, KRB5_CKSUMFLAG_DERIVE,
95       "hmac-sha1-des3-kd", "HMAC-SHA1 DES3 key", /* alias */
96       NULL, NULL, &krb5_hash_sha1, 0,
97 #ifdef _KERNEL
98       SUN_CKM_SHA1_HMAC,
99       CRYPTO_MECH_INVALID
100 #endif /* _KERNEL */
101 },
102     { CKSUMTYPE_HMAC_MD5_ARCFOUR, 0,
103 	"hmac-md5-rc4", "Microsoft HMAC MD5 (RC4 key)",
104 	ENCTYPE_ARCFOUR_HMAC, &krb5int_keyhash_hmac_md5, NULL, 0,
105 #ifdef _KERNEL
106       SUN_CKM_MD5,
107       CRYPTO_MECH_INVALID
108 #endif /* _KERNEL */
109     },
110     { CKSUMTYPE_HMAC_MD5_ARCFOUR, 0,
111 	"hmac-md5-enc", "Microsoft HMAC MD5 (RC4 key)",  /*Heimdal alias*/
112 	ENCTYPE_ARCFOUR_HMAC, &krb5int_keyhash_hmac_md5, NULL, 0,
113 #ifdef _KERNEL
114       SUN_CKM_MD5,
115       CRYPTO_MECH_INVALID
116 #endif /* _KERNEL */
117     },
118     { CKSUMTYPE_HMAC_MD5_ARCFOUR, 0,
119 	"hmac-md5-earcfour", "Microsoft HMAC MD5 (RC4 key)",  /* alias*/
120 	ENCTYPE_ARCFOUR_HMAC, &krb5int_keyhash_hmac_md5, NULL, 0,
121 #ifdef _KERNEL
122       SUN_CKM_MD5,
123       CRYPTO_MECH_INVALID
124 #endif /* _KERNEL */
125     },
126 
127     { CKSUMTYPE_HMAC_SHA1_96_AES128, KRB5_CKSUMFLAG_DERIVE,
128 	"hmac-sha1-96-aes128", "HMAC-SHA1 AES128 key",
129 	NULL, NULL, &krb5_hash_sha1, 12,
130 #ifdef _KERNEL
131       SUN_CKM_SHA1_HMAC,
132       CRYPTO_MECH_INVALID
133 #endif /* _KERNEL */
134     },
135     { CKSUMTYPE_HMAC_SHA1_96_AES256, KRB5_CKSUMFLAG_DERIVE,
136 	"hmac-sha1-96-aes256", "HMAC-SHA1 AES256 key",
137 	0, NULL, &krb5_hash_sha1, 12,
138 #ifdef _KERNEL
139       SUN_CKM_SHA1_HMAC,
140       CRYPTO_MECH_INVALID
141 #endif /* _KERNEL */
142     }
143 
144 };
145 
146 const int krb5_cksumtypes_length =
147 sizeof(krb5_cksumtypes_list)/sizeof(struct krb5_cksumtypes);
148 
149 #ifdef _KERNEL
150 void
151 setup_kef_cksumtypes()
152 {
153 	int i;
154 	struct krb5_cksumtypes *ck;
155 
156 	for (i=0; i<krb5_cksumtypes_length; i++) {
157 		ck = (struct krb5_cksumtypes *)&krb5_cksumtypes_list[i];
158 		if (ck != NULL &&
159 		    ck->mt_c_name != NULL &&
160 		    ck->kef_cksum_mt == CRYPTO_MECH_INVALID) {
161 
162 			ck->kef_cksum_mt = crypto_mech2id(ck->mt_c_name);
163 			KRB5_LOG1(KRB5_INFO, "setup_kef_cksumtypes() - "
164 				"%s ==> %ld",
165 				ck->mt_c_name, (ulong_t)ck->kef_cksum_mt);
166 		}
167 	}
168 }
169 #endif /* _KERNEL */
170