当前位置: 首页>>代码示例>>C#>>正文


C# IBlockCipher类代码示例

本文整理汇总了C#中IBlockCipher的典型用法代码示例。如果您正苦于以下问题:C# IBlockCipher类的具体用法?C# IBlockCipher怎么用?C# IBlockCipher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IBlockCipher类属于命名空间,在下文中一共展示了IBlockCipher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AESCipherCBCnoPad

 /** Creates a new instance of AESCipher */
 public AESCipherCBCnoPad(bool forEncryption, byte[] key)
 {
     IBlockCipher aes = new AesFastEngine();
     cbc = new CbcBlockCipher(aes);
     KeyParameter kp = new KeyParameter(key);
     cbc.Init(forEncryption, kp);
 }
开发者ID:jomamorales,项目名称:createPDF,代码行数:8,代码来源:AESCipher.cs

示例2: CMac

		/**
		* create a standard MAC based on a block cipher with the size of the
		* MAC been given in bits.
		* <p/>
		* Note: the size of the MAC must be at least 24 bits (FIPS Publication 81),
		* or 16 bits if being used as a data authenticator (FIPS Publication 113),
		* and in general should be less than the size of the block cipher as it reduces
		* the chance of an exhaustive attack (see Handbook of Applied Cryptography).
		*
		* @param cipher        the cipher to be used as the basis of the MAC generation.
		* @param macSizeInBits the size of the MAC in bits, must be a multiple of 8 and @lt;= 128.
		*/
		public CMac(
			IBlockCipher	cipher,
			int				macSizeInBits)
		{
			if ((macSizeInBits % 8) != 0)
				throw new ArgumentException("MAC size must be multiple of 8");

			if (macSizeInBits > (cipher.GetBlockSize() * 8))
			{
				throw new ArgumentException(
					"MAC size must be less or equal to "
						+ (cipher.GetBlockSize() * 8));
			}

			if (cipher.GetBlockSize() != 8 && cipher.GetBlockSize() != 16)
			{
				throw new ArgumentException(
					"Block size must be either 64 or 128 bits");
			}

			this.cipher = new CbcBlockCipher(cipher);
			this.macSize = macSizeInBits / 8;

			mac = new byte[cipher.GetBlockSize()];

			buf = new byte[cipher.GetBlockSize()];

			ZEROES = new byte[cipher.GetBlockSize()];

			bufOff = 0;
		}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:43,代码来源:CMac.cs

示例3: doWrapTest

		private void doWrapTest(
			int				id,
			IBlockCipher	engine,
			byte[]			kek,
			byte[]			iv,
			SecureRandom	rand,
			byte[]			inBytes,
			byte[]			outBytes)
		{
			IWrapper wrapper = new Rfc3211WrapEngine(engine);

			wrapper.Init(true, new ParametersWithRandom(
				new ParametersWithIV(new KeyParameter(kek), iv), rand));

			byte[] cText = wrapper.Wrap(inBytes, 0, inBytes.Length);
			if (!AreEqual(cText, outBytes))
			{
				Fail("failed Wrap test " + id  + " expected "
					+ Hex.ToHexString(outBytes) + " got " + Hex.ToHexString(cText));
			}

			wrapper.Init(false, new ParametersWithIV(new KeyParameter(kek), iv));

			byte[] pText = wrapper.Unwrap(outBytes, 0, outBytes.Length);
			if (!AreEqual(pText, inBytes))
			{
				Fail("rfailed Unwrap test " + id  + " expected "
					+ Hex.ToHexString(inBytes) + " got " + Hex.ToHexString(pText));
			}
		}
开发者ID:randombit,项目名称:hacrypto,代码行数:30,代码来源:RFC3211WrapTest.cs

示例4: BlockCipherMode

        protected BlockCipherMode(IBlockCipher cipher)
        {
            if (cipher == null)
                throw new ArgumentNullException("cipher", "Cipher cannot be null!");

            this.cipher = cipher;
        }
开发者ID:flowlo,项目名称:ecdh-aes-chat,代码行数:7,代码来源:BlockCipherMode.cs

示例5: CfbBlockCipherMac

 /**
 * create a standard MAC based on a block cipher with the size of the
 * MAC been given in bits. This class uses CFB mode as the basis for the
 * MAC generation.
 * <p>
 * Note: the size of the MAC must be at least 24 bits (FIPS Publication 81),
 * or 16 bits if being used as a data authenticator (FIPS Publication 113),
 * and in general should be less than the size of the block cipher as it reduces
 * the chance of an exhaustive attack (see Handbook of Applied Cryptography).
 * </p>
 * @param cipher the cipher to be used as the basis of the MAC generation.
 * @param cfbBitSize the size of an output block produced by the CFB mode.
 * @param macSizeInBits the size of the MAC in bits, must be a multiple of 8.
 */
 public CfbBlockCipherMac(
     IBlockCipher	cipher,
     int				cfbBitSize,
     int				macSizeInBits)
     : this(cipher, cfbBitSize, macSizeInBits, null)
 {
 }
开发者ID:bitcoinkit,项目名称:BitcoinKit-CSharp,代码行数:21,代码来源:CfbBlockCipherMac.cs

示例6: GCMCipher

        public GCMCipher(IBlockCipher cipher)
        {
            SecurityAssert.SAssert(cipher.BlockLength == 16);
            SecurityAssert.SAssert(cipher.KeyLength >= 16);

            Cipher = cipher;
            buffer = new byte[BlockLength];
        }
开发者ID:will14smith,项目名称:Crypto,代码行数:8,代码来源:GCMCipher.cs

示例7: SicBlockCipher

 /**
 * Basic constructor.
 *
 * @param c the block cipher to be used.
 */
 public SicBlockCipher(IBlockCipher cipher)
 {
     this.cipher = cipher;
     this.blockSize = cipher.GetBlockSize();
     this.IV = new byte[blockSize];
     this.counter = new byte[blockSize];
     this.counterOut = new byte[blockSize];
 }
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:13,代码来源:SicBlockCipher.cs

示例8: GcmBlockCipher

		// Debug variables
	//    private int nCount, xCount, yCount;

		public GcmBlockCipher(
			IBlockCipher c)
		{
			if (c.GetBlockSize() != BlockSize)
				throw new ArgumentException("cipher required with a block size of " + BlockSize + ".");

			this.cipher = c;
		}
开发者ID:pusp,项目名称:o2platform,代码行数:11,代码来源:GCMBlockCipher.cs

示例9: BlockCipherModeUsingInitializationVector

        protected BlockCipherModeUsingInitializationVector(IBlockCipher cipher, byte[] iv)
            : base(cipher)
        {
            if (iv == null)
                throw new ArgumentNullException("iv", "IV cannot be null!");

            this.iv = iv;
        }
开发者ID:flowlo,项目名称:ecdh-aes-chat,代码行数:8,代码来源:BlockCipherModeUsingInitializationVector.cs

示例10: Poly1305

 /**
  * Constructs a Poly1305 MAC, using a 128 bit block cipher.
  */
 public Poly1305(IBlockCipher cipher)
 {
     if (cipher.GetBlockSize() != BLOCK_SIZE)
     {
         throw new ArgumentException("Poly1305 requires a 128 bit block cipher.");
     }
     this.cipher = cipher;
 }
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:11,代码来源:Poly1305.cs

示例11: BufferedBlockCipher

        /**
        * Create a buffered block cipher without padding.
        *
        * @param cipher the underlying block cipher this buffering object wraps.
        * false otherwise.
        */
        public BufferedBlockCipher(IBlockCipher cipher)
        {
            if (cipher == null)
                throw new ArgumentNullException("cipher");

            this.Cipher = cipher;
            this.Buffer = new byte[cipher.GetBlockSize()];
            this.BufferOffset = 0;
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:15,代码来源:BufferedBlockCipher.cs

示例12: CipherTest

//		protected CipherTest(
//			SimpleTest[]	tests)
//		{
//			_tests = tests;
//		}

		protected CipherTest(
			SimpleTest[]	tests,
			IBlockCipher	engine,
			KeyParameter	validKey)
		{
			_tests = tests;
			_engine = engine;
			_validKey = validKey;
		}
开发者ID:randombit,项目名称:hacrypto,代码行数:15,代码来源:CipherTest.cs

示例13: initCipher

		private void initCipher(bool forEncryption, IBlockCipher cipher,
								byte[] key_block, int key_size, int key_offset, int iv_offset)
		{
			KeyParameter key_parameter = new KeyParameter(key_block, key_offset,
				key_size);
			ParametersWithIV parameters_with_iv = new ParametersWithIV(
				key_parameter, key_block, iv_offset, cipher.GetBlockSize());
			cipher.Init(forEncryption, parameters_with_iv);
		}
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:9,代码来源:TlsBlockCipherCipherSuite.cs

示例14: CcmBlockCipher

        /**
        * Basic constructor.
        *
        * @param cipher the block cipher to be used.
        */
        public CcmBlockCipher(
            IBlockCipher cipher)
        {
            this.cipher = cipher;
            this.macBlock = new byte[BlockSize];

            if (cipher.GetBlockSize() != BlockSize)
                throw new ArgumentException("cipher required with a block size of " + BlockSize + ".");
        }
开发者ID:ubberkid,项目名称:PeerATT,代码行数:14,代码来源:CcmBlockCipher.cs

示例15: CTR

 public static CTR @new(IBlockCipher cipher, _counter counter)
 {
     CTR ctr = new CTR();
      ctr.ucipher = cipher;
      ctr.counter = counter;
      ctr.counterOut = new byte[counter.Length];
      ctr.count = 0;
     return ctr;
 }
开发者ID:HarrisonW,项目名称:Pandoras-Box,代码行数:9,代码来源:CTR.cs


注:本文中的IBlockCipher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。