mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
std.crypto.ml_kem tests: simplify incV
We don't need to reimplement 16-byte subtraction, just use a u128. As a bonus, that handles the theoretical case of an all-0xff value properly.
This commit is contained in:
committed by
Andrew Kelley
parent
858d7eda65
commit
3a07f50dab
@@ -1725,15 +1725,8 @@ const NistDRBG = struct {
|
||||
v: [16]u8,
|
||||
|
||||
fn incV(g: *NistDRBG) void {
|
||||
var j: usize = 15;
|
||||
while (j >= 0) : (j -= 1) {
|
||||
if (g.v[j] == 255) {
|
||||
g.v[j] = 0;
|
||||
} else {
|
||||
g.v[j] += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const val = std.mem.readInt(u128, &g.v, .big);
|
||||
std.mem.writeInt(u128, &g.v, val +% 1, .big);
|
||||
}
|
||||
|
||||
// AES256_CTR_DRBG_Update(pd, &g.key, &g.v).
|
||||
|
||||
Reference in New Issue
Block a user