]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
aes_platform: add riscv64 zkn asm support
authorHongren (Zenithal) Zheng <i@zenithal.me>
Fri, 29 Apr 2022 16:11:28 +0000 (00:11 +0800)
committerTomas Mraz <tomas@openssl.org>
Fri, 10 Jun 2022 09:45:41 +0000 (11:45 +0200)
Signed-off-by: Hongren (Zenithal) Zheng <i@zenithal.me>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18197)

include/crypto/aes_platform.h

index fd19c6e2dc7889cc13257ee947f8a2a36b9f3ca2..4967d59a64f9dbdb3ccd7c212e13cfb5ccda6e31 100644 (file)
@@ -428,6 +428,19 @@ void aes256_t4_xts_decrypt(const unsigned char *in, unsigned char *out,
 
 /* Convert key size to function code: [16,24,32] -> [18,19,20]. */
 #  define S390X_AES_FC(keylen)  (S390X_AES_128 + ((((keylen) << 3) - 128) >> 6))
+# elif defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 64
+/* RISC-V 64 support */
+#  include "riscv_arch.h"
+#  define RV64I_ZKND_ZKNE_CAPABLE   (RISCV_HAS_ZKND() && RISCV_HAS_ZKNE())
+
+int rv64i_zkne_set_encrypt_key(const unsigned char *userKey, const int bits,
+                          AES_KEY *key);
+int rv64i_zknd_set_decrypt_key(const unsigned char *userKey, const int bits,
+                          AES_KEY *key);
+void rv64i_zkne_encrypt(const unsigned char *in, unsigned char *out,
+                   const AES_KEY *key);
+void rv64i_zknd_decrypt(const unsigned char *in, unsigned char *out,
+                   const AES_KEY *key);
 # endif
 
 # if defined(HWAES_CAPABLE)