We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f875f97 commit d5f91e2Copy full SHA for d5f91e2
1 file changed
src/ff1.js
@@ -51,14 +51,13 @@ class FF1 {
51
const blocks = Math.ceil(d / 16);
52
const out = Buffer.alloc(blocks * 16);
53
R.copy(out, 0);
54
- let prev = Buffer.from(R);
55
for (let j = 1; j < blocks; j++) {
56
const x = Buffer.alloc(16);
57
x.writeBigUInt64BE(BigInt(j), 8);
58
- for (let k = 0; k < 16; k++) x[k] ^= prev[k];
+ // XOR with R (not previous block) per NIST SP 800-38G
+ for (let k = 0; k < 16; k++) x[k] ^= R[k];
59
const enc = this._aes(x);
60
enc.copy(out, j * 16);
61
- prev = enc;
62
}
63
return out.subarray(0, d);
64
0 commit comments