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