Skip to content
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

Proposal of the intrinsics for vector crypto #234

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open

Conversation

eopXD
Copy link
Collaborator

@eopXD eopXD commented Jun 1, 2023

Update (2023/11/11)

The vector crypto extension is now has a released v1.0.0 [0]. This PR creates intrinsics that exposes interfaces to the vector crypto instructions.

Regarding the data type used in the intrinsics added, this proposal does not model the concept of "element grouping (EGS/EGW)" and reuses the existing data types of the RVV intrinsics (e.g. vuint32m1_t, vuint64m2_t).

The LLVM implementation of the intrinsics is the following: (to be updated to latest v20230531)

[0] https://github.com/riscv/riscv-crypto/releases/tag/v1.0.0

@eopXD eopXD force-pushed the eopc/vector-crypto branch 4 times, most recently from 2a9812c to 93dcd87 Compare June 28, 2023 10:03
vuint64m8_t __riscv_vror_vx_u64m8_m (vbool8_t mask, vuint64m8_t vs2, uint64_t rs1, size_t vl);
```

### [Vector Bit-manipulation used in Cryptography - Shift]():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have signed and unsigned versions of vsll, but this proposal only adds unsigned versions of vwsll. I'm not proposing a change, just mentioning this asymmetry.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am also aware of the asymmetry. The vector crypto instructions generally operates under an unsigned data type and all other intrinsics does not have variants for signed data type. So I think it is more reasonable to not a signed data type variant here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vwsll will zero-extend vs2 to 2x SEW, so I think no signed version might be less confused.

}

vuint32mf2_t test_vsm4r_vs_u32mf2(vuint32mf2_t vd, vuint32mf2_t vs2, size_t vl) {
return __riscv_vsm4r_vs_u32mf2(vd, vs2, vl);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think vs2 of .vs type of this instruction should have lmul1 type.

@eopXD
Copy link
Collaborator Author

eopXD commented Jul 17, 2023

Address comments from Craig, Nick, Brandon, and Nicholas. Thank you guys for the review.

Changes:

Zvbb - Vector Bit-manipulation used in Cryptography
Return correct LMUL type for vwsll in the function name suffix
Change rs1 operand to using type size_t

Zvbc - Vector Carryless Multiplication
Let vclmul have 64 bit variant only
Add missing vs1 (rs1) operand for vclmul

Zvkned - NIST Suite: Vector AES Block Cipher
Update test cases to have immediate operands for uimm (*.vi instruction)

Zvknh[ab] - NIST Suite: Vector SHA-2 Secure Hash
Correct vsha2c into vsha2ch and vsha2cl
Fix topic name

Zvksed - ShangMi Suite: SM4 Block Cipher
Fix overloaded name for vsmr4
Fix topic name

eopXD and others added 23 commits April 24, 2024 08:15
Signed-off-by: eop Chen <eop.chen@sifive.com>
Signed-off-by: eop Chen <eop.chen@sifive.com>
Signed-off-by: eop Chen <eop.chen@sifive.com>
'vs' instructions will take the first element group from `vs2`, while
`vd` can be other settings of register group. This commit adds extra
variants for users to choose whatever suits their need.

Signed-off-by: eop Chen <eop.chen@sifive.com>
…s regarding zvl extensions

Signed-off-by: eop Chen <eop.chen@sifive.com>
…tion

Signed-off-by: eop Chen <eop.chen@sifive.com>
- Add operand mnemonics for overloaded intrinsics of
  vaesef/vsaesem/vaesdf/vaesdm
- Add vs2 operand for vaeskf2
- Fix vs2 data type for vwsll
…esef/vsaesem/vaesdf/vaesdm

Signed-off-by: eop Chen <eop.chen@sifive.com>
…bit-manipulation_used_in_cryptography.md

Co-authored-by: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com>
Signed-off-by: Kito Cheng <kito.cheng@gmail.com>
@4vtomat
Copy link
Collaborator

4vtomat commented Apr 24, 2024

I'll take over and proceed to work on this patch~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants