]> git.ipfire.org Git - thirdparty/openssl.git/blob - providers/implementations/ciphers/cipher_aes_gcm_hw_rv64i.inc
riscv: Clean up extension test macros
[thirdparty/openssl.git] / providers / implementations / ciphers / cipher_aes_gcm_hw_rv64i.inc
1 /*
2 * Copyright 2022 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 /*-
11 * RISC-V 64 ZKND ZKNE support for AES GCM.
12 * This file is included by cipher_aes_gcm_hw.c
13 */
14
15 static int rv64i_zknd_zkne_gcm_initkey(PROV_GCM_CTX *ctx, const unsigned char *key,
16 size_t keylen)
17 {
18 PROV_AES_GCM_CTX *actx = (PROV_AES_GCM_CTX *)ctx;
19 AES_KEY *ks = &actx->ks.ks;
20 GCM_HW_SET_KEY_CTR_FN(ks, rv64i_zkne_set_encrypt_key, rv64i_zkne_encrypt,
21 NULL);
22 return 1;
23 }
24
25 static const PROV_GCM_HW rv64i_zknd_zkne_gcm = {
26 rv64i_zknd_zkne_gcm_initkey,
27 ossl_gcm_setiv,
28 ossl_gcm_aad_update,
29 generic_aes_gcm_cipher_update,
30 ossl_gcm_cipher_final,
31 ossl_gcm_one_shot
32 };
33
34 const PROV_GCM_HW *ossl_prov_aes_hw_gcm(size_t keybits)
35 {
36 if (RISCV_HAS_ZKND_AND_ZKNE())
37 return &rv64i_zknd_zkne_gcm;
38 else
39 return &aes_gcm;
40 }