• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IBlockCipher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: CTSTester

 internal CTSTester(CTSTest enclosingInstance, int id, IBlockCipher cipher, ICipherParameters parameters, byte[] input, byte[] output)
 {
     InitBlock(enclosingInstance);
     this.id = id;
     this.cipher = cipher;
     this.parameters = parameters;
     this.input = input;
     this.output = output;
 }
开发者ID:randombit,项目名称:hacrypto,代码行数:9,代码来源:CTSTest.cs


示例17: OpenPgpCfbBlockCipher

		/**
        * Basic constructor.
        *
        * @param cipher the block cipher to be used as the basis of the
        * feedback mode.
        */
        public OpenPgpCfbBlockCipher(
            IBlockCipher cipher)
        {
            this.cipher = cipher;

            this.blockSize = cipher.GetBlockSize();
            this.IV = new byte[blockSize];
            this.FR = new byte[blockSize];
            this.FRE = new byte[blockSize];
        }
开发者ID:Xanagandr,项目名称:DisaOpenSource,代码行数:16,代码来源:OpenPgpCfbBlockCipher.cs


示例18: CbcBlockCipher

        /**
        * Basic constructor.
        *
        * @param cipher the block cipher to be used as the basis of chaining.
        */
        public CbcBlockCipher(
            IBlockCipher cipher)
        {
            this.cipher = cipher;
            this.blockSize = cipher.GetBlockSize();

            this.IV = new byte[blockSize];
            this.cbcV = new byte[blockSize];
            this.cbcNextV = new byte[blockSize];
        }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:15,代码来源:CbcBlockCipher.cs


示例19: BlockCipher

 public BlockCipher(IBlockCipher blockCipher)
 {
     if (!blockCipher.GetType().Equals(typeof(AesEngine)))
         DataBlockLength = 8; // in bytes
     else
     {
         DataBlockLength = 16; // aes processes blocks of 16 bytes
     }
     _blockCipher = blockCipher;
 }
开发者ID:knyga,项目名称:KnygaTaranCryption,代码行数:10,代码来源:BlockCipher.cs


示例20: X931TestVector

 public X931TestVector(IBlockCipher engine, IEntropySourceProvider entropyProvider, string key, string dateTimeVector,
     bool predictionResistant, string[] expected)
 {
     this.engine = engine;
     this.entropyProvider = entropyProvider;
     this.key = key;
     this.dateTimeVector = dateTimeVector;
     this.predictionResistant = predictionResistant;
     this.expected = expected;
 }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:10,代码来源:X931TestVector.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IBlockNode类代码示例发布时间:2022-05-24
下一篇:
C# IBlock类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap