GetCanonicalKeyGeneratorAlgorithm() static private method

static private GetCanonicalKeyGeneratorAlgorithm ( string algorithm ) : string
algorithm string
return string
コード例 #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));
        }
コード例 #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);
        }