Exemplo n.º 1
0
 // Create an instance of the default DSA implementation.
 public new static DSA Create()
 {
     return((DSA)(CryptoConfig.CreateFromName
                      (CryptoConfig.DSADefault, null)));
 }
Exemplo n.º 2
0
 public static new DES?Create(string algName)
 {
     return((DES?)CryptoConfig.CreateFromName(algName));
 }
Exemplo n.º 3
0
        public static new ECDsa?Create(string algorithm)
        {
            ArgumentNullException.ThrowIfNull(algorithm);

            return(CryptoConfig.CreateFromName(algorithm) as ECDsa);
        }
Exemplo n.º 4
0
 public static new RSA Create(String algName)
 {
     return((RSA)CryptoConfig.CreateFromName(algName));
 }
Exemplo n.º 5
0
 static public HashAlgorithm Create(String hashName)
 {
     return((HashAlgorithm)CryptoConfig.CreateFromName(hashName));
 }
Exemplo n.º 6
0
 public static new SHA1 Create(string hashName)
 {
     return((SHA1)CryptoConfig.CreateFromName(hashName));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Создание объекта, реализуещего алгоритм шифрования ГОСТ-28147.
 /// </summary>
 ///
 /// <returns>Криптографический объект, реализующий алгоритм ГОСТ
 /// 28147.</returns>
 ///
 /// <remarks><para>Создание объекта алгоритма шифрования ГОСТ 28147.
 /// Объект может использоваться
 /// для симметричного зашифрования и расшифрования.</para></remarks>
 ///
 ///// <doc-sample path="Simple\Encrypt" name="EncryptDecryptRandomFile"
 ///// region="EncryptDecryptRandomFile">Пример зашифрования и
 ///// расшифрования файла при помощи
 /////  порожденного класса <see cref="Gost28147CryptoServiceProvider"/>.
 /////  </doc-sample>
 public new static Gost28147 Create()
 {
     // Создание объекта идет по конфигурации для алгоритма заданного
     // полным именем класса Gost28147.
     return((Gost28147)CryptoConfig.CreateFromName(typeof(Gost28147).Name));
 }
Exemplo n.º 8
0
 // Create a symmetric algorithm object.
 public static SymmetricAlgorithm Create()
 {
     return((SymmetricAlgorithm)
            (CryptoConfig.CreateFromName
                 (CryptoConfig.SymmetricDefault, null)));
 }
Exemplo n.º 9
0
 public static new Rijndael?Create(string algName)
 {
     return((Rijndael?)CryptoConfig.CreateFromName(algName));
 }
Exemplo n.º 10
0
 /// <summary>Creates an instance of the specified implementation of a keyed hash algorithm.</summary>
 /// <returns>A new instance of the specified keyed hash algorithm.</returns>
 /// <param name="algName">The keyed hash algorithm implementation to use. The following table shows the valid values for the <paramref name="algName" /> parameter and the algorithms they map to.Parameter valueImplements System.Security.Cryptography.HMAC<see cref="T:System.Security.Cryptography.HMACSHA1" />System.Security.Cryptography.KeyedHashAlgorithm<see cref="T:System.Security.Cryptography.HMACSHA1" />HMACMD5<see cref="T:System.Security.Cryptography.HMACMD5" />System.Security.Cryptography.HMACMD5<see cref="T:System.Security.Cryptography.HMACMD5" />HMACRIPEMD160<see cref="T:System.Security.Cryptography.HMACRIPEMD160" />System.Security.Cryptography.HMACRIPEMD160<see cref="T:System.Security.Cryptography. HMACRIPEMD160" />HMACSHA1<see cref="T:System.Security.Cryptography.HMACSHA1" />System.Security.Cryptography.HMACSHA1<see cref="T:System.Security.Cryptography. HMACSHA1" />HMACSHA256<see cref="T:System.Security.Cryptography.HMACSHA256" />System.Security.Cryptography.HMACSHA256<see cref="T:System.Security.Cryptography.HMACSHA256" />HMACSHA384<see cref="T:System.Security.Cryptography.HMACSHA384" />System.Security.Cryptography.HMACSHA384<see cref="T:System.Security.Cryptography.HMACSHA384" />HMACSHA512<see cref="T:System.Security.Cryptography.HMACSHA512" />System.Security.Cryptography.HMACSHA512<see cref="T:System.Security.Cryptography.HMACSHA512" />MACTripleDES<see cref="T:System.Security.Cryptography. MACTripleDES" />System.Security.Cryptography.MACTripleDES<see cref="T:System.Security.Cryptography.MACTripleDES" /></param>
 public new static KeyedHashAlgorithm Create(string algName)
 {
     return((KeyedHashAlgorithm)CryptoConfig.CreateFromName(algName));
 }
Exemplo n.º 11
0
 public new static SHA384 Create(String algName)
 {
     return((SHA384)(CryptoConfig.CreateFromName(algName, null)));
 }
Exemplo n.º 12
0
 // Create a new instance of the "SHA384" class.
 public new static SHA384 Create()
 {
     return((SHA384)(CryptoConfig.CreateFromName
                         (CryptoConfig.SHA384Default, null)));
 }
Exemplo n.º 13
0
 public static new RC2 Create(string AlgName)
 {
     return((RC2)CryptoConfig.CreateFromName(AlgName));
 }
Exemplo n.º 14
0
 public DSASignatureDeformatter()
 {
     this._oid = CryptoConfig.MapNameToOID("SHA1");
 }
Exemplo n.º 15
0
 /// <summary>
 /// Создание объекта, реализующего алгоритм шифрования ГОСТ-28147
 /// с заданным именем реализации.
 /// </summary>
 ///
 /// <param name="algName">Имя реализации алгоритма.</param>
 ///
 /// <returns>Криптографический объект, реализующий алгоритм
 /// ГОСТ 28147.</returns>
 ///
 ///// <doc-sample path="Simple\Encrypt" name="EncryptDecryptRandomFile"
 ///// region="EncryptDecryptRandomFile">Пример зашифрования и
 ///// расшифрования файла при помощи
 /////  порожденного класса <see cref="Gost28147CryptoServiceProvider"/>.
 /////  </doc-sample>
 public new static Gost28147 Create(string algName)
 {
     // Создание объекта идет по конфигурации для алгоритма заданного
     // параметром.
     return((Gost28147)CryptoConfig.CreateFromName(algName));
 }
Exemplo n.º 16
0
 /// <include file='doc\SHA1.uex' path='docs/doc[@for="SHA1.Create1"]/*' />
 new static public SHA1 Create(String hashName)
 {
     return((SHA1)CryptoConfig.CreateFromName(hashName));
 }
Exemplo n.º 17
0
 new static public TripleDES Create(String str)
 {
     return((TripleDES)CryptoConfig.CreateFromName(str));
 }
Exemplo n.º 18
0
 public static new TripleDES?Create(string str)
 {
     return((TripleDES?)CryptoConfig.CreateFromName(str));
 }
 /// <summary>
 /// Creates an instance of the specified implementation of the <see cref="RIPEMD160"/> hash algorithm.
 /// </summary>
 /// <param name="hashName">The name of the specific implementation of RIPEMD160 to use.</param>
 /// <returns>A new instance of the specified implementation of RIPEMD160.</returns>
 public static new RIPEMD160 Create(string hashName)
 {
     return((RIPEMD160)CryptoConfig.CreateFromName(hashName));
 }
Exemplo n.º 20
0
Arquivo: Aes.cs Projeto: yonder/mono
 public static new Aes Create(string algName)
 {
     return((Aes)CryptoConfig.CreateFromName(algName));
 }
Exemplo n.º 21
0
 public static new MD5?Create(string algName) => (MD5?)CryptoConfig.CreateFromName(algName);
Exemplo n.º 22
0
 public static new MD5 Create(string algName)
 {
     return((MD5)CryptoConfig.CreateFromName(algName));
 }
Exemplo n.º 23
0
 new static public DSA Create(String algName)
 {
     return((DSA)CryptoConfig.CreateFromName(algName));
 }
Exemplo n.º 24
0
 public static SymmetricAlgorithm Create(string algName)
 {
     return((SymmetricAlgorithm)CryptoConfig.CreateFromName(algName));
 }
 /// <include file='doc\RandomNumberGenerator.uex' path='docs/doc[@for="RandomNumberGenerator.Create1"]/*' />
 static public RandomNumberGenerator Create(String rngName)
 {
     return((RandomNumberGenerator)CryptoConfig.CreateFromName(rngName));
 }
Exemplo n.º 26
0
 public static new SHA1 Create(string hashName) => (SHA1)CryptoConfig.CreateFromName(hashName);
Exemplo n.º 27
0
        /// <include file='doc\RSAPKCS1SignatureFormatter.uex' path='docs/doc[@for="RSAPKCS1SignatureFormatter.CreateSignature"]/*' />
        public override byte[] CreateSignature(byte[] rgbHash)
        {
            byte[] rgbSig;

            if (_strOID == null)
            {
                throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingOID"));
            }
            if (_rsaKey == null)
            {
                throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_MissingKey"));
            }
            if (rgbHash == null)
            {
                throw new ArgumentNullException("rgbHash");
            }

            //
            // Two cases here -- if we are talking to the CSP version or
            //      if we are talking to some other RSA provider.
            //

            if (_rsaKey is RSACryptoServiceProvider)
            {
                rgbSig = ((RSACryptoServiceProvider)_rsaKey).SignHash(rgbHash, _strOID);
            }
            else
            {
                int    cb = _rsaKey.KeySize / 8;
                int    cb1;
                int    i;
                byte[] rgbInput = new byte[cb];
                byte[] rgbOid   = CryptoConfig.EncodeOID(_strOID);
                int    lenOid   = rgbOid.Length;

                //
                //  We want to pad this to the following format:
                //
                //  00 || 01 || FF ... FF || 00 || prefix || Data
                //
                // We want basically to ASN 1 encode the OID + hash:
                // STRUCTURE {
                //  STRUCTURE {
                //	OID <hash algorithm OID>
                //	NULL (0x05 0x00)  // this is actually an ANY and contains the parameters of the algorithm specified by the OID, I think
                //  }
                //  OCTET STRING <hashvalue>
                // }
                //

                // Get the correct prefix
                byte[] rgbPrefix = new byte[lenOid + 8 + rgbHash.Length];
                rgbPrefix[0] = 0x30;                 // a structure follows
                int tmp = rgbPrefix.Length - 2;
                rgbPrefix[1] = (byte)tmp;
                rgbPrefix[2] = 0x30;
                tmp          = rgbOid.Length + 2;
                rgbPrefix[3] = (byte)tmp;
                Buffer.InternalBlockCopy(rgbOid, 0, rgbPrefix, 4, lenOid);
                rgbPrefix[4 + lenOid]     = 0x05;
                rgbPrefix[4 + lenOid + 1] = 0x00;
                rgbPrefix[4 + lenOid + 2] = 0x04;                 // an octet string follows
                rgbPrefix[4 + lenOid + 3] = (byte)rgbHash.Length;
                Buffer.InternalBlockCopy(rgbHash, 0, rgbPrefix, lenOid + 8, rgbHash.Length);

                // Construct the whole array
                cb1 = cb - rgbHash.Length - rgbPrefix.Length;
                if (cb1 <= 2)
                {
                    throw new CryptographicUnexpectedOperationException(Environment.GetResourceString("Cryptography_InvalidOID"));
                }

                rgbInput[0] = 0;
                rgbInput[1] = 1;
                for (i = 2; i < cb1 - 1; i++)
                {
                    rgbInput[i] = 0xff;
                }
                rgbInput[cb1 - 1] = 0;
                Buffer.InternalBlockCopy(rgbPrefix, 0, rgbInput, cb1, rgbPrefix.Length);
                Buffer.InternalBlockCopy(rgbHash, 0, rgbInput, cb1 + rgbPrefix.Length, rgbHash.Length);

                //
                //  Create the signature by applying the private key to
                //      the padded buffer we just created.
                //

                rgbSig = _rsaKey.DecryptValue(rgbInput);
            }

            return(rgbSig);
        }
Exemplo n.º 28
0
 // Create an instance of a specific DSA implementation, by name.
 public new static DSA Create(String algName)
 {
     return((DSA)(CryptoConfig.CreateFromName(algName, null)));
 }
Exemplo n.º 29
0
 public override void SetHashAlgorithm(String strName)
 {
     _strOID = CryptoConfig.MapNameToOID(strName, OidGroup.HashAlgorithm);
 }
Exemplo n.º 30
0
	public void CCToString () 
	{
		// under normal circumstance there are no need to create a CryptoConfig object
		// because all interesting stuff are in static methods
		CryptoConfig cc = new CryptoConfig ();
		Assert.AreEqual ("System.Security.Cryptography.CryptoConfig", cc.ToString ());
	}
 public virtual HashAlgorithm CreateDigest()
 {
     return((HashAlgorithm)CryptoConfig.CreateFromName(_strDigest));
 }