source: trunk/server/source4/heimdal/lib/krb5/crypto.h

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 6.7 KB
Line 
1/*
2 * Copyright (c) 1997 - 2008 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
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.
16 *
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.
20 *
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
31 * SUCH DAMAGE.
32 */
33
34#ifndef HEIMDAL_SMALLER
35#define DES3_OLD_ENCTYPE 1
36#endif
37
38struct _krb5_key_data {
39 krb5_keyblock *key;
40 krb5_data *schedule;
41};
42
43struct _krb5_key_usage;
44
45struct krb5_crypto_data {
46 struct _krb5_encryption_type *et;
47 struct _krb5_key_data key;
48 int num_key_usage;
49 struct _krb5_key_usage *key_usage;
50};
51
52#define CRYPTO_ETYPE(C) ((C)->et->type)
53
54/* bits for `flags' below */
55#define F_KEYED 1 /* checksum is keyed */
56#define F_CPROOF 2 /* checksum is collision proof */
57#define F_DERIVED 4 /* uses derived keys */
58#define F_VARIANT 8 /* uses `variant' keys (6.4.3) */
59#define F_PSEUDO 16 /* not a real protocol type */
60#define F_SPECIAL 32 /* backwards */
61#define F_DISABLED 64 /* enctype/checksum disabled */
62#define F_WEAK 128 /* enctype is considered weak */
63
64struct salt_type {
65 krb5_salttype type;
66 const char *name;
67 krb5_error_code (*string_to_key)(krb5_context, krb5_enctype, krb5_data,
68 krb5_salt, krb5_data, krb5_keyblock*);
69};
70
71struct _krb5_key_type {
72 krb5_keytype type; /* XXX */
73 const char *name;
74 size_t bits;
75 size_t size;
76 size_t schedule_size;
77 void (*random_key)(krb5_context, krb5_keyblock*);
78 void (*schedule)(krb5_context, struct _krb5_key_type *, struct _krb5_key_data *);
79 struct salt_type *string_to_key;
80 void (*random_to_key)(krb5_context, krb5_keyblock*, const void*, size_t);
81 void (*cleanup)(krb5_context, struct _krb5_key_data *);
82 const EVP_CIPHER *(*evp)(void);
83};
84
85struct _krb5_checksum_type {
86 krb5_cksumtype type;
87 const char *name;
88 size_t blocksize;
89 size_t checksumsize;
90 unsigned flags;
91 krb5_error_code (*checksum)(krb5_context context,
92 struct _krb5_key_data *key,
93 const void *buf, size_t len,
94 unsigned usage,
95 Checksum *csum);
96 krb5_error_code (*verify)(krb5_context context,
97 struct _krb5_key_data *key,
98 const void *buf, size_t len,
99 unsigned usage,
100 Checksum *csum);
101};
102
103struct _krb5_encryption_type {
104 krb5_enctype type;
105 const char *name;
106 size_t blocksize;
107 size_t padsize;
108 size_t confoundersize;
109 struct _krb5_key_type *keytype;
110 struct _krb5_checksum_type *checksum;
111 struct _krb5_checksum_type *keyed_checksum;
112 unsigned flags;
113 krb5_error_code (*encrypt)(krb5_context context,
114 struct _krb5_key_data *key,
115 void *data, size_t len,
116 krb5_boolean encryptp,
117 int usage,
118 void *ivec);
119 size_t prf_length;
120 krb5_error_code (*prf)(krb5_context,
121 krb5_crypto, const krb5_data *, krb5_data *);
122};
123
124#define ENCRYPTION_USAGE(U) (((U) << 8) | 0xAA)
125#define INTEGRITY_USAGE(U) (((U) << 8) | 0x55)
126#define CHECKSUM_USAGE(U) (((U) << 8) | 0x99)
127
128/* Checksums */
129
130extern struct _krb5_checksum_type _krb5_checksum_none;
131extern struct _krb5_checksum_type _krb5_checksum_crc32;
132extern struct _krb5_checksum_type _krb5_checksum_rsa_md4;
133extern struct _krb5_checksum_type _krb5_checksum_rsa_md4_des;
134extern struct _krb5_checksum_type _krb5_checksum_rsa_md5_des;
135extern struct _krb5_checksum_type _krb5_checksum_rsa_md5_des3;
136extern struct _krb5_checksum_type _krb5_checksum_rsa_md5;
137extern struct _krb5_checksum_type _krb5_checksum_hmac_sha1_des3;
138extern struct _krb5_checksum_type _krb5_checksum_hmac_sha1_aes128;
139extern struct _krb5_checksum_type _krb5_checksum_hmac_sha1_aes256;
140extern struct _krb5_checksum_type _krb5_checksum_hmac_md5;
141extern struct _krb5_checksum_type _krb5_checksum_sha1;
142
143extern struct _krb5_checksum_type *_krb5_checksum_types[];
144extern int _krb5_num_checksums;
145
146/* Salts */
147
148extern struct salt_type _krb5_AES_salt[];
149extern struct salt_type _krb5_arcfour_salt[];
150extern struct salt_type _krb5_des_salt[];
151extern struct salt_type _krb5_des3_salt[];
152extern struct salt_type _krb5_des3_salt_derived[];
153
154/* Encryption types */
155
156extern struct _krb5_encryption_type _krb5_enctype_aes256_cts_hmac_sha1;
157extern struct _krb5_encryption_type _krb5_enctype_aes128_cts_hmac_sha1;
158extern struct _krb5_encryption_type _krb5_enctype_des3_cbc_sha1;
159extern struct _krb5_encryption_type _krb5_enctype_des3_cbc_md5;
160extern struct _krb5_encryption_type _krb5_enctype_des3_cbc_none;
161extern struct _krb5_encryption_type _krb5_enctype_arcfour_hmac_md5;
162extern struct _krb5_encryption_type _krb5_enctype_des_cbc_md5;
163extern struct _krb5_encryption_type _krb5_enctype_old_des3_cbc_sha1;
164extern struct _krb5_encryption_type _krb5_enctype_des_cbc_crc;
165extern struct _krb5_encryption_type _krb5_enctype_des_cbc_md4;
166extern struct _krb5_encryption_type _krb5_enctype_des_cbc_md5;
167extern struct _krb5_encryption_type _krb5_enctype_des_cbc_none;
168extern struct _krb5_encryption_type _krb5_enctype_des_cfb64_none;
169extern struct _krb5_encryption_type _krb5_enctype_des_pcbc_none;
170extern struct _krb5_encryption_type _krb5_enctype_null;
171
172extern struct _krb5_encryption_type *_krb5_etypes[];
173extern int _krb5_num_etypes;
174
175/* Interface to the EVP crypto layer provided by hcrypto */
176struct _krb5_evp_schedule {
177 EVP_CIPHER_CTX ectx;
178 EVP_CIPHER_CTX dctx;
179};
Note: See TracBrowser for help on using the repository browser.