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.
7 #ifndef RFC3961_RFC3961_H
8 #define RFC3961_RFC3961_H
10 typedef int krb5_error_code
;
11 typedef int krb5_key_usage
;
12 typedef struct _krb5_context
* krb5_context
;
17 } afs_heim_octet_string
;
19 typedef afs_heim_octet_string krb5_data
;
23 afs_heim_octet_string keyvalue
;
26 typedef struct krb5_crypto_data
*krb5_crypto
;
28 #ifndef RFC3961_NO_ENUMS
29 typedef enum CKSUMTYPE
{
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,
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
51 #ifndef RFC3961_NO_CKSUM
52 typedef struct Checksum
{
54 afs_heim_octet_string checksum
;
57 typedef int krb5_cksumtype
;
60 #ifndef RFC3961_NO_ENUMS
61 typedef enum ENCTYPE
{
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
89 ENCTYPE_NULL
= ETYPE_NULL
92 typedef ENCTYPE krb5_enctype
;
95 typedef int krb5_enctype
;
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_enctype_keysize oafs_h_krb5_enctype_keysize
107 #define krb5_data_free oafs_h_krb5_data_free
108 #define krb5_data_alloc oafs_h_krb5_data_alloc
109 #define krb5_keyblock_init oafs_h_krb5_keyblock_init
110 #define krb5_copy_keyblock oafs_h_krb5_copy_keyblock
111 #define krb5_copy_keyblock_contents oafs_h_krb5_copy_keyblock_contents
112 #define krb5_free_keyblock oafs_h_krb5_free_keyblock
113 #define krb5_free_keyblock_contents oafs_h_krb5_free_keyblock_contents
114 #define krb5_keyblock_zero oafs_h_krb5_keyblock_zero
115 #define krb5_keyblock_get_enctype oafs_h_krb5_keyblock_get_enctype
117 krb5_error_code
krb5_init_context(krb5_context
*context
);
119 void krb5_free_context(krb5_context context
);
121 krb5_error_code
krb5_enctype_valid(krb5_context
, krb5_enctype
);
123 krb5_error_code
krb5_crypto_init(krb5_context context
,
124 const krb5_keyblock
*key
,
126 krb5_crypto
*crypto
);
128 krb5_error_code
krb5_crypto_destroy(krb5_context context
,
131 krb5_error_code
krb5_encrypt(krb5_context context
,
138 krb5_error_code
krb5_decrypt(krb5_context context
,
145 krb5_error_code
krb5_enctype_keybits(krb5_context context
,
148 krb5_error_code
krb5_enctype_keysize(krb5_context context
,
152 void krb5_data_free(krb5_data
*p
);
154 krb5_error_code
krb5_data_alloc(krb5_data
*p
, int len
);
156 void krb5_free_keyblock_contents(krb5_context context
,
157 krb5_keyblock
*keyblock
);
159 #define krb5_crypto_prf oafs_h_krb5_crypto_prf
160 #define krb5_crypto_prf_length oafs_h_krb5_crypto_prf_length
161 #define krb5_crypto_fx_cf2 oafs_h_krb5_crypto_fx_cf2
162 #define krb5_generate_random_block oafs_h_krb5_generate_random_block
163 #define krb5_random_to_key oafs_h_krb5_random_to_key
164 #define krb5_crypto_overhead oafs_h_krb5_crypto_overhead
166 krb5_error_code
krb5_crypto_prf(krb5_context context
,
167 const krb5_crypto crypto
,
168 const krb5_data
*input
,
171 krb5_error_code
krb5_crypto_prf_length(krb5_context context
,
175 krb5_error_code
krb5_crypto_fx_cf2(krb5_context context
,
176 const krb5_crypto crypto1
,
177 const krb5_crypto crypto2
,
180 krb5_enctype enctype
,
183 void krb5_generate_random_block(void *buf
, size_t len
);
185 krb5_error_code
krb5_random_to_key(krb5_context context
,
191 size_t krb5_crypto_overhead (krb5_context context
,
194 #ifndef RFC3961_NO_CKSUM
195 #define krb5_crypto_get_checksum_type oafs_h_krb5_crypto_get_checksum_type
196 #define krb5_checksumsize oafs_h_krb5_checksumsize
197 #define krb5_create_checksum oafs_h_krb5_create_checksum
198 #define krb5_verify_checksum oafs_h_krb5_verify_checksum
199 #define free_Checksum oafs_h_free_Checksum
201 krb5_error_code
krb5_crypto_get_checksum_type (krb5_context context
,
203 krb5_cksumtype
*type
);
204 krb5_error_code
krb5_checksumsize (krb5_context context
,
208 krb5_error_code
krb5_create_checksum (krb5_context context
,
210 krb5_key_usage usage
,
216 krb5_error_code
krb5_verify_checksum (krb5_context context
,
218 krb5_key_usage usage
,
224 void free_Checksum(Checksum
*data
);
227 void krb5_keyblock_zero(krb5_keyblock
*keyblock
);
228 void krb5_free_keyblock_contents(krb5_context context
,
229 krb5_keyblock
*keyblock
);
230 void krb5_free_keyblock(krb5_context context
,
231 krb5_keyblock
*keyblock
);
232 krb5_error_code
krb5_copy_keyblock_contents (krb5_context context
,
233 const krb5_keyblock
*inblock
,
235 krb5_error_code
krb5_copy_keyblock (krb5_context context
,
236 const krb5_keyblock
*inblock
,
238 krb5_enctype
krb5_keyblock_get_enctype(const krb5_keyblock
*block
);
239 krb5_error_code
krb5_keyblock_init(krb5_context context
,
245 #endif /* RFC3961_RFC3961_H */