Exemple #1
0
        protected override bool TryDecryptEcbCore(
            ReadOnlySpan <byte> ciphertext,
            Span <byte> destination,
            PaddingMode paddingMode,
            out int bytesWritten)
        {
            UniversalCryptoTransform transform = _core.CreateCryptoTransform(
                iv: null,
                encrypting: false,
                paddingMode,
                CipherMode.ECB);

            using (transform)
            {
                return(transform.TransformOneShot(ciphertext, destination, out bytesWritten));
            }
        }
Exemple #2
0
        protected override bool TryEncryptEcbCore(
            ReadOnlySpan <byte> plaintext,
            Span <byte> destination,
            PaddingMode paddingMode,
            out int bytesWritten)
        {
            UniversalCryptoTransform transform = _core.CreateCryptoTransform(
                iv: null,
                encrypting: true,
                paddingMode,
                CipherMode.ECB,
                feedbackSizeInBits: 0);

            using (transform)
            {
                return(transform.TransformOneShot(plaintext, destination, out bytesWritten));
            }
        }
Exemple #3
0
        protected override bool TryEncryptCbcCore(
            ReadOnlySpan <byte> plaintext,
            ReadOnlySpan <byte> iv,
            Span <byte> destination,
            PaddingMode paddingMode,
            out int bytesWritten)
        {
            UniversalCryptoTransform transform = _core.CreateCryptoTransform(
                iv: iv.ToArray(),
                encrypting: true,
                paddingMode,
                CipherMode.CBC);

            using (transform)
            {
                return(transform.TransformOneShot(plaintext, destination, out bytesWritten));
            }
        }
Exemple #4
0
        protected override bool TryDecryptCbcCore(
            ReadOnlySpan <byte> ciphertext,
            ReadOnlySpan <byte> iv,
            Span <byte> destination,
            PaddingMode paddingMode,
            out int bytesWritten)
        {
            UniversalCryptoTransform transform = _core.CreateCryptoTransform(
                iv: iv.ToArray(),
                encrypting: false,
                paddingMode,
                CipherMode.CBC,
                feedbackSizeInBits: 0);

            using (transform)
            {
                return(transform.TransformOneShot(ciphertext, destination, out bytesWritten));
            }
        }