1b077aed3SPierre Pronchery /*
2*e0c4386eSCy Schubert * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
3b077aed3SPierre Pronchery *
4b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use
5b077aed3SPierre Pronchery * this file except in compliance with the License. You can obtain a copy
6b077aed3SPierre Pronchery * in the file LICENSE in the source distribution or at
7b077aed3SPierre Pronchery * https://www.openssl.org/source/license.html
8b077aed3SPierre Pronchery */
9b077aed3SPierre Pronchery
10b077aed3SPierre Pronchery /*
11b077aed3SPierre Pronchery * This file uses the low level AES functions (which are deprecated for
12b077aed3SPierre Pronchery * non-internal use) in order to implement provider AES ciphers.
13b077aed3SPierre Pronchery */
14b077aed3SPierre Pronchery #include "internal/deprecated.h"
15b077aed3SPierre Pronchery
16b077aed3SPierre Pronchery #include <openssl/proverr.h>
17b077aed3SPierre Pronchery #include "cipher_aes.h"
18b077aed3SPierre Pronchery #include "prov/providercommon.h"
19b077aed3SPierre Pronchery #include "prov/implementations.h"
20b077aed3SPierre Pronchery
21b077aed3SPierre Pronchery /* AES wrap with padding has IV length of 4, without padding 8 */
22b077aed3SPierre Pronchery #define AES_WRAP_PAD_IVLEN 4
23b077aed3SPierre Pronchery #define AES_WRAP_NOPAD_IVLEN 8
24b077aed3SPierre Pronchery
25b077aed3SPierre Pronchery #define WRAP_FLAGS (PROV_CIPHER_FLAG_CUSTOM_IV)
26b077aed3SPierre Pronchery #define WRAP_FLAGS_INV (WRAP_FLAGS | PROV_CIPHER_FLAG_INVERSE_CIPHER)
27b077aed3SPierre Pronchery
28b077aed3SPierre Pronchery typedef size_t (*aeswrap_fn)(void *key, const unsigned char *iv,
29b077aed3SPierre Pronchery unsigned char *out, const unsigned char *in,
30b077aed3SPierre Pronchery size_t inlen, block128_f block);
31b077aed3SPierre Pronchery
32b077aed3SPierre Pronchery static OSSL_FUNC_cipher_encrypt_init_fn aes_wrap_einit;
33b077aed3SPierre Pronchery static OSSL_FUNC_cipher_decrypt_init_fn aes_wrap_dinit;
34b077aed3SPierre Pronchery static OSSL_FUNC_cipher_update_fn aes_wrap_cipher;
35b077aed3SPierre Pronchery static OSSL_FUNC_cipher_final_fn aes_wrap_final;
36b077aed3SPierre Pronchery static OSSL_FUNC_cipher_freectx_fn aes_wrap_freectx;
37b077aed3SPierre Pronchery static OSSL_FUNC_cipher_set_ctx_params_fn aes_wrap_set_ctx_params;
38b077aed3SPierre Pronchery
39b077aed3SPierre Pronchery typedef struct prov_aes_wrap_ctx_st {
40b077aed3SPierre Pronchery PROV_CIPHER_CTX base;
41b077aed3SPierre Pronchery union {
42b077aed3SPierre Pronchery OSSL_UNION_ALIGN;
43b077aed3SPierre Pronchery AES_KEY ks;
44b077aed3SPierre Pronchery } ks;
45b077aed3SPierre Pronchery aeswrap_fn wrapfn;
46b077aed3SPierre Pronchery
47b077aed3SPierre Pronchery } PROV_AES_WRAP_CTX;
48b077aed3SPierre Pronchery
49b077aed3SPierre Pronchery
aes_wrap_newctx(size_t kbits,size_t blkbits,size_t ivbits,unsigned int mode,uint64_t flags)50b077aed3SPierre Pronchery static void *aes_wrap_newctx(size_t kbits, size_t blkbits,
51b077aed3SPierre Pronchery size_t ivbits, unsigned int mode, uint64_t flags)
52b077aed3SPierre Pronchery {
53b077aed3SPierre Pronchery PROV_AES_WRAP_CTX *wctx;
54b077aed3SPierre Pronchery PROV_CIPHER_CTX *ctx;
55b077aed3SPierre Pronchery
56b077aed3SPierre Pronchery if (!ossl_prov_is_running())
57b077aed3SPierre Pronchery return NULL;
58b077aed3SPierre Pronchery
59b077aed3SPierre Pronchery wctx = OPENSSL_zalloc(sizeof(*wctx));
60b077aed3SPierre Pronchery ctx = (PROV_CIPHER_CTX *)wctx;
61b077aed3SPierre Pronchery if (ctx != NULL) {
62b077aed3SPierre Pronchery ossl_cipher_generic_initkey(ctx, kbits, blkbits, ivbits, mode, flags,
63b077aed3SPierre Pronchery NULL, NULL);
64b077aed3SPierre Pronchery ctx->pad = (ctx->ivlen == AES_WRAP_PAD_IVLEN);
65b077aed3SPierre Pronchery }
66b077aed3SPierre Pronchery return wctx;
67b077aed3SPierre Pronchery }
68b077aed3SPierre Pronchery
aes_wrap_dupctx(void * wctx)69*e0c4386eSCy Schubert static void *aes_wrap_dupctx(void *wctx)
70*e0c4386eSCy Schubert {
71*e0c4386eSCy Schubert PROV_AES_WRAP_CTX *ctx = wctx;
72*e0c4386eSCy Schubert PROV_AES_WRAP_CTX *dctx = wctx;
73*e0c4386eSCy Schubert
74*e0c4386eSCy Schubert if (ctx == NULL)
75*e0c4386eSCy Schubert return NULL;
76*e0c4386eSCy Schubert dctx = OPENSSL_memdup(ctx, sizeof(*ctx));
77*e0c4386eSCy Schubert
78*e0c4386eSCy Schubert if (dctx != NULL && dctx->base.tlsmac != NULL && dctx->base.alloced) {
79*e0c4386eSCy Schubert dctx->base.tlsmac = OPENSSL_memdup(dctx->base.tlsmac,
80*e0c4386eSCy Schubert dctx->base.tlsmacsize);
81*e0c4386eSCy Schubert if (dctx->base.tlsmac == NULL) {
82*e0c4386eSCy Schubert OPENSSL_free(dctx);
83*e0c4386eSCy Schubert dctx = NULL;
84*e0c4386eSCy Schubert }
85*e0c4386eSCy Schubert }
86*e0c4386eSCy Schubert return dctx;
87*e0c4386eSCy Schubert }
88*e0c4386eSCy Schubert
aes_wrap_freectx(void * vctx)89b077aed3SPierre Pronchery static void aes_wrap_freectx(void *vctx)
90b077aed3SPierre Pronchery {
91b077aed3SPierre Pronchery PROV_AES_WRAP_CTX *wctx = (PROV_AES_WRAP_CTX *)vctx;
92b077aed3SPierre Pronchery
93b077aed3SPierre Pronchery ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
94b077aed3SPierre Pronchery OPENSSL_clear_free(wctx, sizeof(*wctx));
95b077aed3SPierre Pronchery }
96b077aed3SPierre Pronchery
aes_wrap_init(void * vctx,const unsigned char * key,size_t keylen,const unsigned char * iv,size_t ivlen,const OSSL_PARAM params[],int enc)97b077aed3SPierre Pronchery static int aes_wrap_init(void *vctx, const unsigned char *key,
98b077aed3SPierre Pronchery size_t keylen, const unsigned char *iv,
99b077aed3SPierre Pronchery size_t ivlen, const OSSL_PARAM params[], int enc)
100b077aed3SPierre Pronchery {
101b077aed3SPierre Pronchery PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx;
102b077aed3SPierre Pronchery PROV_AES_WRAP_CTX *wctx = (PROV_AES_WRAP_CTX *)vctx;
103b077aed3SPierre Pronchery
104b077aed3SPierre Pronchery if (!ossl_prov_is_running())
105b077aed3SPierre Pronchery return 0;
106b077aed3SPierre Pronchery
107b077aed3SPierre Pronchery ctx->enc = enc;
108b077aed3SPierre Pronchery if (ctx->pad)
109b077aed3SPierre Pronchery wctx->wrapfn = enc ? CRYPTO_128_wrap_pad : CRYPTO_128_unwrap_pad;
110b077aed3SPierre Pronchery else
111b077aed3SPierre Pronchery wctx->wrapfn = enc ? CRYPTO_128_wrap : CRYPTO_128_unwrap;
112b077aed3SPierre Pronchery
113b077aed3SPierre Pronchery if (iv != NULL) {
114b077aed3SPierre Pronchery if (!ossl_cipher_generic_initiv(ctx, iv, ivlen))
115b077aed3SPierre Pronchery return 0;
116b077aed3SPierre Pronchery }
117b077aed3SPierre Pronchery if (key != NULL) {
118b077aed3SPierre Pronchery int use_forward_transform;
119b077aed3SPierre Pronchery
120b077aed3SPierre Pronchery if (keylen != ctx->keylen) {
121b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
122b077aed3SPierre Pronchery return 0;
123b077aed3SPierre Pronchery }
124b077aed3SPierre Pronchery /*
125b077aed3SPierre Pronchery * See SP800-38F : Section 5.1
126b077aed3SPierre Pronchery * The forward and inverse transformations for the AES block
127b077aed3SPierre Pronchery * cipher—called “cipher” and “inverse cipher” are informally known as
128b077aed3SPierre Pronchery * the AES encryption and AES decryption functions, respectively.
129b077aed3SPierre Pronchery * If the designated cipher function for a key-wrap algorithm is chosen
130b077aed3SPierre Pronchery * to be the AES decryption function, then CIPH-1K will be the AES
131b077aed3SPierre Pronchery * encryption function.
132b077aed3SPierre Pronchery */
133b077aed3SPierre Pronchery if (ctx->inverse_cipher == 0)
134b077aed3SPierre Pronchery use_forward_transform = ctx->enc;
135b077aed3SPierre Pronchery else
136b077aed3SPierre Pronchery use_forward_transform = !ctx->enc;
137b077aed3SPierre Pronchery if (use_forward_transform) {
138b077aed3SPierre Pronchery AES_set_encrypt_key(key, keylen * 8, &wctx->ks.ks);
139b077aed3SPierre Pronchery ctx->block = (block128_f)AES_encrypt;
140b077aed3SPierre Pronchery } else {
141b077aed3SPierre Pronchery AES_set_decrypt_key(key, keylen * 8, &wctx->ks.ks);
142b077aed3SPierre Pronchery ctx->block = (block128_f)AES_decrypt;
143b077aed3SPierre Pronchery }
144b077aed3SPierre Pronchery }
145b077aed3SPierre Pronchery return aes_wrap_set_ctx_params(ctx, params);
146b077aed3SPierre Pronchery }
147b077aed3SPierre Pronchery
aes_wrap_einit(void * ctx,const unsigned char * key,size_t keylen,const unsigned char * iv,size_t ivlen,const OSSL_PARAM params[])148b077aed3SPierre Pronchery static int aes_wrap_einit(void *ctx, const unsigned char *key, size_t keylen,
149b077aed3SPierre Pronchery const unsigned char *iv, size_t ivlen,
150b077aed3SPierre Pronchery const OSSL_PARAM params[])
151b077aed3SPierre Pronchery {
152b077aed3SPierre Pronchery return aes_wrap_init(ctx, key, keylen, iv, ivlen, params, 1);
153b077aed3SPierre Pronchery }
154b077aed3SPierre Pronchery
aes_wrap_dinit(void * ctx,const unsigned char * key,size_t keylen,const unsigned char * iv,size_t ivlen,const OSSL_PARAM params[])155b077aed3SPierre Pronchery static int aes_wrap_dinit(void *ctx, const unsigned char *key, size_t keylen,
156b077aed3SPierre Pronchery const unsigned char *iv, size_t ivlen,
157b077aed3SPierre Pronchery const OSSL_PARAM params[])
158b077aed3SPierre Pronchery {
159b077aed3SPierre Pronchery return aes_wrap_init(ctx, key, keylen, iv, ivlen, params, 0);
160b077aed3SPierre Pronchery }
161b077aed3SPierre Pronchery
aes_wrap_cipher_internal(void * vctx,unsigned char * out,const unsigned char * in,size_t inlen)162b077aed3SPierre Pronchery static int aes_wrap_cipher_internal(void *vctx, unsigned char *out,
163b077aed3SPierre Pronchery const unsigned char *in, size_t inlen)
164b077aed3SPierre Pronchery {
165b077aed3SPierre Pronchery PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx;
166b077aed3SPierre Pronchery PROV_AES_WRAP_CTX *wctx = (PROV_AES_WRAP_CTX *)vctx;
167b077aed3SPierre Pronchery size_t rv;
168b077aed3SPierre Pronchery int pad = ctx->pad;
169b077aed3SPierre Pronchery
170b077aed3SPierre Pronchery /* No final operation so always return zero length */
171b077aed3SPierre Pronchery if (in == NULL)
172b077aed3SPierre Pronchery return 0;
173b077aed3SPierre Pronchery
174b077aed3SPierre Pronchery /* Input length must always be non-zero */
175b077aed3SPierre Pronchery if (inlen == 0) {
176b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_INPUT_LENGTH);
177b077aed3SPierre Pronchery return -1;
178b077aed3SPierre Pronchery }
179b077aed3SPierre Pronchery
180b077aed3SPierre Pronchery /* If decrypting need at least 16 bytes and multiple of 8 */
181b077aed3SPierre Pronchery if (!ctx->enc && (inlen < 16 || inlen & 0x7)) {
182b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_INPUT_LENGTH);
183b077aed3SPierre Pronchery return -1;
184b077aed3SPierre Pronchery }
185b077aed3SPierre Pronchery
186b077aed3SPierre Pronchery /* If not padding input must be multiple of 8 */
187b077aed3SPierre Pronchery if (!pad && inlen & 0x7) {
188b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_INPUT_LENGTH);
189b077aed3SPierre Pronchery return -1;
190b077aed3SPierre Pronchery }
191b077aed3SPierre Pronchery
192b077aed3SPierre Pronchery if (out == NULL) {
193b077aed3SPierre Pronchery if (ctx->enc) {
194b077aed3SPierre Pronchery /* If padding round up to multiple of 8 */
195b077aed3SPierre Pronchery if (pad)
196b077aed3SPierre Pronchery inlen = (inlen + 7) / 8 * 8;
197b077aed3SPierre Pronchery /* 8 byte prefix */
198b077aed3SPierre Pronchery return inlen + 8;
199b077aed3SPierre Pronchery } else {
200b077aed3SPierre Pronchery /*
201b077aed3SPierre Pronchery * If not padding output will be exactly 8 bytes smaller than
202b077aed3SPierre Pronchery * input. If padding it will be at least 8 bytes smaller but we
203b077aed3SPierre Pronchery * don't know how much.
204b077aed3SPierre Pronchery */
205b077aed3SPierre Pronchery return inlen - 8;
206b077aed3SPierre Pronchery }
207b077aed3SPierre Pronchery }
208b077aed3SPierre Pronchery
209b077aed3SPierre Pronchery rv = wctx->wrapfn(&wctx->ks.ks, ctx->iv_set ? ctx->iv : NULL, out, in,
210b077aed3SPierre Pronchery inlen, ctx->block);
211b077aed3SPierre Pronchery if (!rv) {
212b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED);
213b077aed3SPierre Pronchery return -1;
214b077aed3SPierre Pronchery }
215b077aed3SPierre Pronchery if (rv > INT_MAX) {
216b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_OUTPUT_LENGTH);
217b077aed3SPierre Pronchery return -1;
218b077aed3SPierre Pronchery }
219b077aed3SPierre Pronchery return (int)rv;
220b077aed3SPierre Pronchery }
221b077aed3SPierre Pronchery
aes_wrap_final(void * vctx,unsigned char * out,size_t * outl,size_t outsize)222b077aed3SPierre Pronchery static int aes_wrap_final(void *vctx, unsigned char *out, size_t *outl,
223b077aed3SPierre Pronchery size_t outsize)
224b077aed3SPierre Pronchery {
225b077aed3SPierre Pronchery if (!ossl_prov_is_running())
226b077aed3SPierre Pronchery return 0;
227b077aed3SPierre Pronchery
228b077aed3SPierre Pronchery *outl = 0;
229b077aed3SPierre Pronchery return 1;
230b077aed3SPierre Pronchery }
231b077aed3SPierre Pronchery
aes_wrap_cipher(void * vctx,unsigned char * out,size_t * outl,size_t outsize,const unsigned char * in,size_t inl)232b077aed3SPierre Pronchery static int aes_wrap_cipher(void *vctx,
233b077aed3SPierre Pronchery unsigned char *out, size_t *outl, size_t outsize,
234b077aed3SPierre Pronchery const unsigned char *in, size_t inl)
235b077aed3SPierre Pronchery {
236b077aed3SPierre Pronchery PROV_AES_WRAP_CTX *ctx = (PROV_AES_WRAP_CTX *)vctx;
237b077aed3SPierre Pronchery size_t len;
238b077aed3SPierre Pronchery
239b077aed3SPierre Pronchery if (!ossl_prov_is_running())
240b077aed3SPierre Pronchery return 0;
241b077aed3SPierre Pronchery
242b077aed3SPierre Pronchery if (inl == 0) {
243b077aed3SPierre Pronchery *outl = 0;
244b077aed3SPierre Pronchery return 1;
245b077aed3SPierre Pronchery }
246b077aed3SPierre Pronchery
247b077aed3SPierre Pronchery if (outsize < inl) {
248b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
249b077aed3SPierre Pronchery return 0;
250b077aed3SPierre Pronchery }
251b077aed3SPierre Pronchery
252b077aed3SPierre Pronchery len = aes_wrap_cipher_internal(ctx, out, in, inl);
253b077aed3SPierre Pronchery if (len <= 0)
254b077aed3SPierre Pronchery return 0;
255b077aed3SPierre Pronchery
256b077aed3SPierre Pronchery *outl = len;
257b077aed3SPierre Pronchery return 1;
258b077aed3SPierre Pronchery }
259b077aed3SPierre Pronchery
aes_wrap_set_ctx_params(void * vctx,const OSSL_PARAM params[])260b077aed3SPierre Pronchery static int aes_wrap_set_ctx_params(void *vctx, const OSSL_PARAM params[])
261b077aed3SPierre Pronchery {
262b077aed3SPierre Pronchery PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx;
263b077aed3SPierre Pronchery const OSSL_PARAM *p;
264b077aed3SPierre Pronchery size_t keylen = 0;
265b077aed3SPierre Pronchery
266b077aed3SPierre Pronchery if (params == NULL)
267b077aed3SPierre Pronchery return 1;
268b077aed3SPierre Pronchery
269b077aed3SPierre Pronchery p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN);
270b077aed3SPierre Pronchery if (p != NULL) {
271b077aed3SPierre Pronchery if (!OSSL_PARAM_get_size_t(p, &keylen)) {
272b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
273b077aed3SPierre Pronchery return 0;
274b077aed3SPierre Pronchery }
275b077aed3SPierre Pronchery if (ctx->keylen != keylen) {
276b077aed3SPierre Pronchery ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
277b077aed3SPierre Pronchery return 0;
278b077aed3SPierre Pronchery }
279b077aed3SPierre Pronchery }
280b077aed3SPierre Pronchery return 1;
281b077aed3SPierre Pronchery }
282b077aed3SPierre Pronchery
283b077aed3SPierre Pronchery #define IMPLEMENT_cipher(mode, fname, UCMODE, flags, kbits, blkbits, ivbits) \
284b077aed3SPierre Pronchery static OSSL_FUNC_cipher_get_params_fn aes_##kbits##_##fname##_get_params; \
285b077aed3SPierre Pronchery static int aes_##kbits##_##fname##_get_params(OSSL_PARAM params[]) \
286b077aed3SPierre Pronchery { \
287b077aed3SPierre Pronchery return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,\
288b077aed3SPierre Pronchery flags, kbits, blkbits, ivbits); \
289b077aed3SPierre Pronchery } \
290b077aed3SPierre Pronchery static OSSL_FUNC_cipher_newctx_fn aes_##kbits##fname##_newctx; \
291b077aed3SPierre Pronchery static void *aes_##kbits##fname##_newctx(void *provctx) \
292b077aed3SPierre Pronchery { \
293b077aed3SPierre Pronchery return aes_##mode##_newctx(kbits, blkbits, ivbits, \
294b077aed3SPierre Pronchery EVP_CIPH_##UCMODE##_MODE, flags); \
295b077aed3SPierre Pronchery } \
296b077aed3SPierre Pronchery const OSSL_DISPATCH ossl_##aes##kbits##fname##_functions[] = { \
297b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_NEWCTX, \
298b077aed3SPierre Pronchery (void (*)(void))aes_##kbits##fname##_newctx }, \
299b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))aes_##mode##_einit }, \
300b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))aes_##mode##_dinit }, \
301b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))aes_##mode##_cipher }, \
302b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_FINAL, (void (*)(void))aes_##mode##_final }, \
303b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))aes_##mode##_freectx }, \
304*e0c4386eSCy Schubert { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void))aes_##mode##_dupctx }, \
305b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_GET_PARAMS, \
306b077aed3SPierre Pronchery (void (*)(void))aes_##kbits##_##fname##_get_params }, \
307b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_GETTABLE_PARAMS, \
308b077aed3SPierre Pronchery (void (*)(void))ossl_cipher_generic_gettable_params }, \
309b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_GET_CTX_PARAMS, \
310b077aed3SPierre Pronchery (void (*)(void))ossl_cipher_generic_get_ctx_params }, \
311b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_SET_CTX_PARAMS, \
312b077aed3SPierre Pronchery (void (*)(void))aes_wrap_set_ctx_params }, \
313b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS, \
314b077aed3SPierre Pronchery (void (*)(void))ossl_cipher_generic_gettable_ctx_params }, \
315b077aed3SPierre Pronchery { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS, \
316b077aed3SPierre Pronchery (void (*)(void))ossl_cipher_generic_settable_ctx_params }, \
317b077aed3SPierre Pronchery { 0, NULL } \
318b077aed3SPierre Pronchery }
319b077aed3SPierre Pronchery
320b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrap, WRAP, WRAP_FLAGS, 256, 64, AES_WRAP_NOPAD_IVLEN * 8);
321b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrap, WRAP, WRAP_FLAGS, 192, 64, AES_WRAP_NOPAD_IVLEN * 8);
322b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrap, WRAP, WRAP_FLAGS, 128, 64, AES_WRAP_NOPAD_IVLEN * 8);
323b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrappad, WRAP, WRAP_FLAGS, 256, 64, AES_WRAP_PAD_IVLEN * 8);
324b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrappad, WRAP, WRAP_FLAGS, 192, 64, AES_WRAP_PAD_IVLEN * 8);
325b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrappad, WRAP, WRAP_FLAGS, 128, 64, AES_WRAP_PAD_IVLEN * 8);
326b077aed3SPierre Pronchery
327b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrapinv, WRAP, WRAP_FLAGS_INV, 256, 64, AES_WRAP_NOPAD_IVLEN * 8);
328b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrapinv, WRAP, WRAP_FLAGS_INV, 192, 64, AES_WRAP_NOPAD_IVLEN * 8);
329b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrapinv, WRAP, WRAP_FLAGS_INV, 128, 64, AES_WRAP_NOPAD_IVLEN * 8);
330b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrappadinv, WRAP, WRAP_FLAGS_INV, 256, 64, AES_WRAP_PAD_IVLEN * 8);
331b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrappadinv, WRAP, WRAP_FLAGS_INV, 192, 64, AES_WRAP_PAD_IVLEN * 8);
332b077aed3SPierre Pronchery IMPLEMENT_cipher(wrap, wrappadinv, WRAP, WRAP_FLAGS_INV, 128, 64, AES_WRAP_PAD_IVLEN * 8);
333