mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Fix bug in updating the AES-CTR counter
This commit is contained in:
parent
1f62706d4c
commit
77dc8fb9a1
1 changed files with 5 additions and 1 deletions
|
@ -85,11 +85,15 @@ namespace LibHac
|
||||||
private void UpdateCounter(long offset)
|
private void UpdateCounter(long offset)
|
||||||
{
|
{
|
||||||
ulong off = (ulong)offset >> 4;
|
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);
|
Counter[0x10 - j - 1] = (byte)(off & 0xFF);
|
||||||
off >>= 8;
|
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()
|
public override void Flush()
|
||||||
|
|
Loading…
Reference in a new issue