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


C# IDigest.GetDigestSize方法代码示例

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


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

示例1: DigestRandomGenerator

 // Methods
 public DigestRandomGenerator(IDigest digest)
 {
     this.digest = digest;
     this.seed = new byte[digest.GetDigestSize()];
     this.seedCounter = 1L;
     this.state = new byte[digest.GetDigestSize()];
     this.stateCounter = 1L;
 }
开发者ID:Novo,项目名称:apbprivateserver,代码行数:9,代码来源:DigestRandomGenerator.cs

示例2: HashDF

	    /**
	     * Used by both Dual EC and Hash.
	     */
	    internal static byte[] HashDF(IDigest digest, byte[] seedMaterial, int seedLength)
	    {
	         // 1. temp = the Null string.
	        // 2. .
	        // 3. counter = an 8-bit binary value representing the integer "1".
	        // 4. For i = 1 to len do
	        // Comment : In step 4.1, no_of_bits_to_return
	        // is used as a 32-bit string.
	        // 4.1 temp = temp || Hash (counter || no_of_bits_to_return ||
	        // input_string).
	        // 4.2 counter = counter + 1.
	        // 5. requested_bits = Leftmost (no_of_bits_to_return) of temp.
	        // 6. Return SUCCESS and requested_bits.
	        byte[] temp = new byte[(seedLength + 7) / 8];

	        int len = temp.Length / digest.GetDigestSize();
	        int counter = 1;

	        byte[] dig = new byte[digest.GetDigestSize()];

	        for (int i = 0; i <= len; i++)
	        {
	            digest.Update((byte)counter);

	            digest.Update((byte)(seedLength >> 24));
	            digest.Update((byte)(seedLength >> 16));
	            digest.Update((byte)(seedLength >> 8));
	            digest.Update((byte)seedLength);

	            digest.BlockUpdate(seedMaterial, 0, seedMaterial.Length);

	            digest.DoFinal(dig, 0);

	            int bytesToCopy = ((temp.Length - i * dig.Length) > dig.Length)
	                    ? dig.Length
	                    : (temp.Length - i * dig.Length);
	            Array.Copy(dig, 0, temp, i * dig.Length, bytesToCopy);

	            counter++;
	        }

	        // do a left shift to get rid of excess bits.
	        if (seedLength % 8 != 0)
	        {
	            int shift = 8 - (seedLength % 8);
	            uint carry = 0;

                for (int i = 0; i != temp.Length; i++)
	            {
	                uint b = temp[i];
	                temp[i] = (byte)((b >> shift) | (carry << (8 - shift)));
	                carry = b;
	            }
	        }

            return temp;
	    }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:60,代码来源:DrbgUtilities.cs

示例3: DigestRandomGenerator

        public DigestRandomGenerator(IDigest digest)
        {
            _digest = digest;

            _seed = new byte[digest.GetDigestSize()];
            _seedCounter = 1;

            _state = new byte[digest.GetDigestSize()];
            _stateCounter = 1;
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:10,代码来源:DigestRandomGenerator.cs

示例4: TlsStreamCipher

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

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

            SecurityParameters securityParameters = context.SecurityParameters;

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

            int offset = 0;

            // Init MACs
            writeMac = CreateTlsMac(writeDigest, keyBlock, ref offset);
            readMac = CreateTlsMac(readDigest, keyBlock, ref offset);

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

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

            // Init Ciphers
            encryptCipher.Init(true, encryptKey);
            decryptCipher.Init(false, decryptKey);
        }
开发者ID:kyanha,项目名称:bc-csharp,代码行数:33,代码来源:TlsStreamCipher.cs

示例5: doExpectedTest

		private void doExpectedTest(IDigest digest, int seed, byte[] expected, byte[] noCycle)
		{
			DigestRandomGenerator rGen = new DigestRandomGenerator(digest);
			byte[] output = new byte[digest.GetDigestSize()];

			rGen.AddSeedMaterial(seed);

			for (int i = 0; i != 1024; i++)
			{
				rGen.NextBytes(output);
			}

			if (noCycle != null)
			{
				if (Arrays.AreEqual(noCycle, output))
				{
					Fail("seed not being cycled!");
				}
			}

			if (!Arrays.AreEqual(expected, output))
			{
				Fail("expected output doesn't match");
			}
		}
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:25,代码来源:DigestRandomNumberTest.cs

示例6: Iso9796d2PssSigner

		/// <summary>
		/// Generate a signer for the with either implicit or explicit trailers
		/// for ISO9796-2, scheme 2 or 3.
		/// </summary>
		/// <param name="cipher">base cipher to use for signature creation/verification</param>
		/// <param name="digest">digest to use.</param>
		/// <param name="saltLength">length of salt in bytes.</param>
		/// <param name="isImplicit">whether or not the trailer is implicit or gives the hash.</param>
		public Iso9796d2PssSigner(
			IAsymmetricBlockCipher	cipher,
			IDigest					digest,
			int						saltLength,
			bool					isImplicit)
		{
			this.cipher = cipher;
			this.digest = digest;
			this.hLen = digest.GetDigestSize();
			this.saltLength = saltLength;

			if (isImplicit)
			{
				trailer = TrailerImplicit;
			}
			else
			{
				if (digest is Sha1Digest)
				{
					trailer = TrailerSha1;
				}
				else if (digest is RipeMD160Digest)
				{
					trailer = TrailerRipeMD160;
				}
				else if (digest is RipeMD128Digest)
				{
					trailer = TrailerRipeMD128;
				}
				else
				{
					throw new ArgumentException("no valid trailer for digest");
				}
			}
		}
