commit 0423f0f7d8afc24e48926849515f60a8a3a1e470 (tree)
parent b959029f88fa033e54e72e42004bc261baada1f1
Author: Frank Denis <github@pureftpd.org>
Date: Sun, 28 Feb 2021 00:33:50 +0100
std/crypto/aes: fix AES {encrypt,decrypt}Wide
These functions are not used by anything yet, but run the last
round only once.
Diffstat:
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/lib/std/crypto/aes/aesni.zig b/lib/std/crypto/aes/aesni.zig
@@ -313,10 +313,7 @@ pub fn AesEncryptCtx(comptime Aes: type) type {
inline while (i < rounds) : (i += 1) {
ts = Block.parallel.encryptWide(count, ts, round_keys[i]);
}
- i = 1;
- inline while (i < count) : (i += 1) {
- ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
- }
+ ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
j = 0;
inline while (j < count) : (j += 1) {
dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();
@@ -392,10 +389,7 @@ pub fn AesDecryptCtx(comptime Aes: type) type {
inline while (i < rounds) : (i += 1) {
ts = Block.parallel.decryptWide(count, ts, inv_round_keys[i]);
}
- i = 1;
- inline while (i < count) : (i += 1) {
- ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
- }
+ ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
j = 0;
inline while (j < count) : (j += 1) {
dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();
diff --git a/lib/std/crypto/aes/armcrypto.zig b/lib/std/crypto/aes/armcrypto.zig
@@ -364,10 +364,7 @@ pub fn AesEncryptCtx(comptime Aes: type) type {
inline while (i < rounds) : (i += 1) {
ts = Block.parallel.encryptWide(count, ts, round_keys[i]);
}
- i = 1;
- inline while (i < count) : (i += 1) {
- ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
- }
+ ts = Block.parallel.encryptLastWide(count, ts, round_keys[i]);
j = 0;
inline while (j < count) : (j += 1) {
dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();
@@ -443,10 +440,7 @@ pub fn AesDecryptCtx(comptime Aes: type) type {
inline while (i < rounds) : (i += 1) {
ts = Block.parallel.decryptWide(count, ts, inv_round_keys[i]);
}
- i = 1;
- inline while (i < count) : (i += 1) {
- ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
- }
+ ts = Block.parallel.decryptLastWide(count, ts, inv_round_keys[i]);
j = 0;
inline while (j < count) : (j += 1) {
dst[16 * j .. 16 * j + 16].* = ts[j].toBytes();