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 <openssl/aes.h> 11*b077aed3SPierre Pronchery #include "prov/ciphercommon.h" 12*b077aed3SPierre Pronchery #include "crypto/aes_platform.h" 13*b077aed3SPierre Pronchery 14*b077aed3SPierre Pronchery #define OCB_MAX_TAG_LEN AES_BLOCK_SIZE 15*b077aed3SPierre Pronchery #define OCB_MAX_DATA_LEN AES_BLOCK_SIZE 16*b077aed3SPierre Pronchery #define OCB_MAX_AAD_LEN AES_BLOCK_SIZE 17*b077aed3SPierre Pronchery 18*b077aed3SPierre Pronchery typedef struct prov_aes_ocb_ctx_st { 19*b077aed3SPierre Pronchery PROV_CIPHER_CTX base; /* Must be first */ 20*b077aed3SPierre Pronchery union { 21*b077aed3SPierre Pronchery OSSL_UNION_ALIGN; 22*b077aed3SPierre Pronchery AES_KEY ks; 23*b077aed3SPierre Pronchery } ksenc; /* AES key schedule to use for encryption/aad */ 24*b077aed3SPierre Pronchery union { 25*b077aed3SPierre Pronchery OSSL_UNION_ALIGN; 26*b077aed3SPierre Pronchery AES_KEY ks; 27*b077aed3SPierre Pronchery } ksdec; /* AES key schedule to use for decryption */ 28*b077aed3SPierre Pronchery OCB128_CONTEXT ocb; 29*b077aed3SPierre Pronchery unsigned int iv_state; /* set to one of IV_STATE_XXX */ 30*b077aed3SPierre Pronchery unsigned int key_set : 1; 31*b077aed3SPierre Pronchery size_t taglen; 32*b077aed3SPierre Pronchery size_t data_buf_len; 33*b077aed3SPierre Pronchery size_t aad_buf_len; 34*b077aed3SPierre Pronchery unsigned char tag[OCB_MAX_TAG_LEN]; 35*b077aed3SPierre Pronchery unsigned char data_buf[OCB_MAX_DATA_LEN]; /* Store partial data blocks */ 36*b077aed3SPierre Pronchery unsigned char aad_buf[OCB_MAX_AAD_LEN]; /* Store partial AAD blocks */ 37*b077aed3SPierre Pronchery } PROV_AES_OCB_CTX; 38*b077aed3SPierre Pronchery 39*b077aed3SPierre Pronchery const PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_ocb(size_t keybits); 40