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