Fix the aes-xts key-length checking condition and hw declaration.
authorJerry Shih <bignose1007@gmail.com>
Mon, 25 Sep 2023 00:42:23 +0000 (08:42 +0800)
committerHugo Landau <hlandau@openssl.org>
Thu, 26 Oct 2023 14:55:50 +0000 (15:55 +0100)
The argument `key-length` includes 2 sets of keys.

All declarations should under `PROV_CIPHER_HW_declare_xts()` macro.

Signed-off-by: Jerry Shih <jerry.shih@sifive.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)

providers/implementations/ciphers/cipher_aes_xts_hw.c

index e5ee6741ea0b13ad162d4b1f93facdcfccff38b3..24b8fb17dfd4bc145f28948620fdfd96012246f5 100644 (file)
@@ -184,7 +184,7 @@ static int cipher_hw_aes_xts_rv64i_zvkned_initkey(PROV_CIPHER_CTX *ctx,
     OSSL_xts_stream_fn stream_dec = NULL;
 
     /* Zvkned only supports 128 and 256 bit keys. */
-    if (keylen * 8 == 128 || keylen * 8 == 256) {
+    if (keylen * 8 == 128 * 2 || keylen * 8 == 256 * 2) {
         XTS_SET_KEY_FN(rv64i_zvkned_set_encrypt_key,
                        rv64i_zvkned_set_decrypt_key,
                        rv64i_zvkned_encrypt, rv64i_zvkned_decrypt,
@@ -202,7 +202,7 @@ static const PROV_CIPHER_HW aes_xts_rv64i_zknd_zkne = {                        \
     cipher_hw_aes_xts_rv64i_zknd_zkne_initkey,                                 \
     NULL,                                                                      \
     cipher_hw_aes_xts_copyctx                                                  \
-};
+};                                                                             \
 static const PROV_CIPHER_HW aes_xts_rv64i_zvkned = {                           \
     cipher_hw_aes_xts_rv64i_zvkned_initkey,                                    \
     NULL,                                                                      \