mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Improve AES key expansion performance
This commit is contained in:
parent
e02e719ea5
commit
3395ebff44
1 changed files with 4 additions and 2 deletions
|
@ -22,7 +22,7 @@ namespace LibHac.Crypto.Detail
|
|||
{
|
||||
Debug.Assert(key.Length == Aes.KeySize128);
|
||||
|
||||
KeyExpansion(key, MemoryMarshal.CreateSpan(ref _roundKeys, RoundKeyCount), isDecrypting);
|
||||
KeyExpansion(key, isDecrypting);
|
||||
}
|
||||
|
||||
public readonly ReadOnlySpan<Vector128<byte>> RoundKeys =>
|
||||
|
@ -447,8 +447,10 @@ namespace LibHac.Crypto.Detail
|
|||
out7 = AesNi.DecryptLast(b7, key);
|
||||
}
|
||||
|
||||
private static void KeyExpansion(ReadOnlySpan<byte> key, Span<Vector128<byte>> roundKeys, bool isDecrypting)
|
||||
private void KeyExpansion(ReadOnlySpan<byte> key, bool isDecrypting)
|
||||
{
|
||||
Span<Vector128<byte>> roundKeys = MemoryMarshal.CreateSpan(ref _roundKeys, RoundKeyCount);
|
||||
|
||||
var curKey = Unsafe.ReadUnaligned<Vector128<byte>>(ref MemoryMarshal.GetReference(key));
|
||||
roundKeys[0] = curKey;
|
||||
|
||||
|
|
Loading…
Reference in a new issue