示例#1
0
        private ICryptoTransform NewEncryptor(byte[] rgbKey,
                                              CipherMode mode,
                                              byte[] rgbIV,
                                              int feedbackSize,
                                              RijndaelManagedTransformMode encryptMode)
        {
            // Build the key if one does not already exist
            if (rgbKey == null)
            {
                rgbKey = Utils.GenerateRandom(KeySizeValue / 8);
            }

            // If not ECB mode, make sure we have an IV. In CoreCLR we do not support ECB, so we must have
            // an IV in all cases.
#if !FEATURE_CRYPTO
            if (mode != CipherMode.ECB)
            {
#endif // !FEATURE_CRYPTO
            if (rgbIV == null)
            {
                rgbIV = Utils.GenerateRandom(BlockSizeValue / 8);
            }
#if !FEATURE_CRYPTO
        }
#endif // !FEATURE_CRYPTO

            // Create the encryptor/decryptor object
            return(new RijndaelManagedTransform(rgbKey,
                                                mode,
                                                rgbIV,
                                                BlockSizeValue,
                                                feedbackSize,
                                                PaddingValue,
                                                encryptMode));
        }
 private ICryptoTransform NewEncryptor(byte[] rgbKey, CipherMode mode, byte[] rgbIV, int feedbackSize, RijndaelManagedTransformMode encryptMode)
 {
     if (rgbKey == null)
     {
         rgbKey = Utils.GenerateRandom(base.KeySizeValue / 8);
     }
     if (rgbIV == null)
     {
         rgbIV = Utils.GenerateRandom(base.BlockSizeValue / 8);
     }
     return(new RijndaelManagedTransform(rgbKey, mode, rgbIV, base.BlockSizeValue, feedbackSize, base.PaddingValue, encryptMode));
 }
示例#3
0
 public override void GenerateIV()
 {
     IVValue = Utils.GenerateRandom(BlockSizeValue / 8);
 }
示例#4
0
 public override void GenerateKey()
 {
     KeyValue = Utils.GenerateRandom(KeySizeValue / 8);
 }
 public HMACSHA512() : this(Utils.GenerateRandom(0x80))
 {
 }
示例#6
0
 /// <summary>使用随机生成的密钥初始化 <see cref="T:System.Security.Cryptography.HMACSHA1" /> 类的新实例。</summary>
 public HMACSHA1()
     : this(Utils.GenerateRandom(64))
 {
 }
 /// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.HMACSHA384" /> class by using a randomly generated key.</summary>
 // Token: 0x060021C4 RID: 8644 RVA: 0x000778DA File Offset: 0x00075ADA
 public HMACSHA384() : this(Utils.GenerateRandom(128))
 {
 }
示例#8
0
 /// <summary>使用随机生成的密钥初始化 <see cref="T:System.Security.Cryptography.HMACMD5" /> 类的新实例。</summary>
 public HMACMD5()
     : this(Utils.GenerateRandom(64))
 {
 }
示例#9
0
 /// <summary>用随机生成的 64 字节密钥初始化 <see cref="T:System.Security.Cryptography.HMACRIPEMD160" /> 类的新实例。</summary>
 public HMACRIPEMD160()
     : this(Utils.GenerateRandom(64))
 {
 }
 public HMACSHA256() : this(Utils.GenerateRandom(0x40))
 {
 }