xref: /freebsd-src/crypto/openssl/providers/implementations/ciphers/cipher_aes_cbc_hmac_sha.h (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 2019-2020 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 
13*b077aed3SPierre Pronchery int ossl_cipher_capable_aes_cbc_hmac_sha1(void);
14*b077aed3SPierre Pronchery int ossl_cipher_capable_aes_cbc_hmac_sha256(void);
15*b077aed3SPierre Pronchery 
16*b077aed3SPierre Pronchery typedef struct prov_cipher_hw_aes_hmac_sha_ctx_st {
17*b077aed3SPierre Pronchery     PROV_CIPHER_HW base; /* must be first */
18*b077aed3SPierre Pronchery     void (*init_mac_key)(void *ctx, const unsigned char *inkey, size_t inlen);
19*b077aed3SPierre Pronchery     int (*set_tls1_aad)(void *ctx, unsigned char *aad_rec, int aad_len);
20*b077aed3SPierre Pronchery # if !defined(OPENSSL_NO_MULTIBLOCK)
21*b077aed3SPierre Pronchery     int (*tls1_multiblock_max_bufsize)(void *ctx);
22*b077aed3SPierre Pronchery     int (*tls1_multiblock_aad)(
23*b077aed3SPierre Pronchery         void *vctx, EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *param);
24*b077aed3SPierre Pronchery     int (*tls1_multiblock_encrypt)(
25*b077aed3SPierre Pronchery         void *ctx, EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *param);
26*b077aed3SPierre Pronchery # endif /* OPENSSL_NO_MULTIBLOCK) */
27*b077aed3SPierre Pronchery } PROV_CIPHER_HW_AES_HMAC_SHA;
28*b077aed3SPierre Pronchery 
29*b077aed3SPierre Pronchery const PROV_CIPHER_HW_AES_HMAC_SHA *ossl_prov_cipher_hw_aes_cbc_hmac_sha1(void);
30*b077aed3SPierre Pronchery const PROV_CIPHER_HW_AES_HMAC_SHA *ossl_prov_cipher_hw_aes_cbc_hmac_sha256(void);
31*b077aed3SPierre Pronchery 
32*b077aed3SPierre Pronchery #ifdef AES_CBC_HMAC_SHA_CAPABLE
33*b077aed3SPierre Pronchery # include <openssl/aes.h>
34*b077aed3SPierre Pronchery # include <openssl/sha.h>
35*b077aed3SPierre Pronchery 
36*b077aed3SPierre Pronchery typedef struct prov_aes_hmac_sha_ctx_st {
37*b077aed3SPierre Pronchery     PROV_CIPHER_CTX base;
38*b077aed3SPierre Pronchery     AES_KEY ks;
39*b077aed3SPierre Pronchery     size_t payload_length;      /* AAD length in decrypt case */
40*b077aed3SPierre Pronchery     union {
41*b077aed3SPierre Pronchery         unsigned int tls_ver;
42*b077aed3SPierre Pronchery         unsigned char tls_aad[16]; /* 13 used */
43*b077aed3SPierre Pronchery     } aux;
44*b077aed3SPierre Pronchery     const PROV_CIPHER_HW_AES_HMAC_SHA *hw;
45*b077aed3SPierre Pronchery     /* some value that are setup by set methods - that can be retrieved */
46*b077aed3SPierre Pronchery     unsigned int multiblock_interleave;
47*b077aed3SPierre Pronchery     unsigned int multiblock_aad_packlen;
48*b077aed3SPierre Pronchery     size_t multiblock_max_send_fragment;
49*b077aed3SPierre Pronchery     size_t multiblock_encrypt_len;
50*b077aed3SPierre Pronchery     size_t tls_aad_pad;
51*b077aed3SPierre Pronchery } PROV_AES_HMAC_SHA_CTX;
52*b077aed3SPierre Pronchery 
53*b077aed3SPierre Pronchery typedef struct prov_aes_hmac_sha1_ctx_st {
54*b077aed3SPierre Pronchery     PROV_AES_HMAC_SHA_CTX base_ctx;
55*b077aed3SPierre Pronchery     SHA_CTX head, tail, md;
56*b077aed3SPierre Pronchery } PROV_AES_HMAC_SHA1_CTX;
57*b077aed3SPierre Pronchery 
58*b077aed3SPierre Pronchery typedef struct prov_aes_hmac_sha256_ctx_st {
59*b077aed3SPierre Pronchery     PROV_AES_HMAC_SHA_CTX base_ctx;
60*b077aed3SPierre Pronchery     SHA256_CTX head, tail, md;
61*b077aed3SPierre Pronchery } PROV_AES_HMAC_SHA256_CTX;
62*b077aed3SPierre Pronchery 
63*b077aed3SPierre Pronchery # define NO_PAYLOAD_LENGTH ((size_t)-1)
64*b077aed3SPierre Pronchery 
65*b077aed3SPierre Pronchery #endif /* AES_CBC_HMAC_SHA_CAPABLE */
66