コード例 #1
0
 /// <summary>Gets a value indicating whether the specified algorithm requires an initialization vector.</summary>
 /// <param name="algorithm">The algorithm to check.</param>
 /// <returns><c>true</c> if the block mode uses an initialization vector; <c>false</c> otherwise.</returns>
 public static bool UsesIV(this SymmetricAlgorithm algorithm) => UsesIV(algorithm.GetMode());
コード例 #2
0
        /// <summary>
        /// Returns a crypto key management for a specified algorithm.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="algorithm">The algorithm.</param>
        /// <returns>An instance of <see cref="ISymmetricKeyAlgorithmProvider"/>.</returns>
        public static ISymmetricKeyAlgorithmProvider OpenAlgorithm(this ISymmetricKeyAlgorithmProviderFactory factory, SymmetricAlgorithm algorithm)
        {
            Requires.NotNull(factory, nameof(factory));

            return(factory.OpenAlgorithm(algorithm.GetName(), algorithm.GetMode(), algorithm.GetPadding()));
        }
コード例 #3
0
 /// <summary>Gets a value indicating whether the specified algorithm is implemented by a block cipher.</summary>
 /// <param name="algorithm">The algorithm to check.</param>
 /// <returns><c>true</c> if the cipher is a block cipher; <c>false</c> otherwise.</returns>
 public static bool IsBlockCipher(this SymmetricAlgorithm algorithm)
 {
     return(algorithm.GetMode() != SymmetricAlgorithmMode.Streaming);
 }
コード例 #4
0
        /// <summary>
        /// Returns a crypto key management for a specified algorithm.
        /// </summary>
        /// <param name="factory">The factory.</param>
        /// <param name="algorithm">The algorithm.</param>
        /// <returns>An instance of <see cref="ISymmetricKeyAlgorithmProvider"/>.</returns>
        public static ISymmetricKeyAlgorithmProvider OpenAlgorithm(this ISymmetricKeyAlgorithmProviderFactory factory, SymmetricAlgorithm algorithm)
        {
            Requires.NotNull(factory, nameof(factory));

            return factory.OpenAlgorithm(algorithm.GetName(), algorithm.GetMode(), algorithm.GetPadding());
        }