Fix typo in rfc3961 namespace-cleaning
[openafs.git] / src / crypto / rfc3961 / rfc3961.h
1
2 /* This header defines the public interface to a library which implements
3  * RFC3961 crypto on top of an existing EVP layer. It is created using
4  * selected bits of Heimdal's libkrb5.
5  */
6
7 #ifndef RFC3961_RFC3961_H
8 #define RFC3961_RFC3961_H
9
10 typedef int krb5_error_code;
11 typedef int krb5_key_usage;
12 typedef struct _krb5_context * krb5_context;
13
14 typedef struct {
15     size_t length;
16     void *data;
17 } afs_heim_octet_string;
18
19 typedef afs_heim_octet_string krb5_data;
20
21 typedef struct {
22   int keytype;
23   afs_heim_octet_string keyvalue;
24 } krb5_keyblock;
25
26 typedef struct krb5_crypto_data *krb5_crypto;
27
28 #ifndef RFC3961_NO_ENUMS
29 typedef enum CKSUMTYPE {
30   CKSUMTYPE_NONE = 0,
31   CKSUMTYPE_CRC32 = 1,
32   CKSUMTYPE_RSA_MD4 = 2,
33   CKSUMTYPE_RSA_MD4_DES = 3,
34   CKSUMTYPE_DES_MAC = 4,
35   CKSUMTYPE_DES_MAC_K = 5,
36   CKSUMTYPE_RSA_MD4_DES_K = 6,
37   CKSUMTYPE_RSA_MD5 = 7,
38   CKSUMTYPE_RSA_MD5_DES = 8,
39   CKSUMTYPE_RSA_MD5_DES3 = 9,
40   CKSUMTYPE_SHA1_OTHER = 10,
41   CKSUMTYPE_HMAC_SHA1_DES3 = 12,
42   CKSUMTYPE_SHA1 = 14,
43   CKSUMTYPE_HMAC_SHA1_96_AES_128 = 15,
44   CKSUMTYPE_HMAC_SHA1_96_AES_256 = 16,
45   CKSUMTYPE_GSSAPI = 32771,
46   CKSUMTYPE_HMAC_MD5 = -138,
47   CKSUMTYPE_HMAC_MD5_ENC = -1138
48 } CKSUMTYPE;
49 #endif
50
51 #ifndef RFC3961_NO_CKSUM
52 typedef struct Checksum {
53   CKSUMTYPE cksumtype;
54   afs_heim_octet_string checksum;
55 } Checksum;
56
57 typedef int krb5_cksumtype;
58 #endif
59
60 #ifndef RFC3961_NO_ENUMS
61 typedef enum ENCTYPE {
62   ETYPE_NULL = 0,
63   ETYPE_DES_CBC_CRC = 1,
64   ETYPE_DES_CBC_MD4 = 2,
65   ETYPE_DES_CBC_MD5 = 3,
66   ETYPE_DES3_CBC_MD5 = 5,
67   ETYPE_OLD_DES3_CBC_SHA1 = 7,
68   ETYPE_SIGN_DSA_GENERATE = 8,
69   ETYPE_ENCRYPT_RSA_PRIV = 9,
70   ETYPE_ENCRYPT_RSA_PUB = 10,
71   ETYPE_DES3_CBC_SHA1 = 16,
72   ETYPE_AES128_CTS_HMAC_SHA1_96 = 17,
73   ETYPE_AES256_CTS_HMAC_SHA1_96 = 18,
74   ETYPE_ARCFOUR_HMAC_MD5 = 23,
75   ETYPE_ARCFOUR_HMAC_MD5_56 = 24,
76   ETYPE_ENCTYPE_PK_CROSS = 48,
77   ETYPE_ARCFOUR_MD4 = -128,
78   ETYPE_ARCFOUR_HMAC_OLD = -133,
79   ETYPE_ARCFOUR_HMAC_OLD_EXP = -135,
80   ETYPE_DES_CBC_NONE = -4096,
81   ETYPE_DES3_CBC_NONE = -4097,
82   ETYPE_DES_CFB64_NONE = -4098,
83   ETYPE_DES_PCBC_NONE = -4099,
84   ETYPE_DIGEST_MD5_NONE = -4100,
85   ETYPE_CRAM_MD5_NONE = -4101
86 } ENCTYPE;
87
88 enum {
89   ENCTYPE_NULL          = ETYPE_NULL
90 };
91
92 typedef ENCTYPE krb5_enctype;
93
94 #else
95 typedef int krb5_enctype;
96 #endif
97
98 #define krb5_init_context oafs_h_krb5_init_context
99 #define krb5_free_context oafs_h_krb5_free_context
100 #define krb5_enctype_valid oafs_h_krb5_enctype_valid
101 #define krb5_crypto_init oafs_h_krb5_crypto_init
102 #define krb5_crypto_destroy oafs_h_krb5_crypto_destroy
103 #define krb5_encrypt oafs_h_krb5_encrypt
104 #define krb5_decrypt oafs_h_krb5_decrypt
105 #define krb5_enctype_keybits oafs_h_krb5_enctype_keybits
106 #define krb5_data_free oafs_h_krb5_data_free
107 #define krb5_data_alloc oafs_h_krb5_data_alloc
108 #define krb5_keyblock_init oafs_h_krb5_keyblock_init
109 #define krb5_copy_keyblock oafs_h_krb5_copy_keyblock
110 #define krb5_copy_keyblock_contents oafs_h_krb5_copy_keyblock_contents
111 #define krb5_free_keyblock oafs_h_krb5_free_keyblock
112 #define krb5_free_keyblock_contents oafs_h_krb5_free_keyblock_contents
113 #define krb5_keyblock_zero oafs_h_krb5_keyblock_zero
114 #define krb5_keyblock_get_enctype oafs_h_krb5_keyblock_get_enctype
115
116 krb5_error_code krb5_init_context(krb5_context *context);
117
118 void krb5_free_context(krb5_context context);
119
120 krb5_error_code krb5_enctype_valid(krb5_context, krb5_enctype);
121
122 krb5_error_code krb5_crypto_init(krb5_context context,
123                                  const krb5_keyblock *key,
124                                  krb5_enctype etype,
125                                  krb5_crypto *crypto);
126
127 krb5_error_code krb5_crypto_destroy(krb5_context context,
128                                     krb5_crypto crypto);
129
130 krb5_error_code krb5_encrypt(krb5_context context,
131                              krb5_crypto crypto,
132                              unsigned usage,
133                              const void *data,
134                              size_t len,
135                              krb5_data *result);
136
137 krb5_error_code krb5_decrypt(krb5_context context,
138                              krb5_crypto crypto,
139                              unsigned usage,
140                              void *data,
141                              size_t len,
142                              krb5_data *result);
143
144 krb5_error_code krb5_enctype_keybits(krb5_context context,
145                                      krb5_enctype type,
146                                      size_t *keybits);
147
148 void krb5_data_free(krb5_data *p);
149
150 krb5_error_code krb5_data_alloc(krb5_data *p, int len);
151
152 void krb5_free_keyblock_contents(krb5_context context,
153                                  krb5_keyblock *keyblock);
154
155 #define krb5_crypto_prf oafs_h_krb5_crypto_prf
156 #define krb5_crypto_fx_cf2 oafs_h_krb5_crypto_fx_cf2
157 #define krb5_generate_random_block oafs_h_krb5_generate_random_block
158 #define krb5_random_to_key oafs_h_krb5_random_to_key
159 #define krb5_crypto_overhead oafs_h_krb5_crypto_overhead
160
161 krb5_error_code krb5_crypto_prf(krb5_context context,
162                                 const krb5_crypto crypto,
163                                 const krb5_data *input,
164                                 krb5_data *output);
165
166 krb5_error_code krb5_crypto_fx_cf2(krb5_context context,
167                                    const krb5_crypto crypto1,
168                                    const krb5_crypto crypto2,
169                                    krb5_data *pepper1,
170                                    krb5_data *pepper2,
171                                    krb5_enctype enctype,
172                                    krb5_keyblock *res);
173
174 void krb5_generate_random_block(void *buf, size_t len);
175
176 krb5_error_code krb5_random_to_key(krb5_context context,
177                                    krb5_enctype type,
178                                    const void *data,
179                                    size_t size,
180                                    krb5_keyblock *key);
181
182 size_t krb5_crypto_overhead (krb5_context context,
183                              krb5_crypto crypto);
184
185 #ifndef RFC3961_NO_CKSUM
186 #define krb5_crypto_get_checksum_type oafs_h_krb5_crypto_get_checksum_type
187 #define krb5_checksumsize oafs_h_krb5_checksumsize
188 #define krb5_create_checksum oafs_h_krb5_create_checksum
189 #define krb5_verify_checksum oafs_h_krb5_verify_checksum
190 #define free_Checksum oafs_h_free_Checksum
191
192 krb5_error_code krb5_crypto_get_checksum_type (krb5_context context,
193                                                krb5_crypto crypto,
194                                                krb5_cksumtype *type);
195 krb5_error_code krb5_checksumsize (krb5_context context,
196                                    krb5_cksumtype type,
197                                    size_t *size);
198
199 krb5_error_code krb5_create_checksum (krb5_context context,
200                                       krb5_crypto crypto,
201                                       krb5_key_usage usage,
202                                       int type,
203                                       void *data,
204                                       size_t len,
205                                       Checksum *result);
206
207 krb5_error_code krb5_verify_checksum (krb5_context context,
208                                       krb5_crypto crypto,
209                                       krb5_key_usage usage,
210                                       void *data,
211                                       size_t len,
212                                       Checksum *cksum);
213
214
215 void free_Checksum(Checksum *data);
216 #endif
217
218 void krb5_keyblock_zero(krb5_keyblock *keyblock);
219 void krb5_free_keyblock_contents(krb5_context context,
220                             krb5_keyblock *keyblock);
221 void krb5_free_keyblock(krb5_context context,
222                    krb5_keyblock *keyblock);
223 krb5_error_code krb5_copy_keyblock_contents (krb5_context context,
224                              const krb5_keyblock *inblock,
225                              krb5_keyblock *to);
226 krb5_error_code krb5_copy_keyblock (krb5_context context,
227                     const krb5_keyblock *inblock,
228                     krb5_keyblock **to);
229 krb5_enctype krb5_keyblock_get_enctype(const krb5_keyblock *block);
230 krb5_error_code krb5_keyblock_init(krb5_context context,
231                    krb5_enctype type,
232                    const void *data,
233                    size_t size,
234                    krb5_keyblock *key);
235
236 #endif /* RFC3961_RFC3961_H */