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