2 * Copyright (c) 1997 - 2008 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #ifndef HEIMDAL_SMALLER
35 #define DES3_OLD_ENCTYPE 1
48 struct krb5_crypto_data {
49 struct encryption_type *et;
52 struct key_usage *key_usage;
55 #define CRYPTO_ETYPE(C) ((C)->et->type)
57 /* bits for `flags' below */
58 #define F_KEYED 1 /* checksum is keyed */
59 #define F_CPROOF 2 /* checksum is collision proof */
60 #define F_DERIVED 4 /* uses derived keys */
61 #define F_VARIANT 8 /* uses `variant' keys (6.4.3) */
62 #define F_PSEUDO 16 /* not a real protocol type */
63 #define F_SPECIAL 32 /* backwards */
64 #define F_DISABLED 64 /* enctype/checksum disabled */
65 #define F_WEAK 128 /* enctype is considered weak */
70 krb5_error_code (*string_to_key)(krb5_context, krb5_enctype, krb5_data,
71 krb5_salt, krb5_data, krb5_keyblock*);
75 krb5_keytype type; /* XXX */
80 void (*random_key)(krb5_context, krb5_keyblock*);
81 void (*schedule)(krb5_context, struct key_type *, struct key_data *);
82 struct salt_type *string_to_key;
83 void (*random_to_key)(krb5_context, krb5_keyblock*, const void*, size_t);
84 void (*cleanup)(krb5_context, struct key_data *);
85 const EVP_CIPHER *(*evp)(void);
88 struct checksum_type {
94 krb5_error_code (*checksum)(krb5_context context,
96 const void *buf, size_t len,
99 krb5_error_code (*verify)(krb5_context context,
100 struct key_data *key,
101 const void *buf, size_t len,
106 struct encryption_type {
111 size_t confoundersize;
112 struct key_type *keytype;
113 struct checksum_type *checksum;
114 struct checksum_type *keyed_checksum;
116 krb5_error_code (*encrypt)(krb5_context context,
117 struct key_data *key,
118 void *data, size_t len,
119 krb5_boolean encryptp,
123 krb5_error_code (*prf)(krb5_context,
124 krb5_crypto, const krb5_data *, krb5_data *);
127 #define ENCRYPTION_USAGE(U) (((U) << 8) | 0xAA)
128 #define INTEGRITY_USAGE(U) (((U) << 8) | 0x55)
129 #define CHECKSUM_USAGE(U) (((U) << 8) | 0x99)
133 extern struct checksum_type _krb5_checksum_none;
134 extern struct checksum_type _krb5_checksum_crc32;
135 extern struct checksum_type _krb5_checksum_rsa_md4;
136 extern struct checksum_type _krb5_checksum_rsa_md4_des;
137 extern struct checksum_type _krb5_checksum_rsa_md5_des;
138 extern struct checksum_type _krb5_checksum_rsa_md5_des3;
139 extern struct checksum_type _krb5_checksum_rsa_md5;
140 extern struct checksum_type _krb5_checksum_hmac_sha1_des3;
141 extern struct checksum_type _krb5_checksum_hmac_sha1_aes128;
142 extern struct checksum_type _krb5_checksum_hmac_sha1_aes256;
143 extern struct checksum_type _krb5_checksum_hmac_md5;
144 extern struct checksum_type _krb5_checksum_sha1;
146 extern struct checksum_type *_krb5_checksum_types[];
147 extern int _krb5_num_checksums;
151 extern struct salt_type _krb5_AES_salt[];
152 extern struct salt_type _krb5_arcfour_salt[];
153 extern struct salt_type _krb5_des_salt[];
154 extern struct salt_type _krb5_des3_salt[];
155 extern struct salt_type _krb5_des3_salt_derived[];
157 /* Encryption types */
159 extern struct encryption_type _krb5_enctype_aes256_cts_hmac_sha1;
160 extern struct encryption_type _krb5_enctype_aes128_cts_hmac_sha1;
161 extern struct encryption_type _krb5_enctype_des3_cbc_sha1;
162 extern struct encryption_type _krb5_enctype_des3_cbc_md5;
163 extern struct encryption_type _krb5_enctype_des3_cbc_none;
164 extern struct encryption_type _krb5_enctype_arcfour_hmac_md5;
165 extern struct encryption_type _krb5_enctype_des_cbc_md5;
166 extern struct encryption_type _krb5_enctype_old_des3_cbc_sha1;
167 extern struct encryption_type _krb5_enctype_des_cbc_crc;
168 extern struct encryption_type _krb5_enctype_des_cbc_md4;
169 extern struct encryption_type _krb5_enctype_des_cbc_md5;
170 extern struct encryption_type _krb5_enctype_des_cbc_none;
171 extern struct encryption_type _krb5_enctype_des_cfb64_none;
172 extern struct encryption_type _krb5_enctype_des_pcbc_none;
173 extern struct encryption_type _krb5_enctype_null;
175 extern struct encryption_type *_krb5_etypes[];
176 extern int _krb5_num_etypes;
178 /* Interface to the EVP crypto layer provided by hcrypto */
179 struct evp_schedule {