2 * Copyright (c) 2012 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _CRYPTO_REGISTER_CRYPTO_H_
30 #define _CRYPTO_REGISTER_CRYPTO_H_
36 #include <corecrypto/ccdigest.h>
37 #include <corecrypto/cchmac.h>
38 #include <corecrypto/ccmode.h>
39 #include <corecrypto/ccrc4.h>
44 typedef void (*ccdigest_init_fn_t
)(const struct ccdigest_info
*di
, ccdigest_ctx_t ctx
);
45 typedef void (*ccdigest_update_fn_t
)(const struct ccdigest_info
*di
, ccdigest_ctx_t ctx
,
46 unsigned long len
, const void *data
);
47 typedef void (*ccdigest_final_fn_t
)(const struct ccdigest_info
*di
, ccdigest_ctx_t ctx
,
49 typedef void (*ccdigest_fn_t
)(const struct ccdigest_info
*di
, unsigned long len
,
50 const void *data
, void *digest
);
53 typedef void (*cchmac_init_fn_t
)(const struct ccdigest_info
*di
, cchmac_ctx_t ctx
,
54 unsigned long key_len
, const void *key
);
55 typedef void (*cchmac_update_fn_t
)(const struct ccdigest_info
*di
, cchmac_ctx_t ctx
,
56 unsigned long data_len
, const void *data
);
57 typedef void (*cchmac_final_fn_t
)(const struct ccdigest_info
*di
, cchmac_ctx_t ctx
,
60 typedef void (*cchmac_fn_t
)(const struct ccdigest_info
*di
, unsigned long key_len
,
61 const void *key
, unsigned long data_len
, const void *data
,
65 typedef void (*ccpbkdf2_hmac_fn_t
)(const struct ccdigest_info
*di
,
66 unsigned long passwordLen
, const void *password
,
67 unsigned long saltLen
, const void *salt
,
68 unsigned long iterations
,
69 unsigned long dkLen
, void *dk
);
71 /* des weak key testing */
72 typedef int (*ccdes_key_is_weak_fn_t
)(void *key
, unsigned long length
);
73 typedef void (*ccdes_key_set_odd_parity_fn_t
)(void *key
, unsigned long length
);
76 typedef void (*ccpad_xts_decrypt_fn_t
)(const struct ccmode_xts
*xts
, ccxts_ctx
*ctx
,
77 unsigned long nbytes
, const void *in
, void *out
);
79 typedef void (*ccpad_xts_encrypt_fn_t
)(const struct ccmode_xts
*xts
, ccxts_ctx
*ctx
,
80 unsigned long nbytes
, const void *in
, void *out
);
83 typedef struct crypto_functions
{
84 /* digests common functions */
85 ccdigest_init_fn_t ccdigest_init_fn
;
86 ccdigest_update_fn_t ccdigest_update_fn
;
87 ccdigest_final_fn_t ccdigest_final_fn
;
88 ccdigest_fn_t ccdigest_fn
;
89 /* digest implementations */
90 const struct ccdigest_info
* ccmd5_di
;
91 const struct ccdigest_info
* ccsha1_di
;
92 const struct ccdigest_info
* ccsha256_di
;
93 const struct ccdigest_info
* ccsha384_di
;
94 const struct ccdigest_info
* ccsha512_di
;
96 /* hmac common function */
97 cchmac_init_fn_t cchmac_init_fn
;
98 cchmac_update_fn_t cchmac_update_fn
;
99 cchmac_final_fn_t cchmac_final_fn
;
100 cchmac_fn_t cchmac_fn
;
102 /* ciphers modes implementations */
103 /* AES, ecb, cbc and xts */
104 const struct ccmode_ecb
*ccaes_ecb_encrypt
;
105 const struct ccmode_ecb
*ccaes_ecb_decrypt
;
106 const struct ccmode_cbc
*ccaes_cbc_encrypt
;
107 const struct ccmode_cbc
*ccaes_cbc_decrypt
;
108 const struct ccmode_xts
*ccaes_xts_encrypt
;
109 const struct ccmode_xts
*ccaes_xts_decrypt
;
110 /* DES, ecb and cbc */
111 const struct ccmode_ecb
*ccdes_ecb_encrypt
;
112 const struct ccmode_ecb
*ccdes_ecb_decrypt
;
113 const struct ccmode_cbc
*ccdes_cbc_encrypt
;
114 const struct ccmode_cbc
*ccdes_cbc_decrypt
;
115 /* Triple DES, ecb and cbc */
116 const struct ccmode_ecb
*cctdes_ecb_encrypt
;
117 const struct ccmode_ecb
*cctdes_ecb_decrypt
;
118 const struct ccmode_cbc
*cctdes_cbc_encrypt
;
119 const struct ccmode_cbc
*cctdes_cbc_decrypt
;
121 const struct ccrc4_info
*ccrc4_info
;
122 /* Blowfish - ECB only */
123 const struct ccmode_ecb
*ccblowfish_ecb_encrypt
;
124 const struct ccmode_ecb
*ccblowfish_ecb_decrypt
;
125 /* CAST - ECB only */
126 const struct ccmode_ecb
*cccast_ecb_encrypt
;
127 const struct ccmode_ecb
*cccast_ecb_decrypt
;
128 /* DES key helper functions */
129 ccdes_key_is_weak_fn_t ccdes_key_is_weak_fn
;
130 ccdes_key_set_odd_parity_fn_t ccdes_key_set_odd_parity_fn
;
131 /* XTS padding functions */
132 ccpad_xts_encrypt_fn_t ccpad_xts_encrypt_fn
;
133 ccpad_xts_decrypt_fn_t ccpad_xts_decrypt_fn
;
134 } *crypto_functions_t
;
136 int register_crypto_functions(const crypto_functions_t funcs
);
142 #endif /*_CRYPTO_REGISTER_CRYPTO_H_*/