Skip to content

RISC-V 32 no mul SP C: implement multiplication#9855

Merged
douzzer merged 1 commit intowolfSSL:masterfrom
SparkiDev:sp_rv32i_muldi3
Mar 5, 2026
Merged

RISC-V 32 no mul SP C: implement multiplication#9855
douzzer merged 1 commit intowolfSSL:masterfrom
SparkiDev:sp_rv32i_muldi3

Conversation

@SparkiDev
Copy link
Copy Markdown
Contributor

Description

No multiplication instructions when M extension not included. Standard implementation of __muldi3 is not constant time. Include a constant time implementation when SP_NO_MUL_INSTRUCTION is defined
Define it when compiling for RISC-V 32 and no multiplication extension.

Fixes zd#21264

Testing

./configure --disable-shared --enable-sp LDFLAGS=--static --host=riscv32 'CC=/opt/riscv32/bin/riscv32-unknown-linux-gnu-gcc -march=rv32ifd' --disable-asm

@SparkiDev SparkiDev self-assigned this Mar 3, 2026
@SparkiDev
Copy link
Copy Markdown
Contributor Author

Code generated with PR:
https://github.com/wolfSSL/scripts/pull/557

No multiplication instructions when M extension not included.
Standard implementation of __muldi3 is not constant time.
Include a constant time implementation when SP_NO_MUL_INSTRUCTION is
defined
Define it when compiling for RISC-V 32 and no multiplication extension.

Also fix get_entry in SP C implementation to do constant time
comparison.
@SparkiDev
Copy link
Copy Markdown
Contributor Author

retest this please

@windtf
Copy link
Copy Markdown

windtf commented Mar 4, 2026

@SparkiDev ran both the -O0 and -O3 builds and they check out 👍

@SparkiDev SparkiDev assigned wolfSSL-Bot and unassigned SparkiDev Mar 4, 2026
@SparkiDev SparkiDev requested a review from wolfSSL-Bot March 4, 2026 21:55
@SparkiDev SparkiDev added the For This Release Release version 5.9.1 label Mar 4, 2026
@douzzer douzzer added the Staged Staged for merge pending final test results and review label Mar 5, 2026
@douzzer douzzer merged commit 8a5c1c7 into wolfSSL:master Mar 5, 2026
447 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For This Release Release version 5.9.1 Staged Staged for merge pending final test results and review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants