xref: /freebsd-src/crypto/openssl/providers/implementations/ciphers/cipher_aes_siv.h (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3*b077aed3SPierre Pronchery  *
4*b077aed3SPierre Pronchery  * Licensed under the Apache License 2.0 (the "License").  You may not use
5*b077aed3SPierre Pronchery  * this file except in compliance with the License.  You can obtain a copy
6*b077aed3SPierre Pronchery  * in the file LICENSE in the source distribution or at
7*b077aed3SPierre Pronchery  * https://www.openssl.org/source/license.html
8*b077aed3SPierre Pronchery  */
9*b077aed3SPierre Pronchery 
10*b077aed3SPierre Pronchery #include "prov/ciphercommon.h"
11*b077aed3SPierre Pronchery #include "crypto/aes_platform.h"
12*b077aed3SPierre Pronchery #include "crypto/siv.h"
13*b077aed3SPierre Pronchery 
14*b077aed3SPierre Pronchery typedef struct prov_cipher_hw_aes_siv_st {
15*b077aed3SPierre Pronchery     int (*initkey)(void *ctx, const uint8_t *key, size_t keylen);
16*b077aed3SPierre Pronchery     int (*cipher)(void *ctx, unsigned char *out, const unsigned char *in,
17*b077aed3SPierre Pronchery                   size_t len);
18*b077aed3SPierre Pronchery     void (*setspeed)(void *ctx, int speed);
19*b077aed3SPierre Pronchery     int (*settag)(void *ctx, const unsigned char *tag, size_t tagl);
20*b077aed3SPierre Pronchery     void (*cleanup)(void *ctx);
21*b077aed3SPierre Pronchery     int (*dupctx)(void *src, void *dst);
22*b077aed3SPierre Pronchery } PROV_CIPHER_HW_AES_SIV;
23*b077aed3SPierre Pronchery 
24*b077aed3SPierre Pronchery typedef struct prov_siv_ctx_st {
25*b077aed3SPierre Pronchery     unsigned int mode;       /* The mode that we are using */
26*b077aed3SPierre Pronchery     unsigned int enc : 1;    /* Set to 1 if we are encrypting or 0 otherwise */
27*b077aed3SPierre Pronchery     size_t keylen;           /* The input keylength (twice the alg key length) */
28*b077aed3SPierre Pronchery     size_t taglen;           /* the taglen is the same as the sivlen */
29*b077aed3SPierre Pronchery     SIV128_CONTEXT siv;
30*b077aed3SPierre Pronchery     EVP_CIPHER *ctr;        /* These are fetched - so we need to free them */
31*b077aed3SPierre Pronchery     EVP_CIPHER *cbc;
32*b077aed3SPierre Pronchery     const PROV_CIPHER_HW_AES_SIV *hw;
33*b077aed3SPierre Pronchery     OSSL_LIB_CTX *libctx;
34*b077aed3SPierre Pronchery } PROV_AES_SIV_CTX;
35*b077aed3SPierre Pronchery 
36*b077aed3SPierre Pronchery const PROV_CIPHER_HW_AES_SIV *ossl_prov_cipher_hw_aes_siv(size_t keybits);
37