Esempio n. 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());
Esempio n. 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()));
        }
Esempio n. 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);
 }
Esempio n. 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());
        }