diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-10 14:55:00 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-10 14:55:00 +0700 |
commit | 6a948eb427afc513c0c12a054e9a2635cc66da3a (patch) | |
tree | cb2a0cf61e5d9fa20159fb4e10946cdcf8138820 /crypto | |
parent | Fix Haraka digest API compliance (diff) | |
download | BouncyCastle.NET-ed25519-6a948eb427afc513c0c12a054e9a2635cc66da3a.tar.xz |
Fix Harakas XOF API compliance
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/pqc/crypto/sphincsplus/HarakaSXof.cs | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/crypto/src/pqc/crypto/sphincsplus/HarakaSXof.cs b/crypto/src/pqc/crypto/sphincsplus/HarakaSXof.cs index 210ac35e1..86c2f8fbb 100644 --- a/crypto/src/pqc/crypto/sphincsplus/HarakaSXof.cs +++ b/crypto/src/pqc/crypto/sphincsplus/HarakaSXof.cs @@ -54,30 +54,27 @@ namespace Org.BouncyCastle.Pqc.Crypto.SphincsPlus public int DoFinal(byte[] output, int outOff, int len) { int outLen = len; + //Finalize buffer[off] ^= 0x1F; buffer[31] ^= 128; - off = 0; + //Squeeze - while (len > 0) + while (len >= 32) { Haraka512Perm(buffer); - int i = 0; - while (i < 32 && i + outOff < output.Length) - { - output[i + outOff] = buffer[i]; - i++; - } - outOff += i; - len -= i; + Array.Copy(buffer, 0, output, outOff, 32); + outOff += 32; + len -= 32; } - if (len != 0) + if (len > 0) { - byte[] d = new byte[64]; - Haraka512Perm(d); - Array.Copy(d, 0, output, outOff, -len); + Haraka512Perm(buffer); + Array.Copy(buffer, 0, output, outOff, len); } + Reset(); + return outLen; } } |