Add AES_CBC_HMAC_SHA ciphers to providers.
[openssl.git] / providers / implementations / ciphers / cipher_aes_cbc_hmac_sha.h
1 /*
2  * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include "prov/ciphercommon.h"
11 #include "crypto/aes_platform.h"
12
13 int cipher_capable_aes_cbc_hmac_sha1(void);
14 int cipher_capable_aes_cbc_hmac_sha256(void);
15
16 #ifdef AES_CBC_HMAC_SHA_CAPABLE
17 # include <openssl/aes.h>
18 # include <openssl/sha.h>
19
20 typedef struct prov_cipher_hw_aes_hmac_sha_ctx_st {
21     PROV_CIPHER_HW base; /* must be first */
22     void (*init_mac_key)(void *ctx, const unsigned char *inkey, size_t inlen);
23     int (*set_tls1_aad)(void *ctx, unsigned char *aad_rec, int aad_len);
24 # if !defined(OPENSSL_NO_MULTIBLOCK)
25     int (*tls1_multiblock_max_bufsize)(void *ctx);
26     int (*tls1_multiblock_aad)(
27         void *vctx, EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *param);
28     int (*tls1_multiblock_encrypt)(
29         void *ctx, EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM *param);
30 # endif /* OPENSSL_NO_MULTIBLOCK) */
31 } PROV_CIPHER_HW_AES_HMAC_SHA;
32
33 typedef struct prov_aes_hmac_sha_ctx_st {
34     PROV_CIPHER_CTX base;
35     AES_KEY ks;
36     size_t payload_length;      /* AAD length in decrypt case */
37     union {
38         unsigned int tls_ver;
39         unsigned char tls_aad[16]; /* 13 used */
40     } aux;
41     const PROV_CIPHER_HW_AES_HMAC_SHA *hw;
42     /* some value that are setup by set methods - that can be retrieved */
43     unsigned int multiblock_interleave;
44     unsigned int multiblock_aad_packlen;
45     size_t multiblock_max_send_fragment;
46     size_t multiblock_encrypt_len;
47     size_t tls_aad_pad;
48 } PROV_AES_HMAC_SHA_CTX;
49
50 typedef struct prov_aes_hmac_sha1_ctx_st {
51     PROV_AES_HMAC_SHA_CTX base_ctx;
52     SHA_CTX head, tail, md;
53 } PROV_AES_HMAC_SHA1_CTX;
54
55 typedef struct prov_aes_hmac_sha256_ctx_st {
56     PROV_AES_HMAC_SHA_CTX base_ctx;
57     SHA256_CTX head, tail, md;
58 } PROV_AES_HMAC_SHA256_CTX;
59
60 # define NO_PAYLOAD_LENGTH ((size_t)-1)
61
62 const PROV_CIPHER_HW_AES_HMAC_SHA *PROV_CIPHER_HW_aes_cbc_hmac_sha1(void);
63 const PROV_CIPHER_HW_AES_HMAC_SHA *PROV_CIPHER_HW_aes_cbc_hmac_sha256(void);
64
65 #endif /* AES_CBC_HMAC_SHA_CAPABLE */