mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Trim
This commit is contained in:
parent
842c968220
commit
4757c4be53
8 changed files with 97 additions and 189 deletions
|
|
@ -8,17 +8,24 @@ namespace MinecraftClient.Crypto
|
|||
{
|
||||
// Using the AES-NI instruction set
|
||||
// https://gist.github.com/Thealexbarney/9f75883786a9f3100408ff795fb95d85
|
||||
public class AesContext
|
||||
public class FastAes
|
||||
{
|
||||
private Vector128<byte>[] RoundKeys { get; }
|
||||
|
||||
public byte[] Iv { get; } = new byte[0x10];
|
||||
|
||||
public AesContext(Span<byte> key)
|
||||
public FastAes(Span<byte> key)
|
||||
{
|
||||
RoundKeys = KeyExpansion(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detects if the required instruction set is supported
|
||||
/// </summary>
|
||||
/// <returns>Is it supported</returns>
|
||||
public static bool IsSupport()
|
||||
{
|
||||
return Sse2.IsSupported && Aes.IsSupported;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public void EncryptEcb(ReadOnlySpan<byte> plaintext, Span<byte> destination)
|
||||
{
|
||||
|
|
@ -88,10 +95,5 @@ namespace MinecraftClient.Crypto
|
|||
|
||||
keys[i] = Sse2.Xor(s, t);
|
||||
}
|
||||
|
||||
public void SetIv(Span<byte> iv)
|
||||
{
|
||||
iv.Slice(0, 0x10).CopyTo(Iv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue