5 * Created by Fabrice Gautier on 1/21/11.
6 * Copyright 2011 Apple, Inc. All rights reserved.
10 #ifndef _CORECRYPTO_CCMODE_FACTORY_H_
11 #define _CORECRYPTO_CCMODE_FACTORY_H_
13 #include <corecrypto/ccn.h> /* TODO: Remove dependancy on this header. */
14 #include <corecrypto/ccmode_impl.h>
16 /* For CBC, direction of underlying ecb is the same as the cbc direction */
17 #define CCMODE_CBC_FACTORY(_cipher_, _dir_) \
18 static struct ccmode_cbc cbc_##_cipher_##_##_dir_; \
20 const struct ccmode_cbc *cc##_cipher_##_cbc_##_dir_##_mode(void) \
22 const struct ccmode_ecb *ecb=cc##_cipher_##_ecb_##_dir_##_mode(); \
23 ccmode_factory_cbc_##_dir_(&cbc_##_cipher_##_##_dir_, ecb); \
24 return &cbc_##_cipher_##_##_dir_; \
27 /* For CTR, only one direction, underlying ecb is always encrypt */
28 #define CCMODE_CTR_FACTORY(_cipher_) \
29 static struct ccmode_ctr ctr_##_cipher_; \
31 const struct ccmode_ctr *cc##_cipher_##_ctr_crypt_mode(void) \
33 const struct ccmode_ecb *ecb=cc##_cipher_##_ecb_encrypt_mode(); \
34 ccmode_factory_ctr_crypt(&ctr_##_cipher_, ecb); \
35 return &ctr_##_cipher_; \
38 /* OFB, same as CTR */
39 #define CCMODE_OFB_FACTORY(_cipher_) \
40 static struct ccmode_ofb ofb_##_cipher_; \
42 const struct ccmode_ofb *cc##_cipher_##_ofb_crypt_mode(void) \
44 const struct ccmode_ecb *ecb=cc##_cipher_##_ecb_encrypt_mode(); \
45 ccmode_factory_ofb_crypt(&ofb_##_cipher_, ecb); \
46 return &ofb_##_cipher_; \
50 /* For CFB, the underlying ecb operation is encrypt for both directions */
51 #define CCMODE_CFB_FACTORY(_cipher_, _mode_, _dir_) \
52 static struct ccmode_##_mode_ _mode_##_##_cipher_##_##_dir_; \
54 const struct ccmode_##_mode_ *cc##_cipher_##_##_mode_##_##_dir_##_mode(void) \
56 const struct ccmode_ecb *ecb=cc##_cipher_##_ecb_encrypt_mode(); \
57 ccmode_factory_##_mode_##_##_dir_(&_mode_##_##_cipher_##_##_dir_, ecb); \
58 return &_mode_##_##_cipher_##_##_dir_; \
61 /* For GCM, same as CFB */
62 #define CCMODE_GCM_FACTORY(_cipher_, _dir_) CCMODE_CFB_FACTORY(_cipher_, gcm, _dir_)
65 /* Fot XTS, you always need an ecb encrypt */
66 #define CCMODE_XTS_FACTORY(_cipher_ , _dir_) \
67 static struct ccmode_xts xts##_cipher_##_##_dir_; \
69 const struct ccmode_xts *cc##_cipher_##_xts_##_dir_##_mode(void) \
71 const struct ccmode_ecb *ecb=cc##_cipher_##_ecb_##_dir_##_mode(); \
72 const struct ccmode_ecb *ecb_enc=cc##_cipher_##_ecb_encrypt_mode(); \
74 ccmode_factory_xts_##_dir_(&xts##_cipher_##_##_dir_, ecb, ecb_enc); \
75 return &xts##_cipher_##_##_dir_; \
80 /* example of how to make the selection function thread safe */
82 struct ccmode_cbc cc3des_cbc_mode_encrypt
;
83 dispatch_once_t cc3des_mode_encrypt_init_once
;
85 void cc3des_mode_encrypt_init(void *ctx
) {
86 struct ccmode_ecb
*ecb
= cc3des_ecb_encrypt_mode();
87 ccmode_factory_cbc_encrypt(&cc3des_mode_encrypt
, ecb
);
90 const struct ccmode_cbc
*cc3des_cbc_encrypt_mode(void) {
91 dispatch_once_f(&cc3des_mode_encrypt_init_once
, NULL
, cc3des_mode_encrypt_init
);
92 return &cc3des_mode_encrypt
;
95 struct ccmode_cbc cc3des_cbc_mode_encrypt
= {
96 .n
= CC3DES_LTC_ECB_ENCRYPT_N
,
97 .init
= ccmode_cbc_init
,
98 .cbc
= ccmode_cbc_encrypt
,
99 .custom
= &cc3des_ltc_ecb_encrypt
102 const struct ccmode_cbc
*cc3des_cbc_encrypt_mode(void) {
103 return &cc3des_mode_encrypt
;
110 void *ccmode_cbc_init(const struct ccmode_cbc
*cbc
, cccbc_ctx
*ctx
,
111 unsigned long rawkey_len
, const void *rawkey
,
113 void *ccmode_cbc_decrypt(cccbc_ctx
*ctx
, unsigned long nblocks
,
114 const void *in
, void *out
);
115 void *ccmode_cbc_encrypt(cccbc_ctx
*ctx
, unsigned long nblocks
,
116 const void *in
, void *out
);
118 struct _ccmode_cbc_key
{
119 const struct ccmode_ecb
*ecb
;
123 /* Use this to statically initialize a ccmode_cbc object for decryption. */
124 #define CCMODE_FACTORY_CBC_DECRYPT(ECB) { \
125 .size = ccn_sizeof_size(sizeof(struct _ccmode_cbc_key)) + ccn_sizeof_size((ECB)->block_size) + ccn_sizeof_size((ECB)->size), \
126 .block_size = (ECB)->block_size, \
127 .init = ccmode_cbc_init, \
128 .cbc = ccmode_cbc_decrypt, \
132 /* Use this to statically initialize a ccmode_cbc object for encryption. */
133 #define CCMODE_FACTORY_CBC_ENCRYPT(ECB) { \
134 .size = ccn_sizeof_size(sizeof(struct _ccmode_cbc_key)) + ccn_sizeof_size((ECB)->block_size) + ccn_sizeof_size((ECB)->size), \
135 .block_size = (ECB)->block_size, \
136 .init = ccmode_cbc_init, \
137 .cbc = ccmode_cbc_encrypt, \
141 /* Use these function to runtime initialize a ccmode_cbc decrypt object (for
142 example if it's part of a larger structure). Normally you would pass a
143 ecb decrypt mode implementation of some underlying algorithm as the ecb
146 void ccmode_factory_cbc_decrypt(struct ccmode_cbc
*cbc
,
147 const struct ccmode_ecb
*ecb
) {
148 struct ccmode_cbc cbc_decrypt
= CCMODE_FACTORY_CBC_DECRYPT(ecb
);
152 /* Use these function to runtime initialize a ccmode_cbc encrypt object (for
153 example if it's part of a larger structure). Normally you would pass a
154 ecb encrypt mode implementation of some underlying algorithm as the ecb
157 void ccmode_factory_cbc_encrypt(struct ccmode_cbc
*cbc
,
158 const struct ccmode_ecb
*ecb
) {
159 struct ccmode_cbc cbc_encrypt
= CCMODE_FACTORY_CBC_ENCRYPT(ecb
);
164 void ccmode_cfb_init(const struct ccmode_cfb
*cfb
, cccfb_ctx
*ctx
,
165 unsigned long rawkey_len
, const void *rawkey
,
167 void ccmode_cfb_decrypt(cccfb_ctx
*ctx
, unsigned long nblocks
,
168 const void *in
, void *out
);
169 void ccmode_cfb_encrypt(cccfb_ctx
*ctx
, unsigned long nblocks
,
170 const void *in
, void *out
);
172 struct _ccmode_cfb_key
{
173 const struct ccmode_ecb
*ecb
;
178 /* Use this to statically initialize a ccmode_cfb object for decryption. */
179 #define CCMODE_FACTORY_CFB_DECRYPT(ECB) { \
180 .size = ccn_sizeof_size(sizeof(struct _ccmode_cfb_key)) + 2 * ccn_sizeof_size((ECB)->block_size) + ccn_sizeof_size((ECB)->size), \
182 .init = ccmode_cfb_init, \
183 .cfb = ccmode_cfb_decrypt, \
187 /* Use this to statically initialize a ccmode_cfb object for encryption. */
188 #define CCMODE_FACTORY_CFB_ENCRYPT(ECB) { \
189 .size = ccn_sizeof_size(sizeof(struct _ccmode_cfb_key)) + 2 * ccn_sizeof_size((ECB)->block_size) + ccn_sizeof_size((ECB)->size), \
191 .init = ccmode_cfb_init, \
192 .cfb = ccmode_cfb_encrypt, \
196 /* Use these function to runtime initialize a ccmode_cfb decrypt object (for
197 example if it's part of a larger structure). Normally you would pass a
198 ecb encrypt mode implementation of some underlying algorithm as the ecb
201 void ccmode_factory_cfb_decrypt(struct ccmode_cfb
*cfb
,
202 const struct ccmode_ecb
*ecb
) {
203 struct ccmode_cfb cfb_decrypt
= CCMODE_FACTORY_CFB_DECRYPT(ecb
);
207 /* Use these function to runtime initialize a ccmode_cfb encrypt object (for
208 example if it's part of a larger structure). Normally you would pass a
209 ecb encrypt mode implementation of some underlying algorithm as the ecb
212 void ccmode_factory_cfb_encrypt(struct ccmode_cfb
*cfb
,
213 const struct ccmode_ecb
*ecb
) {
214 struct ccmode_cfb cfb_encrypt
= CCMODE_FACTORY_CFB_ENCRYPT(ecb
);
219 void ccmode_cfb8_init(const struct ccmode_cfb8
*cfb8
, cccfb8_ctx
*ctx
,
220 unsigned long rawkey_len
, const void *rawkey
,
222 void ccmode_cfb8_decrypt(cccfb8_ctx
*ctx
, unsigned long nbytes
,
223 const void *in
, void *out
);
224 void ccmode_cfb8_encrypt(cccfb8_ctx
*ctx
, unsigned long nbytes
,
225 const void *in
, void *out
);
227 struct _ccmode_cfb8_key
{
228 const struct ccmode_ecb
*ecb
;
232 /* Use this to statically initialize a ccmode_cfb8 object for decryption. */
233 #define CCMODE_FACTORY_CFB8_DECRYPT(ECB) { \
234 .size = ccn_sizeof_size(sizeof(struct _ccmode_cfb8_key)) + 2 * ccn_sizeof_size((ECB)->block_size) + ccn_sizeof_size((ECB)->size), \
236 .init = ccmode_cfb8_init, \
237 .cfb8 = ccmode_cfb8_decrypt, \
241 /* Use this to statically initialize a ccmode_cfb8 object for encryption. */
242 #define CCMODE_FACTORY_CFB8_ENCRYPT(ECB) { \
243 .size = ccn_sizeof_size(sizeof(struct _ccmode_cfb8_key)) + 2 * ccn_sizeof_size((ECB)->block_size) + ccn_sizeof_size((ECB)->size), \
245 .init = ccmode_cfb8_init, \
246 .cfb8 = ccmode_cfb8_encrypt, \
250 /* Use these function to runtime initialize a ccmode_cfb8 decrypt object (for
251 example if it's part of a larger structure). Normally you would pass a
252 ecb decrypt mode implementation of some underlying algorithm as the ecb
255 void ccmode_factory_cfb8_decrypt(struct ccmode_cfb8
*cfb8
,
256 const struct ccmode_ecb
*ecb
) {
257 struct ccmode_cfb8 cfb8_decrypt
= CCMODE_FACTORY_CFB8_DECRYPT(ecb
);
258 *cfb8
= cfb8_decrypt
;
261 /* Use these function to runtime initialize a ccmode_cfb8 encrypt object (for
262 example if it's part of a larger structure). Normally you would pass a
263 ecb encrypt mode implementation of some underlying algorithm as the ecb
266 void ccmode_factory_cfb8_encrypt(struct ccmode_cfb8
*cfb8
,
267 const struct ccmode_ecb
*ecb
) {
268 struct ccmode_cfb8 cfb8_encrypt
= CCMODE_FACTORY_CFB8_ENCRYPT(ecb
);
269 *cfb8
= cfb8_encrypt
;
272 void ccmode_ctr_init(const struct ccmode_ctr
*ctr
, ccctr_ctx
*ctx
,
273 unsigned long rawkey_len
, const void *rawkey
,
275 void ccmode_ctr_crypt(ccctr_ctx
*ctx
, unsigned long nblocks
,
276 const void *in
, void *out
);
278 struct _ccmode_ctr_key
{
279 const struct ccmode_ecb
*ecb
;
284 /* Use this to statically initialize a ccmode_ctr object for decryption. */
285 #define CCMODE_FACTORY_CTR_CRYPT(ECB_ENCRYPT) { \
286 .size = ccn_sizeof_size(sizeof(struct _ccmode_ctr_key)) + 2 * ccn_sizeof_size((ECB_ENCRYPT)->block_size) + ccn_sizeof_size((ECB_ENCRYPT)->size), \
288 .init = ccmode_ctr_init, \
289 .ctr = ccmode_ctr_crypt, \
290 .custom = (ECB_ENCRYPT) \
293 /* Use these function to runtime initialize a ccmode_ctr decrypt object (for
294 example if it's part of a larger structure). Normally you would pass a
295 ecb encrypt mode implementation of some underlying algorithm as the ecb
298 void ccmode_factory_ctr_crypt(struct ccmode_ctr
*ctr
,
299 const struct ccmode_ecb
*ecb
) {
300 struct ccmode_ctr ctr_crypt
= CCMODE_FACTORY_CTR_CRYPT(ecb
);
305 //#define CCMODE_GCM_TABLES 1
306 #define CCMODE_GCM_FAST 1
308 #ifdef CCMODE_GCM_FAST
309 #define CCMODE_GCM_FAST_TYPE cc_unit
312 #ifdef CCMODE_GCM_TABLES
314 //#define CCMODE_GCM_TABLES_SSE2 1
316 extern const unsigned char gcm_shift_table
[256*2];
319 /* Create a gcm key from a gcm mode object.
320 key must point to at least sizeof(CCMODE_GCM_KEY(ecb)) bytes of free
322 void ccmode_gcm_init(const struct ccmode_gcm
*gcm
, ccgcm_ctx
*ctx
,
323 unsigned long rawkey_len
, const void *rawkey
);
324 void ccmode_gcm_set_iv(ccgcm_ctx
*ctx
, size_t iv_size
, const void *iv
);
325 void ccmode_gcm_gmac(ccgcm_ctx
*ctx
, unsigned long nbytes
, const void *in
);
326 void ccmode_gcm_decrypt(ccgcm_ctx
*ctx
, unsigned long nbytes
, const void *in
,
328 void ccmode_gcm_encrypt(ccgcm_ctx
*ctx
, unsigned long nbytes
, const void *in
,
330 void ccmode_gcm_finalize(ccgcm_ctx
*key
, size_t tag_size
, void *tag
);
331 void ccmode_gcm_reset(ccgcm_ctx
*key
);
333 struct _ccmode_gcm_key
{
334 // 5 blocks of temp space.
335 unsigned char H
[16]; /* multiplier */
336 unsigned char X
[16]; /* accumulator */
337 unsigned char Y
[16]; /* counter */
338 unsigned char Y_0
[16]; /* initial counter */
339 unsigned char buf
[16]; /* buffer for stuff */
341 const struct ccmode_ecb
*ecb
;
342 uint32_t ivmode
; /* Which mode is the IV in? */
343 uint32_t mode
; /* mode the GCM code is in */
344 uint32_t buflen
; /* length of data in buf */
346 uint64_t totlen
; /* 64-bit counter used for IV and AAD */
347 uint64_t pttotlen
; /* 64-bit counter for the PT */
349 #ifdef CCMODE_GCM_TABLES
350 /* TODO: Make table based gcm a separate mode object. */
351 unsigned char PC
[16][256][16] /* 16 tables of 8x128 */
352 #ifdef CCMODE_GCM_TABLES_SSE2
353 __attribute__ ((aligned (16)))
354 #endif /* CCMODE_GCM_TABLES_SSE2 */
356 #endif /* CCMODE_GCM_TABLES */
361 /* Use this to statically initialize a ccmode_gcm object for decryption. */
362 #define CCMODE_FACTORY_GCM_DECRYPT(ECB_ENCRYPT) { \
363 .size = ccn_sizeof_size(sizeof(struct _ccmode_gcm_key)) + 5 * ccn_sizeof_size((ECB_ENCRYPT)->block_size) + ccn_sizeof_size((ECB_ENCRYPT)->size), \
365 .init = ccmode_gcm_init, \
366 .set_iv = ccmode_gcm_set_iv, \
367 .gmac = ccmode_gcm_gmac, \
368 .gcm = ccmode_gcm_decrypt, \
369 .finalize = ccmode_gcm_finalize, \
370 .reset = ccmode_gcm_reset, \
371 .custom = (ECB_ENCRYPT) \
374 /* Use this to statically initialize a ccmode_gcm object for encryption. */
375 #define CCMODE_FACTORY_GCM_ENCRYPT(ECB_ENCRYPT) { \
376 .size = ccn_sizeof_size(sizeof(struct _ccmode_gcm_key)) + 5 * ccn_sizeof_size((ECB_ENCRYPT)->block_size) + ccn_sizeof_size((ECB_ENCRYPT)->size), \
378 .init = ccmode_gcm_init, \
379 .set_iv = ccmode_gcm_set_iv, \
380 .gmac = ccmode_gcm_gmac, \
381 .gcm = ccmode_gcm_encrypt, \
382 .finalize = ccmode_gcm_finalize, \
383 .reset = ccmode_gcm_reset, \
384 .custom = (ECB_ENCRYPT) \
387 /* Use these function to runtime initialize a ccmode_gcm decrypt object (for
388 example if it's part of a larger structure). For GCM you always pass a
389 ecb encrypt mode implementation of some underlying algorithm as the ecb
392 void ccmode_factory_gcm_decrypt(struct ccmode_gcm
*gcm
,
393 const struct ccmode_ecb
*ecb_encrypt
) {
394 struct ccmode_gcm gcm_decrypt
= CCMODE_FACTORY_GCM_DECRYPT(ecb_encrypt
);
398 /* Use these function to runtime initialize a ccmode_gcm encrypt object (for
399 example if it's part of a larger structure). For GCM you always pass a
400 ecb encrypt mode implementation of some underlying algorithm as the ecb
403 void ccmode_factory_gcm_encrypt(struct ccmode_gcm
*gcm
,
404 const struct ccmode_ecb
*ecb_encrypt
) {
405 struct ccmode_gcm gcm_encrypt
= CCMODE_FACTORY_GCM_ENCRYPT(ecb_encrypt
);
410 void ccmode_ofb_init(const struct ccmode_ofb
*ofb
, ccofb_ctx
*ctx
,
411 unsigned long rawkey_len
, const void *rawkey
,
413 void ccmode_ofb_crypt(ccofb_ctx
*ctx
, unsigned long nblocks
,
414 const void *in
, void *out
);
416 struct _ccmode_ofb_key
{
417 const struct ccmode_ecb
*ecb
;
422 /* Use this to statically initialize a ccmode_ofb object. */
423 #define CCMODE_FACTORY_OFB_CRYPT(ECB) { \
424 .size = ccn_sizeof_size(sizeof(struct _ccmode_ofb_key)) + ccn_sizeof_size((ECB)->block_size) + ccn_sizeof_size((ECB)->size), \
426 .init = ccmode_ofb_init, \
427 .ofb = ccmode_ofb_crypt, \
431 /* Use these function to runtime initialize a ccmode_ofb encrypt object (for
432 example if it's part of a larger structure). Normally you would pass a
433 ecb encrypt mode implementation of some underlying algorithm as the ecb
436 void ccmode_factory_ofb_crypt(struct ccmode_ofb
*ofb
,
437 const struct ccmode_ecb
*ecb
) {
438 struct ccmode_ofb ofb_crypt
= CCMODE_FACTORY_OFB_CRYPT(ecb
);
443 int ccmode_omac_decrypt(ccomac_ctx
*ctx
, unsigned long nblocks
,
444 const void *tweak
, const void *in
, void *out
);
445 int ccmode_omac_encrypt(ccomac_ctx
*ctx
, unsigned long nblocks
,
446 const void *tweak
, const void *in
, void *out
);
448 /* Create a omac key from a omac mode object. The tweak_len here
449 determines how long the tweak is in bytes, for each subsequent call to
451 key must point to at least sizeof(CCMODE_OMAC_KEY(ecb)) bytes of free
453 void ccmode_omac_init(const struct ccmode_omac
*omac
, ccomac_ctx
*ctx
,
454 cc_size tweak_len
, unsigned long rawkey_len
,
457 struct _ccmode_omac_key
{
458 const struct ccmode_ecb
*ecb
;
463 /* Use this to statically initialize a ccmode_omac object for decryption. */
464 #define CCMODE_FACTORY_OMAC_DECRYPT(ECB) { \
465 .size = ccn_sizeof_size(sizeof(struct _ccmode_omac_key)) + 2 * ccn_sizeof_size((ECB)->size), \
466 .block_size = (ECB)->block_size, \
467 .init = ccmode_omac_init, \
468 .omac = ccmode_omac_decrypt, \
472 /* Use this to statically initialize a ccmode_omac object for encryption. */
473 #define CCMODE_FACTORY_OMAC_ENCRYPT(ECB) { \
474 .size = ccn_sizeof_size(sizeof(struct _ccmode_omac_key)) + 2 * ccn_sizeof_size((ECB)->size), \
475 .block_size = (ECB)->block_size, \
476 .init = ccmode_omac_init, \
477 .omac = ccmode_omac_encrypt, \
481 /* Use these function to runtime initialize a ccmode_omac decrypt object (for
482 example if it's part of a larger structure). Normally you would pass a
483 ecb decrypt mode implementation of some underlying algorithm as the ecb
486 void ccmode_factory_omac_decrypt(struct ccmode_omac
*omac
,
487 const struct ccmode_ecb
*ecb
) {
488 struct ccmode_omac omac_decrypt
= CCMODE_FACTORY_OMAC_DECRYPT(ecb
);
489 *omac
= omac_decrypt
;
492 /* Use these function to runtime initialize a ccmode_omac encrypt object (for
493 example if it's part of a larger structure). Normally you would pass a
494 ecb encrypt mode implementation of some underlying algorithm as the ecb
497 void ccmode_factory_omac_encrypt(struct ccmode_omac
*omac
,
498 const struct ccmode_ecb
*ecb
) {
499 struct ccmode_omac omac_encrypt
= CCMODE_FACTORY_OMAC_ENCRYPT(ecb
);
500 *omac
= omac_encrypt
;
504 /* Function prototypes used by the macros below, do not call directly. */
505 void ccmode_xts_init(const struct ccmode_xts
*xts
, ccxts_ctx
*ctx
,
506 unsigned long key_len
, const void *data_key
,
507 const void *tweak_key
);
508 void *ccmode_xts_crypt(ccxts_ctx
*ctx
, unsigned long nblocks
,
509 const void *in
, void *out
);
510 void ccmode_xts_set_tweak(ccxts_ctx
*ctx
, const void *tweak
);
513 struct _ccmode_xts_key
{
514 const struct ccmode_ecb
*ecb
;
515 const struct ccmode_ecb
*ecb_encrypt
;
516 // FIPS requires that for XTS that no more that 2^20 AES blocks may be processed for any given
517 // Key, Tweak Key, and tweak combination
518 // the bytes_processed field in the context will accumuate the number of blocks processed and
519 // will fail the encrypt/decrypt if the size is violated. This counter will be reset to 0
520 // when set_tweak is called.
521 unsigned long blocks_processed
;
525 /* Use this to statically initialize a ccmode_xts object for decryption. */
526 #define CCMODE_FACTORY_XTS_DECRYPT(ECB, ECB_ENCRYPT) { \
527 .size = ccn_sizeof_size(sizeof(struct _ccmode_xts_key)) + 2 * ccn_sizeof_size((ECB)->size) + ccn_sizeof_size(16), \
529 .init = ccmode_xts_init, \
530 .set_tweak = ccmode_xts_set_tweak, \
531 .xts = ccmode_xts_crypt, \
533 .custom1 = (ECB_ENCRYPT) \
536 /* Use this to statically initialize a ccmode_xts object for encryption. */
537 #define CCMODE_FACTORY_XTS_ENCRYPT(ECB, ECB_ENCRYPT) { \
538 .size = ccn_sizeof_size(sizeof(struct _ccmode_xts_key)) + 2 * ccn_sizeof_size((ECB)->size) + ccn_sizeof_size(16), \
540 .init = ccmode_xts_init, \
541 .set_tweak = ccmode_xts_set_tweak, \
542 .xts = ccmode_xts_crypt, \
544 .custom1 = (ECB_ENCRYPT) \
547 /* Use these function to runtime initialize a ccmode_xts decrypt object (for
548 example if it's part of a larger structure). Normally you would pass a
549 ecb decrypt mode implementation of some underlying algorithm as the ecb
552 void ccmode_factory_xts_decrypt(struct ccmode_xts
*xts
,
553 const struct ccmode_ecb
*ecb
,
554 const struct ccmode_ecb
*ecb_encrypt
) {
555 struct ccmode_xts xts_decrypt
= CCMODE_FACTORY_XTS_DECRYPT(ecb
, ecb_encrypt
);
559 /* Use these function to runtime initialize a ccmode_xts encrypt object (for
560 example if it's part of a larger structure). Normally you would pass a
561 ecb encrypt mode implementation of some underlying algorithm as the ecb
564 void ccmode_factory_xts_encrypt(struct ccmode_xts
*xts
,
565 const struct ccmode_ecb
*ecb
,
566 const struct ccmode_ecb
*ecb_encrypt
) {
567 struct ccmode_xts xts_encrypt
= CCMODE_FACTORY_XTS_ENCRYPT(ecb
, ecb_encrypt
);
571 #endif /* _CORECRYPTO_CCMODE_FACTORY_H_ */