Fix bug in updating the AES-CTR counter

This commit is contained in:
Alex Barney 2018-09-15 15:55:50 -05:00
parent 1f62706d4c
commit 77dc8fb9a1

View file

@ -85,11 +85,15 @@ namespace LibHac
private void UpdateCounter(long offset)
{
ulong off = (ulong)offset >> 4;
for (uint j = 0; j < 0x8; j++)
for (uint j = 0; j < 0x7; j++)
{
Counter[0x10 - j - 1] = (byte)(off & 0xFF);
off >>= 8;
}
// Because the value stored in the counter is offset >> 4, the top 4 bits
// of byte 8 need to have their original value preserved
Counter[8] = (byte)((Counter[8] & 0xF0) | (int)(off & 0x0F));
}
public override void Flush()