1e1051a39Sopenharmony_ci/*
2e1051a39Sopenharmony_ci * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
3e1051a39Sopenharmony_ci *
4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License").  You may not use
5e1051a39Sopenharmony_ci * this file except in compliance with the License.  You can obtain a copy
6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at
7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html
8e1051a39Sopenharmony_ci */
9e1051a39Sopenharmony_ci
10e1051a39Sopenharmony_ci#include <openssl/aes.h>
11e1051a39Sopenharmony_ci#include "prov/ciphercommon.h"
12e1051a39Sopenharmony_ci#include "crypto/aes_platform.h"
13e1051a39Sopenharmony_ci
14e1051a39Sopenharmony_ci#define OCB_MAX_TAG_LEN     AES_BLOCK_SIZE
15e1051a39Sopenharmony_ci#define OCB_MAX_DATA_LEN    AES_BLOCK_SIZE
16e1051a39Sopenharmony_ci#define OCB_MAX_AAD_LEN     AES_BLOCK_SIZE
17e1051a39Sopenharmony_ci
18e1051a39Sopenharmony_citypedef struct prov_aes_ocb_ctx_st {
19e1051a39Sopenharmony_ci    PROV_CIPHER_CTX base;       /* Must be first */
20e1051a39Sopenharmony_ci    union {
21e1051a39Sopenharmony_ci        OSSL_UNION_ALIGN;
22e1051a39Sopenharmony_ci        AES_KEY ks;
23e1051a39Sopenharmony_ci    } ksenc;                    /* AES key schedule to use for encryption/aad */
24e1051a39Sopenharmony_ci    union {
25e1051a39Sopenharmony_ci        OSSL_UNION_ALIGN;
26e1051a39Sopenharmony_ci        AES_KEY ks;
27e1051a39Sopenharmony_ci    } ksdec;                    /* AES key schedule to use for decryption */
28e1051a39Sopenharmony_ci    OCB128_CONTEXT ocb;
29e1051a39Sopenharmony_ci    unsigned int iv_state;      /* set to one of IV_STATE_XXX */
30e1051a39Sopenharmony_ci    unsigned int key_set : 1;
31e1051a39Sopenharmony_ci    size_t taglen;
32e1051a39Sopenharmony_ci    size_t data_buf_len;
33e1051a39Sopenharmony_ci    size_t aad_buf_len;
34e1051a39Sopenharmony_ci    unsigned char tag[OCB_MAX_TAG_LEN];
35e1051a39Sopenharmony_ci    unsigned char data_buf[OCB_MAX_DATA_LEN]; /* Store partial data blocks */
36e1051a39Sopenharmony_ci    unsigned char aad_buf[OCB_MAX_AAD_LEN];   /* Store partial AAD blocks */
37e1051a39Sopenharmony_ci} PROV_AES_OCB_CTX;
38e1051a39Sopenharmony_ci
39e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_ocb(size_t keybits);
40