开发者ID:kungfubozo,项目名称:Bouncy-Castle-WP8,代码行数:43,代码来源:Iso9796d2PssSigner.cs

示例7: Compute

 public static byte[] Compute(IDigest hash, byte[] data)
 {
     var result = new byte[hash.GetDigestSize()];
     hash.BlockUpdate(data, 0, data.Length);
     hash.DoFinal(result, 0);
     return result;
 }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:7,代码来源:Hash.cs

示例8: CreateTlsMac

        protected virtual TlsMac CreateTlsMac(IDigest digest, byte[] buf, ref int off)
		{
			int len = digest.GetDigestSize();
			TlsMac mac = new TlsMac(digest, buf, off, len);
			off += len;
			return mac;
		}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:7,代码来源:TlsBlockCipher.cs

示例9: Encode

		/// <summary>
		/// Encode the stream with the given digest.
		/// </summary>
		/// <param name="data">The byte array to be encoded.</param>
		/// <param name="digest">The digest to be used.</param>
		/// <returns>Hashed value of the byte array as a hex string.</returns>
		private static string Encode(byte[] data, IDigest digest)
		{
			digest.BlockUpdate(data, 0, data.Length);
			byte[] output = new byte[digest.GetDigestSize()];
			digest.DoFinal (output, 0);
			return Hex.Encode(output);
		}
开发者ID:acschmit,项目名称:cryptography.Net,代码行数:13,代码来源:DigestSHA.cs

示例10: Pkcs12ParametersGenerator

		/**
		 * Construct a Pkcs 12 Parameters generator.
		 *
		 * @param digest the digest to be used as the source of derived keys.
		 * @exception ArgumentException if an unknown digest is passed in.
		 */
		public Pkcs12ParametersGenerator(
			IDigest digest)
		{
			this.digest = digest;

			u = digest.GetDigestSize();
			v = digest.GetByteLength();
		}
开发者ID:kungfubozo,项目名称:Bouncy-Castle-WP8,代码行数:14,代码来源:Pkcs12ParametersGenerator.cs

示例11: HMac

		public HMac(IDigest digest)
		{
			this.digest = digest;
			this.digestSize = digest.GetDigestSize();
			this.blockLength = digest.GetByteLength();
			this.inputPad = new byte[blockLength];
			this.outputBuf = new byte[blockLength + digestSize];
		}
开发者ID:Nethereum,项目名称:Nethereum,代码行数:8,代码来源:HMac.cs

示例12: GetHash

 private string GetHash(string s, IDigest algorithm)
 {
     var bytes = Encoding.UTF8.GetBytes(s);
     algorithm.BlockUpdate(bytes,0,bytes.Length);
     var res = new byte[algorithm.GetDigestSize()];
     algorithm.DoFinal(res, 0);
     return BitConverter.ToString(res).Replace("-", string.Empty);
 }
开发者ID:MediaFire,项目名称:mediafire-csharp-open-sdk,代码行数:8,代码来源:BouncyCastleCryptoService.cs

示例13: Hash

        private static byte[] Hash(byte[] data, IDigest digestAlgoritm)
        {
            digestAlgoritm.BlockUpdate(data, 0, data.Length);

            var result = new byte[digestAlgoritm.GetDigestSize()];

            digestAlgoritm.DoFinal(result, 0);

            return result;
        }
开发者ID:endret,项目名称:hamustronclient,代码行数:10,代码来源:HashUtil.cs

示例14: TlsNullCipher

        /// <exception cref="IOException"></exception>
        public TlsNullCipher(TlsContext context, IDigest clientWriteDigest, IDigest serverWriteDigest)
        {
            if ((clientWriteDigest == null) != (serverWriteDigest == null))
                throw new TlsFatalAlert(AlertDescription.internal_error);

            this.context = context;

            TlsMac clientWriteMac = null, serverWriteMac = null;

            if (clientWriteDigest != null)
            {
                int key_block_size = clientWriteDigest.GetDigestSize()
                    + serverWriteDigest.GetDigestSize();
                byte[] key_block = TlsUtilities.CalculateKeyBlock(context, key_block_size);

                int offset = 0;

                clientWriteMac = new TlsMac(context, clientWriteDigest, key_block, offset,
                    clientWriteDigest.GetDigestSize());
                offset += clientWriteDigest.GetDigestSize();

                serverWriteMac = new TlsMac(context, serverWriteDigest, key_block, offset,
                    serverWriteDigest.GetDigestSize());
                offset += serverWriteDigest.GetDigestSize();

                if (offset != key_block_size)
                {
                    throw new TlsFatalAlert(AlertDescription.internal_error);
                }
            }

            if (context.IsServer)
            {
                writeMac = serverWriteMac;
                readMac = clientWriteMac;
            }
            else
            {
                writeMac = clientWriteMac;
                readMac = serverWriteMac;
            }
        }
开发者ID:ubberkid,项目名称:PeerATT,代码行数:43,代码来源:TlsNullCipher.cs

示例15: HMac

        public HMac(
            IDigest digest)
        {
            this.digest = digest;
            digestSize = digest.GetDigestSize();

            blockLength = digest.GetByteLength();

            inputPad = new byte[blockLength];
            outputPad = new byte[blockLength];
        }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:11,代码来源:HMac.cs


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