diff options
author | Hongren (Zenithal) Zheng <i@zenithal.me> | 2022-05-11 18:09:46 +0800 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-21 10:49:52 +0100 |
commit | 1f664896b90f7e57ee831bfa38ac03992da0e2a4 (patch) | |
tree | 0bbf0495a424f4b0a252c35490a5b75e22f38f26 /crypto/chacha | |
parent | dc6daead2f2111de077e2c350d999291223fe749 (diff) |
Add ROTATE inline RISC-V zbb/zbkb asm for chacha
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18289)
(cherry picked from commit ca6286c382a7eb527fac9aba2a018354acb27b16)
Diffstat (limited to 'crypto/chacha')
-rw-r--r-- | crypto/chacha/chacha_enc.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crypto/chacha/chacha_enc.c b/crypto/chacha/chacha_enc.c index c5d1d63d80..f8f1835906 100644 --- a/crypto/chacha/chacha_enc.c +++ b/crypto/chacha/chacha_enc.c @@ -24,6 +24,28 @@ typedef union { # define ROTATE(v, n) (((v) << (n)) | ((v) >> (32 - (n)))) +# ifndef PEDANTIC +# if defined(__GNUC__) && __GNUC__>=2 && \ + !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) +# if defined(__riscv_zbb) || defined(__riscv_zbkb) +# if __riscv_xlen == 64 +# undef ROTATE +# define ROTATE(x, n) ({ u32 ret; \ + asm ("roriw %0, %1, %2" \ + : "=r"(ret) \ + : "r"(x), "i"(32 - (n))); ret;}) +# endif +# if __riscv_xlen == 32 +# undef ROTATE +# define ROTATE(x, n) ({ u32 ret; \ + asm ("rori %0, %1, %2" \ + : "=r"(ret) \ + : "r"(x), "i"(32 - (n))); ret;}) +# endif +# endif +# endif +# endif + # define U32TO8_LITTLE(p, v) do { \ (p)[0] = (u8)(v >> 0); \ (p)[1] = (u8)(v >> 8); \ |