-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Make destructive in most cases - Add `rnum` immediate to key schedule instructions On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: modified: insns/vaes128e.adoc new file: insns/vaes192e.adoc new file: insns/vaes256e.adoc modified: insns/vaesds.adoc modified: insns/vaesdsm.adoc modified: insns/vaeses.adoc modified: insns/vaesesm.adoc modified: insns/vaeskf128.vv.adoc modified: insns/vaeskf192.vv.adoc modified: insns/vaeskf256.vv.adoc modified: riscv-crypto-spec-vector.adoc
- Loading branch information
1 parent
17c2c39
commit 73de909
Showing
11 changed files
with
273 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
[[insns-vaes192e, Vector AES-192 all-rounds encrypt]] | ||
= vaes192e.[vv,vs] | ||
|
||
Synopsis:: | ||
Vector AES-192 all rounds encryption instruction. | ||
|
||
Mnemonic:: | ||
vaes192e.[vv,vs] vd, vs1, vs2 | ||
|
||
Encoding (Vector-Scalar):: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{bits: 7, name: '???????'}, | ||
{bits: 5, name: 'vd'}, | ||
{bits: 3, name: '???'}, | ||
{bits: 5, name: 'vs1'}, | ||
{bits: 5, name: 'vs2'}, | ||
{bits: 7, name: '???????'}, | ||
]} | ||
.... | ||
|
||
Encoding (Vector-Vector):: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{bits: 7, name: '???????'}, | ||
{bits: 5, name: 'vd'}, | ||
{bits: 3, name: '???'}, | ||
{bits: 5, name: 'vs1'}, | ||
{bits: 5, name: 'vs2'}, | ||
{bits: 7, name: '???????'}, | ||
]} | ||
.... | ||
|
||
Description:: | ||
This instruction implements the entire AES-192 block cipher encryption | ||
function. | ||
It treats each element of `vd` as the plaintext | ||
and concatenates elements of `vs1` and `vs2` to create the 192-bit key. | ||
The Vector-Vector (VV) variant encrypts elements of `vd` under corresponding | ||
elements of `vs1` and `vs2`. | ||
The Vector-Scalar (VV) variant encrypts elements of `vd` under the | ||
zeroth element of `vs1` and `vs2`. | ||
The result (i.e. the ciphertext) is written to elements of `vd`. | ||
|
||
This instruction treats `EEW=128`, regardless of `vtype.vsew` | ||
and requires that `Zvl128b` be implemented (i.e `VLEN>=128`). | ||
It _does not_ require that `EEW=128` be | ||
supported for any other instruction. | ||
|
||
Operation:: | ||
[source,sail] | ||
-- | ||
function clause execute (VAES192E(vs1, vd, vv)) = { | ||
assert(VLEN>=128); | ||
foreach (i from vlstart to vl) { | ||
let keyelem = if vv then i else 0; | ||
state : bits(128) = get_velem(vd, EEW=128, i); | ||
ekey : bits(192) = get_velem(vs1, EEW=128, keyelem) @ | ||
get_velem(vs2, EEW=128, keyelem) [128..64]; | ||
rkey : bits(128) = ekey[127..0]; | ||
state = state ^ rkey; | ||
foreach(r from 0 to 12) { | ||
state = aes_fwd_sub_bytes(state); | ||
state = aes_fwd_shift_rows(state); | ||
state = aes_fwd_mix_columns(state); | ||
state = state ^ rkey; | ||
rkey = aes_192_forward_key_schedule(ekey); | ||
ekey = rkey @ ekey[128..64]; | ||
} | ||
state = aes_fwd_sub_bytes(state); | ||
state = aes_fwd_shift_rows(state); | ||
state = state ^ rkey; | ||
set_velem(vd, EEW=128, i, state); | ||
} | ||
RETIRE_SUCCESS | ||
} | ||
-- | ||
|
||
Included in:: | ||
[%header,cols="4,2,2"] | ||
|=== | ||
|Extension | ||
|Minimum version | ||
|Lifecycle state | ||
|
||
| <<zvknf>> | ||
| v0.1.0 | ||
| In Development | ||
|=== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
[[insns-vaes256e, Vector AES-256 all-rounds encrypt]] | ||
= vaes256e.[vv,vs] | ||
|
||
Synopsis:: | ||
Vector AES-256 all rounds encryption instruction. | ||
|
||
Mnemonic:: | ||
vaes256e.[vv,vs] vd, vs1, vs2 | ||
|
||
Encoding (Vector-Scalar):: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{bits: 7, name: '???????'}, | ||
{bits: 5, name: 'vd'}, | ||
{bits: 3, name: '???'}, | ||
{bits: 5, name: 'vs1'}, | ||
{bits: 5, name: 'vs2'}, | ||
{bits: 7, name: '???????'}, | ||
]} | ||
.... | ||
|
||
Encoding (Vector-Vector):: | ||
[wavedrom, , svg] | ||
.... | ||
{reg:[ | ||
{bits: 7, name: '???????'}, | ||
{bits: 5, name: 'vd'}, | ||
{bits: 3, name: '???'}, | ||
{bits: 5, name: 'vs1'}, | ||
{bits: 5, name: 'vs2'}, | ||
{bits: 7, name: '???????'}, | ||
]} | ||
.... | ||
|
||
Description:: | ||
This instruction implements the entire AES-256 block cipher encryption | ||
function. | ||
It treats each element of `vd` as the plaintext | ||
and concatenates elements of `vs1` and `vs2` to create the 256-bit key. | ||
The Vector-Vector (VV) variant encrypts elements of `vd` under corresponding | ||
elements of `vs1` and `vs2`. | ||
The Vector-Scalar (VV) variant encrypts elements of `vd` under the | ||
zeroth element of `vs1` and `vs2`. | ||
The result (i.e. the ciphertext) is written to elements of `vd`. | ||
|
||
This instruction treats `EEW=128`, regardless of `vtype.vsew` | ||
and requires that `Zvl128b` be implemented (i.e `VLEN>=128`). | ||
It _does not_ require that `EEW=128` be | ||
supported for any other instruction. | ||
|
||
Operation:: | ||
[source,sail] | ||
-- | ||
function clause execute (VAES256E(vs1, vd, vv)) = { | ||
assert(VLEN>=128); | ||
foreach (i from vlstart to vl) { | ||
let keyelem = if vv then i else 0; | ||
state : bits(128) = get_velem(vd, EEW=128, i); | ||
ekey : bits(256) = get_velem(vs1, EEW=128, keyelem) @ | ||
get_velem(vs2, EEW=128, keyelem) ; | ||
rkey : bits(128) = ekey[127..0]; | ||
state = state ^ rkey; | ||
foreach(r from 0 to 12) { | ||
state = aes_fwd_sub_bytes(state); | ||
state = aes_fwd_shift_rows(state); | ||
state = aes_fwd_mix_columns(state); | ||
state = state ^ rkey; | ||
rkey = aes_256_forward_key_schedule(ekey); | ||
ekey = rkey @ ekey[256..128]; | ||
} | ||
state = aes_fwd_sub_bytes(state); | ||
state = aes_fwd_shift_rows(state); | ||
state = state ^ rkey; | ||
set_velem(vd, EEW=128, i, state); | ||
} | ||
RETIRE_SUCCESS | ||
} | ||
-- | ||
|
||
Included in:: | ||
[%header,cols="4,2,2"] | ||
|=== | ||
|Extension | ||
|Minimum version | ||
|Lifecycle state | ||
|
||
| <<zvknf>> | ||
| v0.1.0 | ||
| In Development | ||
|=== | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.