Example #1
0
 SafeAlgorithmHandle ICngSymmetricAlgorithm.GetEphemeralModeHandle(CipherMode mode, int feedbackSizeInBits)
 {
     try
     {
         return(AesBCryptModes.GetSharedHandle(mode, feedbackSizeInBits / 8));
     }
     catch (NotSupportedException)
     {
         throw new CryptographicException(SR.Cryptography_InvalidCipherMode);
     }
 }
        private static UniversalCryptoTransform CreateTransformCore(
            CipherMode cipherMode,
            PaddingMode paddingMode,
            byte[] key,
            byte[]?iv,
            int blockSize,
            int paddingSize,
            int feedbackSize,
            bool encrypting)
        {
            SafeAlgorithmHandle algorithm = AesBCryptModes.GetSharedHandle(cipherMode, feedbackSize);

            BasicSymmetricCipher cipher = new BasicSymmetricCipherBCrypt(algorithm, cipherMode, blockSize, paddingSize, key, false, iv, encrypting);

            return(UniversalCryptoTransform.Create(paddingMode, cipher, encrypting));
        }
        private static ILiteSymmetricCipher CreateLiteCipher(
            CipherMode cipherMode,
            ReadOnlySpan <byte> key,
            ReadOnlySpan <byte> iv,
            int blockSize,
            int paddingSize,
            int feedbackSize,
            bool encrypting)
        {
            SafeAlgorithmHandle algorithm = AesBCryptModes.GetSharedHandle(cipherMode, feedbackSize);

            return(new BasicSymmetricCipherLiteBCrypt(
                       algorithm,
                       cipherMode,
                       blockSize,
                       paddingSize,
                       key,
                       ownsParentHandle: false,
                       iv,
                       encrypting));
        }
Example #4
0
 SafeAlgorithmHandle ICngSymmetricAlgorithm.GetEphemeralModeHandle()
 {
     return(AesBCryptModes.GetSharedHandle(Mode));
 }