Skip to content

Commit

Permalink
Fixing H value reset for vghsh/vgmul
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Brunie <[email protected]>
  • Loading branch information
nibrunie committed Sep 20, 2024
1 parent 320d64f commit c4f3549
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/vector-crypto-additional.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,14 @@ function clause execute (VGHSHVS(vs2, vs1, vd)) = {

// H is common to all element groups
let helem = 0;
let H = brev8(get_velem(vs2, EGW=128, helem)); // Hash subkey
let Hinit = brev8(get_velem(vs2, EGW=128, helem)); // Hash subkey

foreach (i from eg_start to eg_len-1) {
let Y = get_velem(vd,EGW=128,i); // current partial-hash
let X = get_velem(vs1,EGW=128,i); // block cipher output
// Since H is destroyed by the inner loop it must be reset
// on every element-group iteration (even if loop independent)
let H = Hinit;

let Z : bits(128) = 0;

Expand Down Expand Up @@ -559,11 +562,15 @@ function clause execute (VGMUL(vs2, vs1, vd, suffix)) = {
eg_start = (vstart/EGS)
// H multiplicand is common for all loop iterations
let helem = 0;
let H = brev8(get_velem(vs2,EGW=128, helem)); // Multiplicand
let Hinit = brev8(get_velem(vs2,EGW=128, helem)); // Multiplicand


foreach (i from eg_start to eg_len-1) {
let Y = brev8(get_velem(vd,EGW=128,i)); // Multiplier
let Z : bits(128) = 0;
let Z : bits(128) = 0;
// Since H is destroyed by the inner loop it must be reset
// on every element-group iteration (even if loop independent)
let H = Hinit;

for (int bit = 0; bit < 128; bit++) {
if bit_to_bool(Y[bit])
Expand Down

0 comments on commit c4f3549

Please sign in to comment.