GetMac() публичный статический Метод

/// Returns a ObjectIdentifier for a given digest mechanism. ///
public static GetMac ( DerObjectIdentifier id ) : IMac
id Org.BouncyCastle.Asn1.DerObjectIdentifier
Результат IMac
Пример #1
0
        public static object CreateEngine(string algorithm)
        {
            string text = (string)algorithms.get_Item((object)Platform.ToUpperInvariant(algorithm));

            if (Platform.StartsWith(text, "PBEwithHmac"))
            {
                string text2 = text.Substring("PBEwithHmac".get_Length());
                return(MacUtilities.GetMac("HMAC/" + text2));
            }
            if (Platform.StartsWith(text, "PBEwithMD2") || Platform.StartsWith(text, "PBEwithMD5") || Platform.StartsWith(text, "PBEwithSHA-1") || Platform.StartsWith(text, "PBEwithSHA-256"))
            {
                if (Platform.EndsWith(text, "AES-CBC-BC") || Platform.EndsWith(text, "AES-CBC-OPENSSL"))
                {
                    return(CipherUtilities.GetCipher("AES/CBC"));
                }
                if (Platform.EndsWith(text, "DES-CBC"))
                {
                    return(CipherUtilities.GetCipher("DES/CBC"));
                }
                if (Platform.EndsWith(text, "DESEDE-CBC"))
                {
                    return(CipherUtilities.GetCipher("DESEDE/CBC"));
                }
                if (Platform.EndsWith(text, "RC2-CBC"))
                {
                    return(CipherUtilities.GetCipher("RC2/CBC"));
                }
                if (Platform.EndsWith(text, "RC4"))
                {
                    return(CipherUtilities.GetCipher("RC4"));
                }
            }
            return(null);
        }
Пример #2
0
        public static object CreateEngine(string algorithm)
        {
            string text = (string)PbeUtilities.algorithms[Platform.ToUpperInvariant(algorithm)];

            if (text.StartsWith("PBEwithHmac"))
            {
                string str = text.Substring("PBEwithHmac".Length);
                return(MacUtilities.GetMac("HMAC/" + str));
            }
            if (text.StartsWith("PBEwithMD2") || text.StartsWith("PBEwithMD5") || text.StartsWith("PBEwithSHA-1") || text.StartsWith("PBEwithSHA-256"))
            {
                if (text.EndsWith("AES-CBC-BC") || text.EndsWith("AES-CBC-OPENSSL"))
                {
                    return(CipherUtilities.GetCipher("AES/CBC"));
                }
                if (text.EndsWith("DES-CBC"))
                {
                    return(CipherUtilities.GetCipher("DES/CBC"));
                }
                if (text.EndsWith("DESEDE-CBC"))
                {
                    return(CipherUtilities.GetCipher("DESEDE/CBC"));
                }
                if (text.EndsWith("RC2-CBC"))
                {
                    return(CipherUtilities.GetCipher("RC2/CBC"));
                }
                if (text.EndsWith("RC4"))
                {
                    return(CipherUtilities.GetCipher("RC4"));
                }
            }
            return(null);
        }
Пример #3
0
        public static object CreateEngine(
            string algorithm)
        {
            string mechanism = (string)algorithms[Platform.ToUpperInvariant(algorithm)];

            if (Platform.StartsWith(mechanism, "PBEwithHmac"))
            {
                string digestName = mechanism.Substring("PBEwithHmac".Length);

                return(MacUtilities.GetMac("HMAC/" + digestName));
            }

            if (Platform.StartsWith(mechanism, "PBEwithMD2") ||
                Platform.StartsWith(mechanism, "PBEwithMD5") ||
                Platform.StartsWith(mechanism, "PBEwithSHA-1") ||
                Platform.StartsWith(mechanism, "PBEwithSHA-256"))
            {
                if (Platform.EndsWith(mechanism, "AES-CBC-BC") || Platform.EndsWith(mechanism, "AES-CBC-OPENSSL"))
                {
                    return(CipherUtilities.GetCipher("AES/CBC"));
                }

                if (Platform.EndsWith(mechanism, "DES-CBC"))
                {
                    return(CipherUtilities.GetCipher("DES/CBC"));
                }

                if (Platform.EndsWith(mechanism, "DESEDE-CBC"))
                {
                    return(CipherUtilities.GetCipher("DESEDE/CBC"));
                }

                if (Platform.EndsWith(mechanism, "RC2-CBC"))
                {
                    return(CipherUtilities.GetCipher("RC2/CBC"));
                }

                if (Platform.EndsWith(mechanism, "RC4"))
                {
                    return(CipherUtilities.GetCipher("RC4"));
                }
            }

            return(null);
        }
Пример #4
0
        public static object CreateEngine(
            string algorithm)
        {
            //TODO: SUSTITUIDO
            //string mechanism = (string)algorithms[algorithm.ToUpper(CultureInfo.InvariantCulture)];
            string mechanism = (string)algorithms[algorithm.ToUpper()];

            if (mechanism.StartsWith("PBEwithHmac"))
            {
                string digestName = mechanism.Substring("PBEwithHmac".Length);

                return(MacUtilities.GetMac("HMAC/" + digestName));
            }

            if (mechanism.StartsWith("PBEwithMD2") ||
                mechanism.StartsWith("PBEwithMD5") ||
                mechanism.StartsWith("PBEwithSHA-1"))
            {
                if (mechanism.EndsWith("RC2-CBC"))
                {
                    return(CipherUtilities.GetCipher("RC2/CBC"));
                }

                if (mechanism.EndsWith("RC4"))
                {
                    return(CipherUtilities.GetCipher("RC4"));
                }

                if (mechanism.EndsWith("DES-CBC"))
                {
                    return(CipherUtilities.GetCipher("DES/CBC"));
                }

                if (mechanism.EndsWith("DESEDE-CBC"))
                {
                    return(CipherUtilities.GetCipher("DESEDE/CBC"));
                }
            }

            return(null);
        }
Пример #5
0
 public static IMac GetMac(DerObjectIdentifier id)
 {
     return MacUtilities.GetMac(id.Id);
 }