本文整理汇总了C#中AsymmetricKeyParameter类的典型用法代码示例。如果您正苦于以下问题:C# AsymmetricKeyParameter类的具体用法?C# AsymmetricKeyParameter怎么用?C# AsymmetricKeyParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsymmetricKeyParameter类属于命名空间,在下文中一共展示了AsymmetricKeyParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefaultTlsAgreementCredentials
public DefaultTlsAgreementCredentials(Certificate certificate, AsymmetricKeyParameter privateKey)
{
if (certificate == null)
throw new ArgumentNullException("certificate");
if (certificate.IsEmpty)
throw new ArgumentException("cannot be empty", "certificate");
if (privateKey == null)
throw new ArgumentNullException("privateKey");
if (!privateKey.IsPrivate)
throw new ArgumentException("must be private", "privateKey");
if (privateKey is DHPrivateKeyParameters)
{
mBasicAgreement = new DHBasicAgreement();
mTruncateAgreement = true;
}
else if (privateKey is ECPrivateKeyParameters)
{
mBasicAgreement = new ECDHBasicAgreement();
mTruncateAgreement = false;
}
else
{
throw new ArgumentException("type not supported: " + privateKey.GetType().FullName, "privateKey");
}
this.mCertificate = certificate;
this.mPrivateKey = privateKey;
}
示例2: CalculateRawSignature
public virtual byte[] CalculateRawSignature(SecureRandom random,
AsymmetricKeyParameter privateKey, byte[] md5andsha1)
{
ISigner s = MakeSigner(new NullDigest(), true, new ParametersWithRandom(privateKey, random));
s.BlockUpdate(md5andsha1, 0, md5andsha1.Length);
return s.GenerateSignature();
}
示例3: VerifyRawSignature
public virtual bool VerifyRawSignature(byte[] sigBytes, AsymmetricKeyParameter publicKey,
byte[] md5andsha1)
{
ISigner s = MakeSigner(new NullDigest(), false, publicKey);
s.BlockUpdate(md5andsha1, 0, md5andsha1.Length);
return s.VerifySignature(sigBytes);
}
示例4: VerifyRawSignature
public bool VerifyRawSignature(byte[] sigBytes, AsymmetricKeyParameter publicKey, byte[] md5andsha1)
{
ISigner s = MakeSigner(new NullDigest(), false, publicKey);
// Note: Only use the SHA1 part of the hash
s.BlockUpdate(md5andsha1, 16, 20);
return s.VerifySignature(sigBytes);
}
示例5: VerifyRawSignature
public override bool VerifyRawSignature(SignatureAndHashAlgorithm algorithm, byte[] sigBytes,
AsymmetricKeyParameter publicKey, byte[] hash)
{
ISigner signer = MakeSigner(algorithm, true, false, publicKey);
signer.BlockUpdate(hash, 0, hash.Length);
return signer.VerifySignature(sigBytes);
}
示例6: GenerateRawSignature
public virtual byte[] GenerateRawSignature(SecureRandom random,
AsymmetricKeyParameter privateKey, byte[] md5AndSha1)
{
IAsymmetricBlockCipher engine = CreateRsaImpl();
engine.Init(true, new ParametersWithRandom(privateKey, random));
return engine.ProcessBlock(md5AndSha1, 0, md5AndSha1.Length);
}
示例7: VerifyRawSignature
public virtual bool VerifyRawSignature(byte[] sigBytes, AsymmetricKeyParameter publicKey,
byte[] md5AndSha1)
{
IAsymmetricBlockCipher engine = CreateRsaImpl();
engine.Init(false, publicKey);
byte[] signed = engine.ProcessBlock(sigBytes, 0, sigBytes.Length);
return Arrays.ConstantTimeAreEqual(signed, md5AndSha1);
}
示例8: CalculateRawSignature
public virtual byte[] CalculateRawSignature(SecureRandom random,
AsymmetricKeyParameter privateKey, byte[] md5andsha1)
{
ISigner sig = new GenericSigner(new Pkcs1Encoding(new RsaBlindedEngine()), new NullDigest());
sig.Init(true, new ParametersWithRandom(privateKey, random));
sig.BlockUpdate(md5andsha1, 0, md5andsha1.Length);
return sig.GenerateSignature();
}
示例9: CalculateRawSignature
public virtual byte[] CalculateRawSignature(SecureRandom random,
AsymmetricKeyParameter privateKey, byte[] md5andsha1)
{
ISigner s = MakeSigner(new NullDigest(), true, new ParametersWithRandom(privateKey, random));
// Note: Only use the SHA1 part of the hash
s.BlockUpdate(md5andsha1, 16, 20);
return s.GenerateSignature();
}
示例10: GenerateRawSignature
public override byte[] GenerateRawSignature(SignatureAndHashAlgorithm algorithm,
AsymmetricKeyParameter privateKey, byte[] hash)
{
ISigner signer = MakeSigner(algorithm, true, true,
new ParametersWithRandom(privateKey, this.mContext.SecureRandom));
signer.BlockUpdate(hash, 0, hash.Length);
return signer.GenerateSignature();
}
示例11: GenerateAgreement
/// <exception cref="IOException"></exception>
public override byte[] GenerateAgreement(AsymmetricKeyParameter peerPublicKey)
{
mBasicAgreement.Init(mPrivateKey);
BigInteger agreementValue = mBasicAgreement.CalculateAgreement(peerPublicKey);
if (mTruncateAgreement)
{
return BigIntegers.AsUnsignedByteArray(agreementValue);
}
return BigIntegers.AsUnsignedByteArray(mBasicAgreement.GetFieldSize(), agreementValue);
}
示例12: GenerateAgreement
public virtual byte[] GenerateAgreement(AsymmetricKeyParameter serverPublicKey)
{
basicAgreement.Init(clientPrivateKey);
BigInteger agreementValue = basicAgreement.CalculateAgreement(serverPublicKey);
if (truncateAgreement)
{
return BigIntegers.AsUnsignedByteArray(agreementValue);
}
return BigIntegers.AsUnsignedByteArray(basicAgreement.GetFieldSize(), agreementValue);
}
示例13: VerifyRawSignature
public override bool VerifyRawSignature(SignatureAndHashAlgorithm algorithm, byte[] sigBytes,
AsymmetricKeyParameter publicKey, byte[] hash)
{
ISigner signer = MakeSigner(algorithm, true, false, publicKey);
if (algorithm == null)
{
// Note: Only use the SHA1 part of the (MD5/SHA1) hash
signer.BlockUpdate(hash, 16, 20);
}
else
{
signer.BlockUpdate(hash, 0, hash.Length);
}
return signer.VerifySignature(sigBytes);
}
示例14: GenerateRawSignature
public override byte[] GenerateRawSignature(SignatureAndHashAlgorithm algorithm,
AsymmetricKeyParameter privateKey, byte[] hash)
{
ISigner signer = MakeSigner(algorithm, true, true,
new ParametersWithRandom(privateKey, this.mContext.SecureRandom));
if (algorithm == null)
{
// Note: Only use the SHA1 part of the (MD5/SHA1) hash
signer.BlockUpdate(hash, 16, 20);
}
else
{
signer.BlockUpdate(hash, 0, hash.Length);
}
return signer.GenerateSignature();
}
示例15: DefaultTlsSignerCredentials
public DefaultTlsSignerCredentials(TlsClientContext context,
Certificate clientCertificate, AsymmetricKeyParameter clientPrivateKey)
{
if (clientCertificate == null)
{
throw new ArgumentNullException("clientCertificate");
}
if (clientCertificate.Length == 0)
{
throw new ArgumentException("cannot be empty", "clientCertificate");
}
if (clientPrivateKey == null)
{
throw new ArgumentNullException("clientPrivateKey");
}
if (!clientPrivateKey.IsPrivate)
{
throw new ArgumentException("must be private", "clientPrivateKey");
}
if (clientPrivateKey is RsaKeyParameters)
{
clientSigner = new TlsRsaSigner();
}
else if (clientPrivateKey is DsaPrivateKeyParameters)
{
clientSigner = new TlsDssSigner();
}
else if (clientPrivateKey is ECPrivateKeyParameters)
{
clientSigner = new TlsECDsaSigner();
}
else
{
throw new ArgumentException("type not supported: "
+ clientPrivateKey.GetType().FullName, "clientPrivateKey");
}
this.context = context;
this.clientCert = clientCertificate;
this.clientPrivateKey = clientPrivateKey;
}