<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/lib/crypto/riscv, branch master</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=master</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2026-03-24T00:50:59Z</updated>
<entry>
<title>lib/crypto: riscv/sm3: Migrate optimized code into library</title>
<updated>2026-03-24T00:50:59Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2026-03-21T04:09:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5f6bbba5e9bb7f271557513d0ed77bb7b5a92698'/>
<id>urn:sha1:5f6bbba5e9bb7f271557513d0ed77bb7b5a92698</id>
<content type='text'>
Instead of exposing the riscv-optimized SM3 code via a riscv-specific
crypto_shash algorithm, instead just implement the sm3_blocks() library
function.  This is much simpler, it makes the SM3 library functions be
riscv-optimized, and it fixes the longstanding issue where the
riscv-optimized SM3 code was disabled by default.  SM3 still remains
available through crypto_shash, but individual architectures no longer
need to handle it.

Tweak the prototype of sm3_transform_zvksh_zvkb() to match what the
library expects, including changing the block count to size_t.
Note that the assembly code already treated it as size_t.

Note: to see the diff from arch/riscv/crypto/sm3-riscv64-glue.c to
lib/crypto/riscv/sm3.h, view this commit with 'git show -M10'.

Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20260321040935.410034-9-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: riscv/ghash: Migrate optimized code into library</title>
<updated>2026-03-23T23:44:29Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2026-03-19T06:17:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=af413d71f09d4dde28277319926c1c3a6ec8b8d4'/>
<id>urn:sha1:af413d71f09d4dde28277319926c1c3a6ec8b8d4</id>
<content type='text'>
Remove the "ghash-riscv64-zvkg" crypto_shash algorithm.  Move the
corresponding assembly code into lib/crypto/, modify it to take the
length in blocks instead of bytes, and wire it up to the GHASH library.

This makes the GHASH library be optimized with the RISC-V Vector
Cryptography Extension.  It also greatly reduces the amount of
riscv-specific glue code that is needed, and it fixes the issue where
this optimized GHASH code was disabled by default.

Note that this RISC-V code has multiple opportunities for improvement,
such as adding more parallelism, providing an optimized multiplication
function, and directly supporting POLYVAL.  But for now, this commit
simply tweaks ghash_zvkg() slightly to make it compatible with the
library, then wires it up to ghash_blocks_arch().

ghash_preparekey_arch() is also implemented to store the copy of the raw
key needed by the vghsh.vv instruction.

Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20260319061723.1140720-13-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: riscv/aes: Migrate optimized code into library</title>
<updated>2026-01-12T19:39:58Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2026-01-12T19:20:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a4e573db06a4e8c519ec4c42f8e1249a0853367a'/>
<id>urn:sha1:a4e573db06a4e8c519ec4c42f8e1249a0853367a</id>
<content type='text'>
Move the aes_encrypt_zvkned() and aes_decrypt_zvkned() assembly
functions into lib/crypto/, wire them up to the AES library API, and
remove the "aes-riscv64-zvkned" crypto_cipher algorithm.

To make this possible, change the prototypes of these functions to
take (rndkeys, key_len) instead of a pointer to crypto_aes_ctx, and
change the RISC-V AES-XTS code to implement tweak encryption using the
AES library instead of directly calling aes_encrypt_zvkned().

