FindDefaultKeySize() private static method

private static FindDefaultKeySize ( string canonicalName ) : int
canonicalName string
return int
Ejemplo n.º 1
0
        public static CipherKeyGenerator GetKeyGenerator(string algorithm)
        {
            string canonicalKeyGeneratorAlgorithm = GeneratorUtilities.GetCanonicalKeyGeneratorAlgorithm(algorithm);

            if (canonicalKeyGeneratorAlgorithm == null)
            {
                throw new SecurityUtilityException("KeyGenerator " + algorithm + " not recognised.");
            }
            int num = GeneratorUtilities.FindDefaultKeySize(canonicalKeyGeneratorAlgorithm);

            if (num == -1)
            {
                throw new SecurityUtilityException(string.Concat(new string[]
                {
                    "KeyGenerator ",
                    algorithm,
                    " (",
                    canonicalKeyGeneratorAlgorithm,
                    ") not supported."
                }));
            }
            if (canonicalKeyGeneratorAlgorithm == "DES")
            {
                return(new DesKeyGenerator(num));
            }
            if (canonicalKeyGeneratorAlgorithm == "DESEDE" || canonicalKeyGeneratorAlgorithm == "DESEDE3")
            {
                return(new DesEdeKeyGenerator(num));
            }
            return(new CipherKeyGenerator(num));
        }
Ejemplo n.º 2
0
        internal static int GetDefaultKeySize(string algorithm)
        {
            string canonicalKeyGeneratorAlgorithm = GeneratorUtilities.GetCanonicalKeyGeneratorAlgorithm(algorithm);

            if (canonicalKeyGeneratorAlgorithm == null)
            {
                throw new SecurityUtilityException("KeyGenerator " + algorithm + " not recognised.");
            }
            int num = GeneratorUtilities.FindDefaultKeySize(canonicalKeyGeneratorAlgorithm);

            if (num == -1)
            {
                throw new SecurityUtilityException(string.Concat(new string[]
                {
                    "KeyGenerator ",
                    algorithm,
                    " (",
                    canonicalKeyGeneratorAlgorithm,
                    ") not supported."
                }));
            }
            return(num);
        }