]>
Commit | Line | Data |
---|---|---|
e1178600 | 1 | /* |
8020d79b | 2 | * Copyright 2001-2021 The OpenSSL Project Authors. All Rights Reserved. |
e1178600 SL |
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 | /*- | |
11 | * Fujitsu SPARC64 X support for AES GCM. | |
68a51d59 | 12 | * This file is included by cipher_aes_gcm_hw.c |
e1178600 SL |
13 | */ |
14 | ||
15 | static int t4_aes_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key, | |
16 | size_t keylen) | |
17 | { | |
18 | ctr128_f ctr; | |
19 | PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx; | |
20 | AES_KEY *ks = &actx->ks.ks; | |
21 | ||
22 | ||
23 | switch (keylen) { | |
24 | case 16: | |
25 | ctr = (ctr128_f)aes128_t4_ctr32_encrypt; | |
26 | break; | |
27 | case 24: | |
28 | ctr = (ctr128_f)aes192_t4_ctr32_encrypt; | |
29 | break; | |
30 | case 32: | |
31 | ctr = (ctr128_f)aes256_t4_ctr32_encrypt; | |
32 | break; | |
33 | default: | |
34 | return 0; | |
35 | } | |
36 | ||
4a42e264 | 37 | GCM_HW_SET_KEY_CTR_FN(ks, aes_t4_set_encrypt_key, aes_t4_encrypt, ctr); |
e1178600 SL |
38 | return 1; |
39 | } | |
40 | ||
41 | static const PROV_GCM_HW t4_aes_gcm = { | |
42 | t4_aes_gcm_initkey, | |
e36b3c2f SL |
43 | ossl_gcm_setiv, |
44 | ossl_gcm_aad_update, | |
7c66ad65 | 45 | generic_aes_gcm_cipher_update, |
e36b3c2f SL |
46 | ossl_gcm_cipher_final, |
47 | ossl_gcm_one_shot | |
e1178600 | 48 | }; |
7d6766cb | 49 | const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits) |
e1178600 SL |
50 | { |
51 | return SPARC_AES_CAPABLE ? &t4_aes_gcm : &aes_gcm; | |
52 | } |