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 "prov/ciphercommon_ccm.h" 13*b077aed3SPierre Pronchery #include "crypto/aes_platform.h" 14*b077aed3SPierre Pronchery 15*b077aed3SPierre Pronchery typedef struct prov_aes_ccm_ctx_st { 16*b077aed3SPierre Pronchery PROV_CCM_CTX base; /* Must be first */ 17*b077aed3SPierre Pronchery union { 18*b077aed3SPierre Pronchery OSSL_UNION_ALIGN; 19*b077aed3SPierre Pronchery /*- 20*b077aed3SPierre Pronchery * Padding is chosen so that s390x.kmac.k overlaps with ks.ks and 21*b077aed3SPierre Pronchery * fc with ks.ks.rounds. Remember that on s390x, an AES_KEY's 22*b077aed3SPierre Pronchery * rounds field is used to store the function code and that the key 23*b077aed3SPierre Pronchery * schedule is not stored (if aes hardware support is detected). 24*b077aed3SPierre Pronchery */ 25*b077aed3SPierre Pronchery struct { 26*b077aed3SPierre Pronchery unsigned char pad[16]; 27*b077aed3SPierre Pronchery AES_KEY ks; 28*b077aed3SPierre Pronchery } ks; 29*b077aed3SPierre Pronchery #if defined(OPENSSL_CPUID_OBJ) && defined(__s390__) 30*b077aed3SPierre Pronchery struct { 31*b077aed3SPierre Pronchery S390X_KMAC_PARAMS kmac; 32*b077aed3SPierre Pronchery unsigned long long blocks; 33*b077aed3SPierre Pronchery union { 34*b077aed3SPierre Pronchery unsigned long long g[2]; 35*b077aed3SPierre Pronchery unsigned char b[AES_BLOCK_SIZE]; 36*b077aed3SPierre Pronchery } nonce; 37*b077aed3SPierre Pronchery union { 38*b077aed3SPierre Pronchery unsigned long long g[2]; 39*b077aed3SPierre Pronchery unsigned char b[AES_BLOCK_SIZE]; 40*b077aed3SPierre Pronchery } buf; 41*b077aed3SPierre Pronchery unsigned char dummy_pad[168]; 42*b077aed3SPierre Pronchery unsigned int fc; /* fc has same offset as ks.ks.rounds */ 43*b077aed3SPierre Pronchery } s390x; 44*b077aed3SPierre Pronchery #endif /* defined(OPENSSL_CPUID_OBJ) && defined(__s390__) */ 45*b077aed3SPierre Pronchery } ccm; 46*b077aed3SPierre Pronchery } PROV_AES_CCM_CTX; 47*b077aed3SPierre Pronchery 48*b077aed3SPierre Pronchery const PROV_CCM_HW *ossl_prov_aes_hw_ccm(size_t keylen); 49