GetCanonicalKeyPairGeneratorAlgorithm() static private method

static private GetCanonicalKeyPairGeneratorAlgorithm ( string algorithm ) : string
algorithm string
return string
Ejemplo n.º 1
0
        public static IAsymmetricCipherKeyPairGenerator GetKeyPairGenerator(string algorithm)
        {
            string canonicalKeyPairGeneratorAlgorithm = GeneratorUtilities.GetCanonicalKeyPairGeneratorAlgorithm(algorithm);

            if (canonicalKeyPairGeneratorAlgorithm == null)
            {
                throw new SecurityUtilityException("KeyPairGenerator " + algorithm + " not recognised.");
            }
            if (canonicalKeyPairGeneratorAlgorithm == "DH")
            {
                return(new DHKeyPairGenerator());
            }
            if (canonicalKeyPairGeneratorAlgorithm == "DSA")
            {
                return(new DsaKeyPairGenerator());
            }
            if (canonicalKeyPairGeneratorAlgorithm.StartsWith("EC"))
            {
                return(new ECKeyPairGenerator(canonicalKeyPairGeneratorAlgorithm));
            }
            if (canonicalKeyPairGeneratorAlgorithm == "ELGAMAL")
            {
                return(new ElGamalKeyPairGenerator());
            }
            if (canonicalKeyPairGeneratorAlgorithm == "GOST3410")
            {
                return(new Gost3410KeyPairGenerator());
            }
            if (canonicalKeyPairGeneratorAlgorithm == "RSA")
            {
                return(new RsaKeyPairGenerator());
            }
            throw new SecurityUtilityException(string.Concat(new string[]
            {
                "KeyPairGenerator ",
                algorithm,
                " (",
                canonicalKeyPairGeneratorAlgorithm,
                ") not supported."
            }));
        }