authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2021-02-28 00:33:50+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-02-28 21:55:58+02:00
log0423f0f7d8afc24e48926849515f60a8a3a1e470
tree1868e101f582c5f26ecaae4d163ee83fb7b86b89
parentb959029f88fa033e54e72e42004bc261baada1f1

std/crypto/aes: fix AES {encrypt,decrypt}Wide

These functions are not used by anything yet, but run the last round only once.

2 files changed, 4 insertions(+), 16 deletions(-)

lib/std/crypto/aes/aesni.zig+2-8
......@@ -313,10 +313,7 @@ pub fn AesEncryptCtx(comptime Aes: type) type {
313313 inline while (i < rounds) : (i += 1) {
314314 ts = Block.parallel.encryptWide(count, ts, round_keys[i]);
315315 }
316 i = 1;
317 inline while (i < count) : (i += 1) {
318 ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
319 }
316 ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
320317 j = 0;
321318 inline while (j < count) : (j += 1) {
322319 dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();
......@@ -392,10 +389,7 @@ pub fn AesDecryptCtx(comptime Aes: type) type {
392389 inline while (i < rounds) : (i += 1) {
393390 ts = Block.parallel.decryptWide(count, ts, inv_round_keys[i]);
394391 }
395 i = 1;
396 inline while (i < count) : (i += 1) {
397 ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
398 }
392 ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
399393 j = 0;
400394 inline while (j < count) : (j += 1) {
401395 dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();
lib/std/crypto/aes/armcrypto.zig+2-8
......@@ -364,10 +364,7 @@ pub fn AesEncryptCtx(comptime Aes: type) type {
364364 inline while (i < rounds) : (i += 1) {
365365 ts = Block.parallel.encryptWide(count, ts, round_keys[i]);
366366 }
367 i = 1;
368 inline while (i < count) : (i += 1) {
369 ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
370 }
367 ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
371368 j = 0;
372369 inline while (j < count) : (j += 1) {
373370 dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();
......@@ -443,10 +440,7 @@ pub fn AesDecryptCtx(comptime Aes: type) type {
443440 inline while (i < rounds) : (i += 1) {
444441 ts = Block.parallel.decryptWide(count, ts, inv_round_keys[i]);
445442 }
446 i = 1;
447 inline while (i < count) : (i += 1) {
448 ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
449 }
443 ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
450444 j = 0;
451445 inline while (j < count) : (j += 1) {
452446 dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();