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:
Frank Denis
2026-04-20 12:14:38 +02:00
committed by Andrew Kelley
parent 858d7eda65
commit 3a07f50dab
+2 -9
View File
@@ -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).