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