diff options
author | Hongren (Zenithal) Zheng <i@zenithal.me> | 2022-05-14 00:01:11 +0800 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-09-05 10:20:30 +1000 |
commit | 5ccee69b1384fa9377986a6f7730e0d9a372b42b (patch) | |
tree | b354928fcafbffc0799b4633aeb1892f181f9aa5 /providers/implementations/ciphers/cipher_aes_xts_hw.c | |
parent | cbb15b31b98f47276cf9e87453831d96274baf66 (diff) | |
download | openssl-new-5ccee69b1384fa9377986a6f7730e0d9a372b42b.tar.gz |
provider: cipher: aes: add riscv32 zkn (zbkb) support
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18308)
Diffstat (limited to 'providers/implementations/ciphers/cipher_aes_xts_hw.c')
-rw-r--r-- | providers/implementations/ciphers/cipher_aes_xts_hw.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/providers/implementations/ciphers/cipher_aes_xts_hw.c b/providers/implementations/ciphers/cipher_aes_xts_hw.c index c2cbf060fb..c8c9cbf19e 100644 --- a/providers/implementations/ciphers/cipher_aes_xts_hw.c +++ b/providers/implementations/ciphers/cipher_aes_xts_hw.c @@ -183,6 +183,48 @@ static const PROV_CIPHER_HW aes_xts_rv64i_zknd_zkne = { \ # define PROV_CIPHER_HW_select_xts() \ if (RV64I_ZKND_ZKNE_CAPABLE) \ return &aes_xts_rv64i_zknd_zkne; +#elif defined(RV32I_ZBKB_ZKND_ZKNE_CAPABLE) && defined(RV32I_ZKND_ZKNE_CAPABLE) + +static int cipher_hw_aes_xts_rv32i_zknd_zkne_initkey(PROV_CIPHER_CTX *ctx, + const unsigned char *key, + size_t keylen) +{ + PROV_AES_XTS_CTX *xctx = (PROV_AES_XTS_CTX *)ctx; + + XTS_SET_KEY_FN(rv32i_zkne_set_encrypt_key, rv32i_zknd_zkne_set_decrypt_key, + rv32i_zkne_encrypt, rv32i_zknd_decrypt, + NULL, NULL); + return 1; +} + +static int cipher_hw_aes_xts_rv32i_zbkb_zknd_zkne_initkey(PROV_CIPHER_CTX *ctx, + const unsigned char *key, + size_t keylen) +{ + PROV_AES_XTS_CTX *xctx = (PROV_AES_XTS_CTX *)ctx; + + XTS_SET_KEY_FN(rv32i_zbkb_zkne_set_encrypt_key, rv32i_zbkb_zknd_zkne_set_decrypt_key, + rv32i_zkne_encrypt, rv32i_zknd_decrypt, + NULL, NULL); + return 1; +} + +# define PROV_CIPHER_HW_declare_xts() \ +static const PROV_CIPHER_HW aes_xts_rv32i_zknd_zkne = { \ + cipher_hw_aes_xts_rv32i_zknd_zkne_initkey, \ + NULL, \ + cipher_hw_aes_xts_copyctx \ +}; \ +static const PROV_CIPHER_HW aes_xts_rv32i_zbkb_zknd_zkne = { \ + cipher_hw_aes_xts_rv32i_zbkb_zknd_zkne_initkey, \ + NULL, \ + cipher_hw_aes_xts_copyctx \ +}; +# define PROV_CIPHER_HW_select_xts() \ +if (RV32I_ZBKB_ZKND_ZKNE_CAPABLE) \ + return &aes_xts_rv32i_zbkb_zknd_zkne; \ +if (RV32I_ZKND_ZKNE_CAPABLE) \ + return &aes_xts_rv32i_zknd_zkne; # else /* The generic case */ # define PROV_CIPHER_HW_declare_xts() |