private void OpenKey(IntPtr algorithm, byte[] key, int effectiveKeyLength) { _ctx = Interop.Crypto.EvpCipherCreate( algorithm, ref MemoryMarshal.GetReference(key.AsSpan()), key.Length * 8, effectiveKeyLength, ref MemoryMarshal.GetReference(IV.AsSpan()), _encrypting ? 1 : 0); Interop.Crypto.CheckValidOpenSslHandle(_ctx); // OpenSSL will happily do PKCS#7 padding for us, but since we support padding modes // that it doesn't (PaddingMode.Zeros) we'll just always pad the blocks ourselves. CheckBoolReturn(Interop.Crypto.EvpCipherCtxSetPadding(_ctx, 0)); }