]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/corecrypto/ccmode_impl.h
5 * Created by James Murphy on 12/9/11.
6 * Copyright (c) 2011 Apple Inc. All rights reserved.
10 #ifndef _CORECRYPTO_CCMODE_IMPL_H_
11 #define _CORECRYPTO_CCMODE_IMPL_H_
13 #include <corecrypto/cc.h>
16 cc_aligned_struct(16) ccecb_ctx
;
19 /* Actual symmetric algorithm implementation should provide you one of these. */
21 size_t size
; /* first argument to ccecb_ctx_decl(). */
22 unsigned long block_size
;
23 void (*init
)(const struct ccmode_ecb
*ecb
, ccecb_ctx
*ctx
,
24 unsigned long key_len
, const void *key
);
25 void (*ecb
)(const ccecb_ctx
*ctx
, unsigned long nblocks
, const void *in
,
30 cc_aligned_struct(16) cccbc_ctx
;
31 cc_aligned_struct(16) cccbc_iv
;
34 size_t size
; /* first argument to cccbc_ctx_decl(). */
35 unsigned long block_size
;
36 void (*init
)(const struct ccmode_cbc
*cbc
, cccbc_ctx
*ctx
,
37 unsigned long key_len
, const void *key
);
38 /* cbc encrypt or decrypt nblocks from in to out, iv will be used and updated. */
39 void (*cbc
)(const cccbc_ctx
*ctx
, cccbc_iv
*iv
, unsigned long nblocks
,
40 const void *in
, void *out
);
45 cc_aligned_struct(16) cccfb_ctx
;
48 size_t size
; /* first argument to cccfb_ctx_decl(). */
49 unsigned long block_size
;
50 void (*init
)(const struct ccmode_cfb
*cfb
, cccfb_ctx
*ctx
,
51 unsigned long key_len
, const void *key
,
53 void (*cfb
)(cccfb_ctx
*ctx
, unsigned long nblocks
,
54 const void *in
, void *out
);
60 cc_aligned_struct(16) cccfb8_ctx
;
63 size_t size
; /* first argument to cccfb8_ctx_decl(). */
64 unsigned long block_size
;
65 void (*init
)(const struct ccmode_cfb8
*cfb8
, cccfb8_ctx
*ctx
,
66 unsigned long key_len
, const void *key
,
68 void (*cfb8
)(cccfb8_ctx
*ctx
, unsigned long nbytes
,
69 const void *in
, void *out
);
75 cc_aligned_struct(16) ccctr_ctx
;
78 size_t size
; /* first argument to ccctr_ctx_decl(). */
79 unsigned long block_size
;
80 void (*init
)(const struct ccmode_ctr
*ctr
, ccctr_ctx
*ctx
,
81 unsigned long key_len
, const void *key
,
83 void (*ctr
)(ccctr_ctx
*ctx
, unsigned long nblocks
,
84 const void *in
, void *out
);
90 cc_aligned_struct(16) ccofb_ctx
;
93 size_t size
; /* first argument to ccofb_ctx_decl(). */
94 unsigned long block_size
;
95 void (*init
)(const struct ccmode_ofb
*ofb
, ccofb_ctx
*ctx
,
96 unsigned long key_len
, const void *key
,
98 void (*ofb
)(ccofb_ctx
*ctx
, unsigned long nblocks
,
99 const void *in
, void *out
);
105 cc_aligned_struct(16) ccxts_ctx
;
106 cc_aligned_struct(16) ccxts_tweak
;
109 size_t size
; /* first argument to ccxts_ctx_decl(). */
110 size_t tweak_size
; /* first argument to ccxts_tweak_decl(). */
111 unsigned long block_size
;
113 /* Create a xts key from a xts mode object. The tweak_len here
114 determines how long the tweak is in bytes, for each subsequent call to
116 key must point to at least 'size' cc_units of free storage.
117 tweak_key must point to at least 'tweak_size' cc_units of free storage. */
118 void (*init
)(const struct ccmode_xts
*xts
, ccxts_ctx
*ctx
,
119 unsigned long key_len
, const void *key
,
120 const void *tweak_key
);
122 /* Set the tweak (sector number), the block within the sector zero. */
123 void (*set_tweak
)(const ccxts_ctx
*ctx
, ccxts_tweak
*tweak
, const void *iv
);
125 /* Encrypt blocks for a sector, clients must call set_tweak before calling
126 this function. Return a pointer to the tweak buffer */
127 void *(*xts
)(const ccxts_ctx
*ctx
, ccxts_tweak
*tweak
, unsigned long nblocks
,
128 const void *in
, void *out
);
136 cc_aligned_struct(16) ccgcm_ctx
;
139 size_t size
; /* first argument to ccgcm_ctx_decl(). */
140 unsigned long block_size
;
141 void (*init
)(const struct ccmode_gcm
*gcm
, ccgcm_ctx
*ctx
,
142 unsigned long key_len
, const void *key
);
143 void (*set_iv
)(ccgcm_ctx
*ctx
, size_t iv_size
, const void *iv
);
144 void (*gmac
)(ccgcm_ctx
*ctx
, unsigned long nbytes
, const void *in
); // could just be gcm with NULL out
145 void (*gcm
)(ccgcm_ctx
*ctx
, unsigned long nbytes
, const void *in
, void *out
);
146 void (*finalize
)(ccgcm_ctx
*key
, size_t tag_size
, void *tag
);
147 void (*reset
)(ccgcm_ctx
*ctx
);
153 cc_aligned_struct(16) ccomac_ctx
;
156 size_t size
; /* first argument to ccomac_ctx_decl(). */
157 unsigned long block_size
;
158 void (*init
)(const struct ccmode_omac
*omac
, ccomac_ctx
*ctx
,
159 unsigned long tweak_len
, unsigned long key_len
,
161 int (*omac
)(ccomac_ctx
*ctx
, unsigned long nblocks
,
162 const void *tweak
, const void *in
, void *out
);
166 #endif /* _CORECRYPTO_CCMODE_IMPL_H_ */