The result is that both the AES library and crypto_cipher APIs use
RISC-V's AES instructions, whereas previously only crypto_cipher did
(and it wasn't enabled by default, which this commit fixes as well).

Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20260112192035.10427-15-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: riscv: Add poly1305-core.S to .gitignore</title>
<updated>2025-12-14T18:18:22Z</updated>
<author>
<name>Charles Mirabile</name>
<email>cmirabil@redhat.com</email>
</author>
<published>2025-12-12T18:47:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5a0b1882506858b12cc77f0e2439a5f3c5052761'/>
<id>urn:sha1:5a0b1882506858b12cc77f0e2439a5f3c5052761</id>
<content type='text'>
poly1305-core.S is an auto-generated file, so it should be ignored.

Fixes: bef9c7559869 ("lib/crypto: riscv/poly1305: Import OpenSSL/CRYPTOGAMS implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Charles Mirabile &lt;cmirabil@redhat.com&gt;
Link: https://lore.kernel.org/r/20251212184717.133701-1-cmirabil@redhat.com
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: riscv/chacha: Avoid s0/fp register</title>
<updated>2025-12-09T23:10:20Z</updated>
<author>
<name>Vivian Wang</name>
<email>wangruikang@iscas.ac.cn</email>
</author>
<published>2025-12-02T05:25:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=43169328c7b4623b54b7713ec68479cebda5465f'/>
<id>urn:sha1:43169328c7b4623b54b7713ec68479cebda5465f</id>
<content type='text'>
In chacha_zvkb, avoid using the s0 register, which is the frame pointer,
by reallocating KEY0 to t5. This makes stack traces available if e.g. a
crash happens in chacha_zvkb.

No frame pointer maintenance is otherwise required since this is a leaf
function.

Signed-off-by: Vivian Wang &lt;wangruikang@iscas.ac.cn&gt;
Fixes: bb54668837a0 ("crypto: riscv - add vector crypto accelerated ChaCha20")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20251202-riscv-chacha_zvkb-fp-v2-1-7bd00098c9dc@iscas.ac.cn
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: chacha: Consolidate into single module</title>
<updated>2025-08-29T16:50:19Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-08-27T15:11:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=13cecc526d8fe7eeb9b136159738688a1a10cd82'/>
<id>urn:sha1:13cecc526d8fe7eeb9b136159738688a1a10cd82</id>
<content type='text'>
Consolidate the ChaCha code into a single module (excluding
chacha-block-generic.c which remains always built-in for random.c),
similar to various other algorithms:

- Each arch now provides a header file lib/crypto/$(SRCARCH)/chacha.h,
  replacing lib/crypto/$(SRCARCH)/chacha*.c.  The header defines
  chacha_crypt_arch() and hchacha_block_arch().  It is included by
  lib/crypto/chacha.c, and thus the code gets built into the single
  libchacha module, with improved inlining in some cases.

- Whether arch-optimized ChaCha is buildable is now controlled centrally
  by lib/crypto/Kconfig instead of by lib/crypto/$(SRCARCH)/Kconfig.
  The conditions for enabling it remain the same as before, and it
  remains enabled by default.

- Any additional arch-specific translation units for the optimized
  ChaCha code, such as assembly files, are now compiled by
  lib/crypto/Makefile instead of lib/crypto/$(SRCARCH)/Makefile.

This removes the last use for the Makefile and Kconfig files in the
arm64, mips, powerpc, riscv, and s390 subdirectories of lib/crypto/.  So
also remove those files and the references to them.

Reviewed-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250827151131.27733-7-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: chacha: Remove unused function chacha_is_arch_optimized()</title>
<updated>2025-08-29T16:50:19Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-08-27T15:11:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c4b846ff6ecab0427cc7dcccbe0af60b244a6d56'/>
<id>urn:sha1:c4b846ff6ecab0427cc7dcccbe0af60b244a6d56</id>
<content type='text'>
chacha_is_arch_optimized() is no longer used, so remove it.

Reviewed-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250827151131.27733-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: riscv/poly1305: Import OpenSSL/CRYPTOGAMS implementation</title>
<updated>2025-08-29T16:49:18Z</updated>
<author>
<name>Zhihang Shao</name>
<email>zhihang.shao.iscas@gmail.com</email>
</author>
<published>2025-08-29T15:25:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bef9c755986980eecc18e9cecd847bc3c037aebb'/>
<id>urn:sha1:bef9c755986980eecc18e9cecd847bc3c037aebb</id>
<content type='text'>
This is a straight import of the OpenSSL/CRYPTOGAMS Poly1305
implementation for riscv authored by Andy Polyakov.  The file
'poly1305-riscv.pl' is taken straight from
https://github.com/dot-asm/cryptogams commit
5e3fba73576244708a752fa61a8e93e587f271bb.  This patch was tested on
SpacemiT X60, with 2~2.5x improvement over generic implementation.

Signed-off-by: Chunyan Zhang &lt;zhangchunyan@iscas.ac.cn&gt;
Signed-off-by: Zhihang Shao &lt;zhihang.shao.iscas@gmail.com&gt;
[EB: ported to lib/crypto/riscv/]
Reviewed-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250829152513.92459-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: Drop inline from all *_mod_init_arch() functions</title>
<updated>2025-08-27T15:15:35Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-08-16T02:04:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5012bd2dc6ab0c4499923b3b6c6113def9b0c88b'/>
<id>urn:sha1:5012bd2dc6ab0c4499923b3b6c6113def9b0c88b</id>
<content type='text'>
Drop 'inline' from all the *_mod_init_arch() functions so that the
compiler will warn about any bugs where they are unused due to not being
wired up properly.  (There are no such bugs currently, so this just
establishes a more robust convention for the future.  Of course, these
functions also tend to get inlined anyway, regardless of the keyword.)

Link: https://lore.kernel.org/r/20250816020457.432040-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: sha512: Use underlying functions instead of crypto_simd_usable()</title>
<updated>2025-08-26T16:52:27Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-07-31T22:36:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bce5816672ec27085489f096ec27739a4a233b7b'/>
<id>urn:sha1:bce5816672ec27085489f096ec27739a4a233b7b</id>
<content type='text'>
Since sha512_kunit tests the fallback code paths without using
crypto_simd_disabled_for_test, make the SHA-512 code just use the
underlying may_use_simd() and irq_fpu_usable() functions directly
instead of crypto_simd_usable().  This eliminates an unnecessary layer.

Link: https://lore.kernel.org/r/20250731223651.136939-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
</feed>
