Beispiel #1
0
        protected virtual CryptoStream CreateDecryptingStream(
            Stream encryptedStream)
        {
            if (encryptedStream == null)
            {
                throw new ArgumentNullException(nameof(encryptedStream));
            }
            if (!encryptedStream.CanRead)
            {
                throw new ArgumentException(Resources.StreamNotReadable, nameof(encryptedStream));
            }
            if (!IsSymmetricKeyInitialized)
            {
                throw new InvalidOperationException(Resources.UninitializedSymmetricKey);
            }

            return(new CryptoStream(
                       encryptedStream,
                       Symmetric.CreateDecryptor(),
                       CryptoStreamMode.Read));
        }