| author | |
| committer | |
| log | 3a07f50dabbda0532b9e87d76662d81a4740fe40 |
| tree | 51172b0f9080548d00b85d1f1b320a67a6cb2ee5 |
| parent | 858d7eda6550ebb80e96c92b82c2e17ca5107b29 |
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.1 files changed, 2 insertions(+), 9 deletions(-)
lib/std/crypto/ml_kem.zig+2-9| ... | ... | @@ -1725,15 +1725,8 @@ const NistDRBG = struct { |
| 1725 | 1725 | v: [16]u8, |
| 1726 | 1726 | |
| 1727 | 1727 | fn incV(g: *NistDRBG) void { |
| 1728 | var j: usize = 15; | |
| 1729 | while (j >= 0) : (j -= 1) { | |
| 1730 | if (g.v[j] == 255) { | |
| 1731 | g.v[j] = 0; | |
| 1732 | } else { | |
| 1733 | g.v[j] += 1; | |
| 1734 | break; | |
| 1735 | } | |
| 1736 | } | |
| 1728 | const val = std.mem.readInt(u128, &g.v, .big); | |
| 1729 | std.mem.writeInt(u128, &g.v, val +% 1, .big); | |
| 1737 | 1730 | } |
| 1738 | 1731 | |
| 1739 | 1732 | // AES256_CTR_DRBG_Update(pd, &g.key, &g.v). |