public GcmCryptoModeBlock16X86(IBlockCrypto crypto, IBlockCrypto crypto16) { if (crypto.BlockSize is not BlockSize) { throw new ArgumentException($@"Crypto block size must be {BlockSize} bytes.", nameof(crypto)); } if (crypto16.BlockSize is not BlockSize16) { throw new ArgumentException($@"Crypto block size must be {BlockSize16} bytes.", nameof(crypto16)); } _crypto = crypto; _crypto16 = crypto16; _buffer = ArrayPool <byte> .Shared.Rent(BlockSize16); _tagBuffer = ArrayPool <byte> .Shared.Rent(TagSize); _counterBlock = ArrayPool <byte> .Shared.Rent(BlockSize16); Span <byte> key = _buffer.AsSpan(0, 16); _crypto.Encrypt(Init, key); _gHash = GHashUtils.Create(key); }
public void Test(string keyHex, string plainHex, string cipherHex) { var key = keyHex.FromHex(); Test(new GHashSF(key), plainHex, cipherHex); Test(new GHashX86(key), plainHex, cipherHex); Test(GHashUtils.Create(key), plainHex, cipherHex); }
public GcmCryptoMode(IBlockCrypto crypto) { if (crypto.BlockSize is not BlockSize) { throw new ArgumentException($@"Crypto block size must be {BlockSize} bytes.", nameof(crypto)); } _crypto = crypto; _buffer = ArrayPool <byte> .Shared.Rent(BlockSize); _tagBuffer = ArrayPool <byte> .Shared.Rent(TagSize); _counterBlock = ArrayPool <byte> .Shared.Rent(BlockSize); _crypto.Encrypt(Init, _buffer); _gHash = GHashUtils.Create(_buffer); }