本文整理汇总了C#中IDigest类的典型用法代码示例。如果您正苦于以下问题:C# IDigest类的具体用法?C# IDigest怎么用?C# IDigest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDigest类属于命名空间,在下文中一共展示了IDigest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: PssSigner
/// <summary>Basic constructor</summary>
/// <param name="cipher">the asymmetric cipher to use.</param>
/// <param name="digest">the digest to use.</param>
/// <param name="salt">the fixed salt to be used.</param>
public PssSigner(
IAsymmetricBlockCipher cipher,
IDigest digest,
byte[] salt)
: this(cipher, digest, digest, digest, salt.Length, salt, TrailerImplicit)
{
}
示例3: 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");
}
}
示例4: GeneratePrivateValue
public static BigInteger GeneratePrivateValue(IDigest digest, BigInteger N, BigInteger g, SecureRandom random)
{
int num = Math.Min(0x100, N.BitLength / 2);
BigInteger min = BigInteger.One.ShiftLeft(num - 1);
BigInteger max = N.Subtract(BigInteger.One);
return BigIntegers.CreateRandomInRange(min, max, random);
}
示例5: CalculateSecret
/**
* Processes the client's credentials. If valid the shared secret is generated and returned.
* @param clientA The client's credentials
* @return A shared secret BigInteger
* @throws CryptoException If client's credentials are invalid
*/
public virtual BigInteger CalculateSecret(IDigest digest, BigInteger clientA)
{
this.A = Srp6Utilities.ValidatePublicValue(param.N, clientA);
this.u = Srp6Utilities.CalculateU(digest, param.N, A, pubB);
this.S = v.ModPow(u, param.N).Multiply(A).Mod(param.N).ModPow(privB, param.N);
return S;
}
示例6: DigestRandomGenerator
public DigestRandomGenerator(
IDigest digest)
{
this.digest = digest;
this.state = new byte[digest.GetDigestSize()];
this.counter = 1;
}
示例7: HashSP800Drbg
/**
* Construct a SP800-90A Hash DRBG.
* <p>
* Minimum entropy requirement is the security strength requested.
* </p>
* @param digest source digest to use for DRB stream.
* @param securityStrength security strength required (in bits)
* @param entropySource source of entropy to use for seeding/reseeding.
* @param personalizationString personalization string to distinguish this DRBG (may be null).
* @param nonce nonce to further distinguish this DRBG (may be null).
*/
public HashSP800Drbg(IDigest digest, int securityStrength, IEntropySource entropySource, byte[] personalizationString, byte[] nonce)
{
if (securityStrength > DrbgUtilities.GetMaxSecurityStrength(digest))
throw new ArgumentException("Requested security strength is not supported by the derivation function");
if (entropySource.EntropySize < securityStrength)
throw new ArgumentException("Not enough entropy for security strength required");
mDigest = digest;
mEntropySource = entropySource;
mSecurityStrength = securityStrength;
mSeedLength = (int)seedlens[digest.AlgorithmName];
// 1. seed_material = entropy_input || nonce || personalization_string.
// 2. seed = Hash_df (seed_material, seedlen).
// 3. V = seed.
// 4. C = Hash_df ((0x00 || V), seedlen). Comment: Preceed V with a byte
// of zeros.
// 5. reseed_counter = 1.
// 6. Return V, C, and reseed_counter as the initial_working_state
byte[] entropy = GetEntropy();
byte[] seedMaterial = Arrays.ConcatenateAll(entropy, nonce, personalizationString);
byte[] seed = DrbgUtilities.HashDF(mDigest, seedMaterial, mSeedLength);
mV = seed;
byte[] subV = new byte[mV.Length + 1];
Array.Copy(mV, 0, subV, 1, mV.Length);
mC = DrbgUtilities.HashDF(mDigest, subV, mSeedLength);
mReseedCounter = 1;
}
示例8: Iso9796d2Signer
/// <summary>
/// Generate a signer for the with either implicit or explicit trailers
/// for ISO9796-2.
/// </summary>
/// <param name="cipher">base cipher to use for signature creation/verification</param>
/// <param name="digest">digest to use.</param>
/// <param name="isImplicit">whether or not the trailer is implicit or gives the hash.</param>
public Iso9796d2Signer(
IAsymmetricBlockCipher cipher,
IDigest digest,
bool isImplicit)
{
this.cipher = cipher;
this.digest = digest;
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 System.ArgumentException("no valid trailer for digest");
}
}
}
示例9: RsaDigestSigner
public RsaDigestSigner(
IDigest digest)
{
this.digest = digest;
algId = new AlgorithmIdentifier( (DerObjectIdentifier)oidMap[digest.AlgorithmName] , DerNull.Instance);
}
示例10: DsaDigestSigner
public DsaDigestSigner(
IDsa signer,
IDigest digest)
{
this.digest = digest;
this.dsaSigner = signer;
}
示例11: DeferredHash
private DeferredHash(byte prfHashAlgorithm, IDigest prfHash)
{
this.mBuf = null;
this.mHashes = Platform.CreateHashtable();
this.mPrfHashAlgorithm = prfHashAlgorithm;
mHashes[prfHashAlgorithm] = prfHash;
}
示例12: NonMemoableDigest
/**
* Base constructor.
*
* @param baseDigest underlying digest to use.
* @exception IllegalArgumentException if baseDigest is null
*/
public NonMemoableDigest(IDigest baseDigest)
{
if (baseDigest == null)
throw new ArgumentNullException("baseDigest");
this.mBaseDigest = baseDigest;
}
示例13: GenericSigner
public GenericSigner(
IAsymmetricBlockCipher engine,
IDigest digest)
{
this.engine = engine;
this.digest = digest;
}
示例14: OaepEncoding
public OaepEncoding(
IAsymmetricBlockCipher cipher,
IDigest hash,
byte[] encodingParams)
: this(cipher, hash, hash, encodingParams)
{
}
示例15: Init
/**
* Initialises the client to begin new authentication attempt
* @param N The safe prime associated with the client's verifier
* @param g The group parameter associated with the client's verifier
* @param digest The digest algorithm associated with the client's verifier
* @param random For key generation
*/
public virtual void Init(BigInteger N, BigInteger g, IDigest digest, SecureRandom random)
{
this.N = N;
this.g = g;
this.digest = digest;
this.random = random;
}