-
Notifications
You must be signed in to change notification settings - Fork 1
Zvksh/SM3: Fix slide sequence #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The zvkb-test.c file contains a set of functions verifying and
showcasing usage of instructions defined by the Zvkb extension.
Pre-requisites:
- riscv64-linux-gnu toolchain available in PATH.
- Zvkb-enabled binutils-gdb available in PATH overriding the above
toolchain.
- Zvkb-enabled Spike available in PATH.
- RISC-V Proxy kernel (riscv-pk) compiled and available in
~/RISC-V/riscv64-linux-gnu/bin/pk (can be overridden with PK make
variable).
The default make target will compile all examples and run them in Spike
simulator.
Example make invocation:
# Build and run Zvkb tests with default parameters
make run-zvkb
# Override riscv-pk location
make run-zvkb PK=/opt/prefix/riscv64-linux-gnu/bin/pk
# Override target triplet and riscv-pk location
make run-zvkb TARGET=riscv64-unknown-linux-gnu \
PK=/opt/prefix/riscv64-linux-gnu/bin/pk
Make targets:
- zvkb-test - compiles the PoC code.
- run-zvkb - Executes the compiled binary in Spike.
- clean - Cleans the build artifacts.
Make variables:
- TARGET - Target triplet to use. By default riscv64-linux-gnu.
- PK - Location of the riscv-pk binary. By default it's
~/RISC-V/$(TARGET)/bin/pk
See Makefile for more details.
Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
The aes-cbc-test.c file contains a set of functions verifying and
showcasing usage of instructions defined by the Zvkns extension to
implement the AES-CBC algorithm routines.
Pre-requisites:
- riscv64-linux-gnu toolchain available in PATH.
- Zvkns-enabled binutils-gdb available in PATH overriding the above
toolchain.
- Zvkns-enabled Spike available in PATH.
- RISC-V Proxy kernel (riscv-pk) compiled and available in
~/RISC-V/riscv64-linux-gnu/bin/pk (can be overridden with PK make
variable).
The default make target will compile all examples and run them in Spike
simulator.
Example make invocation:
# Build and run Zvkns tests with default parameters
make run-aes-cbc
# Override riscv-pk location
make run-aes-cbc PK=/opt/prefix/riscv64-linux-gnu/bin/pk
# Override target triplet and riscv-pk location
make run-aes-cbc TARGET=riscv64-unknown-linux-gnu \
PK=/opt/prefix/riscv64-linux-gnu/bin/pk
Make targets:
- aes-cbc-test - compiles the PoC code.
- run-aes-cbc - Executes the compiled binary in Spike.
- clean - Cleans the build artifacts.
Make variables:
- TARGET - Target triplet to use. By default riscv64-linux-gnu.
- PK - Location of the riscv-pk binary. By default it's
~/RISC-V/$(TARGET)/bin/pk
See Makefile for more details.
Signed-off-by: Kornel Dulęba <mindal@semihalf.com>
Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
The aes-gcm-test.c file contains a set of functions verifying and
showcasing usage of instructions defined by the Zvkns and Zvkb
extensions to implement AES-GCM algorithm routines.
Pre-requisites:
- riscv64-linux-gnu toolchain available in PATH.
- zvkns and zvkb enabled binutils-gdb available in PATH overriding the
above toolchain.
- zvkns and zvkb enabled Spike available in PATH.
- RISC-V Proxy kernel (riscv-pk) compiled and available in
~/RISC-V/riscv64-linux-gnu/bin/pk (can be overridden with PK make
variable).
The default make target will compile all examples and run them in Spike
simulator.
Example make invocation:
# Build and run aes-gcm-test with default parameters
make run-aes-gcm
# Override riscv-pk location
make run-aes-gcm PK=/opt/prefix/riscv64-linux-gnu/bin/pk
# Override target triplet and riscv-pk location
make run-aes-gcm TARGET=riscv64-unknown-linux-gnu \
PK=/opt/prefix/riscv64-linux-gnu/bin/pk
Make targets:
- aes-gcm-test - compiles the PoC code.
- run-aes-gcm - Executes the compiled binary in Spike.
- clean - Cleans the build artifacts.
Make variables:
- TARGET - Target triplet to use. By default riscv64-linux-gnu.
- PK - Location of the riscv-pk binary. By default it's
~/RISC-V/$(TARGET)/bin/pk
See Makefile for more details.
Signed-off-by: Kornel Dulęba <mindal@semihalf.com>
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
The GHASH part of AES-GCM is now run twice using instructions from Zvkb
and Zvkg extensions and then compared to ensure result validity.
The usage of Zvkg extension can be disabled by setting "SKIP_ZVKG"
variable before running make.
This can be useful, in the case where an implementation doesn't support
Zvkg extension.
Pre-requisites:
- riscv64-linux-gnu toolchain available in PATH.
- Zvkg-enabled binutils-gdb available in PATH overriding the above
toolchain.
- Zvkg-enabled Spike available in PATH.
- RISC-V Proxy kernel (riscv-pk) compiled and available in
~/RISC-V/riscv64-linux-gnu/bin/pk (can be overridden with PK make
variable).
The default make target will compile all examples and run them in Spike
simulator.
Example make invocation:
# Build and run Zvkns+Zvkg tests with default parameters
make run-aes-gcm
# Override riscv-pk location
make run-aes-gcm PK=/opt/prefix/riscv64-linux-gnu/bin/pk
# Override target triplet and riscv-pk location
make run-aes-gcm TARGET=riscv64-unknown-linux-gnu \
PK=/opt/prefix/riscv64-linux-gnu/bin/pk
Make targets:
- aes-gcm-test - compiles the PoC code.
- run-aes-gcm - Executes the compiled binary in Spike.
- clean - Cleans the build artifacts.
Make variables:
- TARGET - Target triplet to use. By default riscv64-linux-gnu.
- PK - Location of the riscv-pk binary. By default it's
~/RISC-V/$(TARGET)/bin/pk
See Makefile for more details.
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
Signed-off-by: Kornel Duleba <mindal@semihalf.com>
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
The sha-test.c file contains a set of functions verifying and
showcasing usage of instructions defined by the Zvknha/Zvknhb
extensions to implement the SHA-128 and SHA-256 algorithm routines.
Pre-requisites:
- riscv64-linux-gnu toolchain available in PATH.
- zvknh[ab]-enabled binutils-gdb available in PATH overriding the above
toolchain.
- zvknh[ab]-enabled Spike available in PATH.
- RISC-V Proxy kernel (riscv-pk) compiled and available in
~/RISC-V/riscv64-linux-gnu/bin/pk (can be overridden with PK make
variable).
The default make target will compile all examples and run them in Spike
simulator.
Example make invocation:
# Build and run zvknh[ab] tests with default parameters
make run-sha
# Override riscv-pk location
make run-sha PK=/opt/prefix/riscv64-linux-gnu/bin/pk
# Override target triplet and riscv-pk location
make run-sha TARGET=riscv64-unknown-linux-gnu \
PK=/opt/prefix/riscv64-linux-gnu/bin/pk
Make targets:
- sha-test - compiles the PoC code.
- run-sha - Executes the compiled binary in Spike.
- clean - Cleans the build artifacts.
Make variables:
- TARGET - Target triplet to use. By default riscv64-linux-gnu.
- PK - Location of the riscv-pk binary. By default it's
~/RISC-V/$(TARGET)/bin/pk
See Makefile for more details.
Signed-off-by: Kornel Dulęba <mindal@semihalf.com>
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
The sm3-test.c file contains a set of functions verifying and
showcasing usage of instructions implementing SM3 algorithm (see [1])
defined by the Zvksh extension (see [2]).
Pre-requisites:
- riscv64-linux-gnu toolchain available in PATH.
- Zvksh-enabled binutils-gdb available in PATH overriding the above
toolchain.
- Zvksh-enabled Spike available in PATH.
- RISC-V Proxy kernel (riscv-pk) compiled and available in
~/RISC-V/riscv64-linux-gnu/bin/pk (can be overridden with PK make
variable).
The default make target will compile all examples and run them in Spike
simulator.
Example make invocation:
# Build and run Zvksh tests with default parameters
make run-sm3
# Override riscv-pk location
make run-sm3 PK=/opt/prefix/riscv64-linux-gnu/bin/pk
# Override target triplet and riscv-pk location
make run-sm3 TARGET=riscv64-unknown-linux-gnu \
PK=/opt/prefix/riscv64-linux-gnu/bin/pk
Make targets:
- sm3-test - compiles the PoC code.
- run-sm3 - Executes the compiled binary in Spike.
- clean - Cleans the build artifacts.
Make variables:
- TARGET - Target triplet to use. By default riscv64-linux-gnu.
- PK - Location of the riscv-pk binary. By default it's
~/RISC-V/$(TARGET)/bin/pk
See Makefile for more details.
[1] https://datatracker.ietf.org/doc/html/draft-oscca-cfrg-sm3-00
[2] https://github.com/riscv/riscv-crypto/releases
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
Signed-off-by: Albert Jakieła <aja@semihalf.com>
Signed-off-by: Kornel Duleba <mindal@semihalf.com>
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
The sm4-test.c file contains a set of functions verifying and
showcasing usage of instructions implementing SM4 algorithm (see [1])
defined by the Zvksed extension (see [2]).
Pre-requisites:
- riscv64-linux-gnu toolchain available in PATH.
- Zvksed-enabled binutils-gdb available in PATH overriding the above
toolchain.
- Zvksed-enabled Spike available in PATH.
- RISC-V Proxy kernel (riscv-pk) compiled and available in
~/RISC-V/riscv64-linux-gnu/bin/pk (can be overridden with PK make
variable).
The default make target will compile all examples and run them in Spike
simulator.
Example make invocation:
# Build and run Zvksed tests with default parameters
make run-sm4
# Override riscv-pk location
make run-sm4 PK=/opt/prefix/riscv64-linux-gnu/bin/pk
# Override target triplet and riscv-pk location
make run-sm4 TARGET=riscv64-unknown-linux-gnu \
PK=/opt/prefix/riscv64-linux-gnu/bin/pk
Make targets:
- sm4-test - compiles the PoC code.
- run-sm4 - Executes the compiled binary in Spike.
- clean - Cleans the build artifacts.
Make variables:
- TARGET - Target triplet to use. By default riscv64-linux-gnu.
- PK - Location of the riscv-pk binary. By default it's
~/RISC-V/$(TARGET)/bin/pk
See Makefile for more details.
[1] https://datatracker.ietf.org/doc/html/draft-ribose-cfrg-sm4-10
[2] https://github.com/riscv/riscv-crypto/releases
Signed-off-by: Albert Jakieła <aja@semihalf.com>
Signed-off-by: Eric Gouriou <ego@rivosinc.com>
Previously defined slide sequence was longer than necessary and needed v4 to be cleared before usage since vslideup.vi leaves the lower-indexed elements of vd untouched, which was an issue when using other accelerated code that used the v4 register, writing wrong data when using vor.vv. This commit fixes this issue by stop using vor.vv and no longer needing v4. Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
|
Hi @charmitro! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Previously defined slide sequence was longer than necessary and needed
v4to be cleared before usage sincevslideup.vileaves the lower-indexed elements ofvduntouched, which was an issue when using other accelerated code that used thev4register, writing wrong data when usingvor.vv.This commit fixes this issue by stop using
vor.vvand no longer needingv4.Test results: