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


C# IBlockCipher.GetBlockSize方法代码示例

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


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

示例1: 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

示例2: CfbBlockCipher

		/**
        * Basic constructor.
        *
        * @param cipher the block cipher to be used as the basis of the
        * feedback mode.
        * @param blockSize the block size in bits (note: a multiple of 8)
        */
        public CfbBlockCipher(
            IBlockCipher cipher,
            int          bitBlockSize)
        {
            this.cipher = cipher;
            this.blockSize = bitBlockSize / 8;
            this.IV = new byte[cipher.GetBlockSize()];
            this.cfbV = new byte[cipher.GetBlockSize()];
            this.cfbOutV = new byte[cipher.GetBlockSize()];
        }
开发者ID:ktw,项目名称:OutlookPrivacyPlugin,代码行数:17,代码来源:CfbBlockCipher.cs

示例3: X931Rng

        /**
         *
         * @param engine
         * @param entropySource
         */
        internal X931Rng(IBlockCipher engine, byte[] dateTimeVector, IEntropySource entropySource)
        {
            this.mEngine = engine;
            this.mEntropySource = entropySource;

            this.mDT = new byte[engine.GetBlockSize()];

            Array.Copy(dateTimeVector, 0, mDT, 0, mDT.Length);

            this.mI = new byte[engine.GetBlockSize()];
            this.mR = new byte[engine.GetBlockSize()];
        }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:17,代码来源:X931Rng.cs

示例4: Build

        /**
         * Construct a X9.31 secure random generator using the passed in engine and key. If predictionResistant is true the
         * generator will be reseeded on each request.
         *
         * @param engine a block cipher to use as the operator.
         * @param key the block cipher key to initialise engine with.
         * @param predictionResistant true if engine to be reseeded on each use, false otherwise.
         * @return a SecureRandom.
         */
        public X931SecureRandom Build(IBlockCipher engine, KeyParameter key, bool predictionResistant)
        {
            if (mDateTimeVector == null)
            {
                mDateTimeVector = new byte[engine.GetBlockSize()];
                Pack.UInt64_To_BE((ulong)DateTimeUtilities.CurrentUnixMs(), mDateTimeVector, 0);
            }

            engine.Init(true, key);

            return new X931SecureRandom(mRandom, new X931Rng(engine, mDateTimeVector, mEntropySourceProvider.Get(engine.GetBlockSize() * 8)), predictionResistant);
        }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:21,代码来源:X931SecureRandomBuilder.cs

示例5: CfbDCPCipher

		/**
        * Basic constructor.
        *
        * @param cipher the block cipher to be used as the basis of the
        * feedback mode.
        * @param blockSize the block size in bits (note: a multiple of 8)
        */
        public CfbDCPCipher(
            IBlockCipher cipher,
            int          bitBlockSize)
        {
            if (bitBlockSize != 8)
                throw new SystemException("Block size should be 8");
            this.cipher = cipher;
            this.blockSize = bitBlockSize / 8;
            this.IV = new byte[cipher.GetBlockSize()];
            this.cfbV = new byte[cipher.GetBlockSize()];
            this.cfbOutV = new byte[cipher.GetBlockSize()];
        }
开发者ID:AndreyRepko,项目名称:Org.BouncyCastle.Utilities,代码行数:19,代码来源:Cfb8bitCipher.cs

示例6: GOfbBlockCipher

		const int C2 = 16843009; //00000001000000010000000100000001

		/**
		* Basic constructor.
		*
		* @param cipher the block cipher to be used as the basis of the
		* counter mode (must have a 64 bit block size).
		*/
		public GOfbBlockCipher(
			IBlockCipher cipher)
		{
			this.cipher = cipher;
			this.blockSize = cipher.GetBlockSize();

			if (blockSize != 8)
			{
				throw new ArgumentException("GCTR only for 64 bit block ciphers");
			}

			this.IV = new byte[cipher.GetBlockSize()];
			this.ofbV = new byte[cipher.GetBlockSize()];
			this.ofbOutV = new byte[cipher.GetBlockSize()];
		}
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:23,代码来源:GOFBBlockCipher.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: 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

示例10: 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

示例11: 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

示例12: 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

示例13: TlsBlockCipher

		public TlsBlockCipher(TlsClientContext context, IBlockCipher encryptCipher,
			IBlockCipher decryptCipher, IDigest writeDigest, IDigest readDigest, int cipherKeySize)
		{
			this.context = context;

            this.randomData = new byte[256];
            context.SecureRandom.NextBytes(randomData);

            this.encryptCipher = encryptCipher;
			this.decryptCipher = decryptCipher;

			int prfSize = (2 * cipherKeySize) + writeDigest.GetDigestSize()
				+ readDigest.GetDigestSize() + encryptCipher.GetBlockSize()
				+ decryptCipher.GetBlockSize();

			SecurityParameters securityParameters = context.SecurityParameters;

			byte[] keyBlock = TlsUtilities.PRF(securityParameters.masterSecret, "key expansion",
				TlsUtilities.Concat(securityParameters.serverRandom, securityParameters.clientRandom),
				prfSize);

			int offset = 0;

			// Init MACs
			wMac = CreateTlsMac(writeDigest, keyBlock, ref offset);
            rMac = CreateTlsMac(readDigest, keyBlock, ref offset);

			// Build keys
			KeyParameter encryptKey = CreateKeyParameter(keyBlock, ref offset, cipherKeySize);
			KeyParameter decryptKey = CreateKeyParameter(keyBlock, ref offset, cipherKeySize);

			// Add IVs
			ParametersWithIV encryptParams = CreateParametersWithIV(encryptKey,
				keyBlock, ref offset, encryptCipher.GetBlockSize());
			ParametersWithIV decryptParams = CreateParametersWithIV(decryptKey,
				keyBlock, ref offset, decryptCipher.GetBlockSize());

			if (offset != prfSize)
				throw new TlsFatalAlert(AlertDescription.internal_error);

			// Init Ciphers
			encryptCipher.Init(true, encryptParams);
			decryptCipher.Init(false, decryptParams);
		}
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:44,代码来源:TlsBlockCipher.cs

示例14: PaddedBufferedBlockCipher

		/**
		* Create a buffered block cipher with the desired padding.
		*
		* @param cipher the underlying block cipher this buffering object wraps.
		* @param padding the padding type.
		*/
		public PaddedBufferedBlockCipher(
			IBlockCipher		cipher,
			IBlockCipherPadding	padding)
		{
			this.cipher = cipher;
			this.padding = padding;

			buf = new byte[cipher.GetBlockSize()];
			bufOff = 0;
		}
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:16,代码来源:PaddedBufferedBlockCipher.cs

示例15: EaxBlockCipher

		/**
		* Constructor that accepts an instance of a block cipher engine.
		*
		* @param cipher the engine to use
		*/
		public EaxBlockCipher(
			IBlockCipher cipher)
		{
			blockSize = cipher.GetBlockSize();
			mac = new CMac(cipher);
			macBlock = new byte[blockSize];
			associatedTextMac = new byte[mac.GetMacSize()];
			nonceMac = new byte[mac.GetMacSize()];
			this.cipher = new SicBlockCipher(cipher);
		}
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:15,代码来源:EAXBlockCipher.cs


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