本文整理汇总了C#中System.Security.Cryptography.RSAPKCS1SignatureDeformatter类的典型用法代码示例。如果您正苦于以下问题:C# RSAPKCS1SignatureDeformatter类的具体用法?C# RSAPKCS1SignatureDeformatter怎么用?C# RSAPKCS1SignatureDeformatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RSAPKCS1SignatureDeformatter类属于System.Security.Cryptography命名空间,在下文中一共展示了RSAPKCS1SignatureDeformatter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RSAConstructors
public void RSAConstructors ()
{
RSAPKCS1SignatureDeformatter fmt;
fmt = new RSAPKCS1SignatureDeformatter ();
fmt = new RSAPKCS1SignatureDeformatter (rsa);
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:RSAPKCS1SignatureDeformatterTest.cs
示例2: Validate
/// <summary>
/// ��ע����Ϣ���ݲ��÷ǶԳƼ��ܵķ�ʽ����
/// </summary>
/// <param name="originalString">δ���ܵ��ı����������</param>
/// <param name="encrytedString">���ܺ���ı�����ע�����к�</param>
/// <returns>�����֤�ɹ�����True������ΪFalse</returns>
public static bool Validate(string originalString, string encrytedString)
{
bool bPassed = false;
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
try
{
rsa.FromXmlString(UIConstants.PublicKey); //��Կ
RSAPKCS1SignatureDeformatter formatter = new RSAPKCS1SignatureDeformatter(rsa);
formatter.SetHashAlgorithm("SHA1");
byte[] key = Convert.FromBase64String(encrytedString); //��֤
SHA1Managed sha = new SHA1Managed();
byte[] name = sha.ComputeHash(ASCIIEncoding.ASCII.GetBytes(originalString));
if (formatter.VerifySignature(name, key))
{
bPassed = true;
}
}
catch
{
}
}
return bPassed;
}
开发者ID:Andy-Yin,项目名称:MY_OA_RM,代码行数:31,代码来源:RSASecurityHelper.cs
示例3: Verify
public static bool Verify(Stream input, Stream output, string publicKey)
{
// ファイルから情報の抽出
var buffer = new byte[64];
if (input.Read(buffer, 0, 64) < 64)
throw new Exception("File is corrupted.(KSIG: Magic Not Found)");
var magicstr = Encoding.UTF8.GetString(buffer).Split(new[] { ":" }, StringSplitOptions.None);
if (magicstr.Length < 2)
throw new Exception("File is corrupted.(KSIG: Invalid Magic Length)");
if (magicstr[0] != MagicStr)
throw new Exception("File is corrupted.(KSIG: Invalid Magic String)");
var siglen = int.Parse(magicstr[1]);
var sigbuf = new byte[siglen];
if (input.Read(sigbuf, 0, siglen) < siglen)
throw new Exception("File is corrupted.(KSIG: Invalid Signature)");
var data = ReadAllBytes(input);
using (var sha = new SHA256Managed())
using (var rsa = new RSACryptoServiceProvider())
{
// Compute hash
var hash = sha.ComputeHash(data);
// RSA Initialize
rsa.FromXmlString(publicKey);
// deformat
var deformatter = new RSAPKCS1SignatureDeformatter(rsa);
deformatter.SetHashAlgorithm("SHA256");
if (!deformatter.VerifySignature(hash, sigbuf))
return false;
}
output.Write(data, 0, data.Length);
return true;
}
开发者ID:Kei-Nanigashi,项目名称:StarryEyes,代码行数:33,代码来源:Cryptography.cs
示例4: CerRSAVerifySignature
/// <summary>
/// 引用证书非对称加/解密RSA-公钥验签【OriginalString:原文;SignatureString:签名字符;pubkey_path:证书路径;CertificatePW:证书密码;SignType:签名摘要类型(1:MD5,2:SHA1)】
/// </summary>
public static bool CerRSAVerifySignature(string OriginalString, string SignatureString, string pubkey_path, string CertificatePW, int SignType)
{
byte[] OriginalByte = System.Text.Encoding.UTF8.GetBytes(OriginalString);
byte[] SignatureByte = Convert.FromBase64String(SignatureString);
X509Certificate2 x509_Cer1 = new X509Certificate2(pubkey_path, CertificatePW);
RSACryptoServiceProvider rsapub = (RSACryptoServiceProvider)x509_Cer1.PublicKey.Key;
rsapub.ImportCspBlob(rsapub.ExportCspBlob(false));
RSAPKCS1SignatureDeformatter f = new RSAPKCS1SignatureDeformatter(rsapub);
byte[] HashData;
switch (SignType)
{
case 1:
f.SetHashAlgorithm("MD5");//摘要算法MD5
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
HashData = md5.ComputeHash(OriginalByte);
break;
default:
f.SetHashAlgorithm("SHA1");//摘要算法SHA1
SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
HashData = sha.ComputeHash(OriginalByte);
break;
}
if (f.VerifySignature(HashData, SignatureByte))
{
return true;
}
else
{
return false;
}
}
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:34,代码来源:99BillController.cs
示例5: CompareCode
public static bool CompareCode(string regcode)
{
if (regcode == null || regcode == "")
{
return false;
}
try
{
string toolcode = GetDiskVolumeSerialNumber() + GetCpuSerialNumber();
string pubkey = "<RSAKeyValue><Modulus>xe3teTUwLgmbiwFJwWEQnshhKxgcasglGsfNVFTk0hdqKc9i7wb+gG7HOdPZLh65QyBcFfzdlrawwVkiPEL5kNTX1q3JW5J49mTVZqWd3w49reaLd8StHRYJdyGAL4ZovBhSTThETi+zYvgQ5SvCGkM6/xXOz+lkMaEgeFcjQQs=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
string prikey = "<RSAKeyValue><Modulus>xe3teTUwLgmbiwFJwWEQnshhKxgcasglGsfNVFTk0hdqKc9i7wb+gG7HOdPZLh65QyBcFfzdlrawwVkiPEL5kNTX1q3JW5J49mTVZqWd3w49reaLd8StHRYJdyGAL4ZovBhSTThETi+zYvgQ5SvCGkM6/xXOz+lkMaEgeFcjQQs=</Modulus><Exponent>AQAB</Exponent><P>5flMAd7IrUTx92yomBdJBPDzp1Kclpaw4uXB1Ht+YXqwLW/9icI6mcv7d2O0kuVLSWj8DPZJol9V8AtvHkC3oQ==</P><Q>3FRA9UWcFrVPvGR5bewcL7YqkCMZlybV/t6nCH+gyMfbEvgk+p04F+j8WiHDykWj+BahjScjwyF5SGADbrfJKw==</Q><DP>b4WOU1XbERNfF3JM67xW/5ttPNX185zN2Ko8bbMZXWImr1IgrD5RNqXRo1rphVbGRKoxmIOSv7flr8uLrisKIQ==</DP><DQ>otSZlSq2qomgvgg7PaOLSS+F0TQ/i1emO0/tffhkqT4ah7BgE97xP6puJWZivjAteAGxrxHH+kPY0EY1AzRMNQ==</DQ><InverseQ>Sxyz0fEf5m7GrzAngLDRP/i+QDikJFfM6qPyr3Ub6Y5RRsFbeOWY1tX3jmV31zv4cgJ6donH7W2dSBPi67sSsw==</InverseQ><D>nVqofsIgSZltxTcC8fA/DFz1kxMaFHKFvSK3RKIxQC1JQ3ASkUEYN/baAElB0f6u/oTNcNWVPOqE31IDe7ErQelVc4D26RgFd5V7dSsF3nVz00s4mq1qUBnCBLPIrdb0rcQZ8FUQTsd96qW8Foave4tm8vspbM65iVUBBVdSYYE=</D></RSAKeyValue>";
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
rsa.FromXmlString(pubkey);
RSAPKCS1SignatureDeformatter f = new RSAPKCS1SignatureDeformatter(rsa);
f.SetHashAlgorithm("SHA1");
SHA1Managed sha = new SHA1Managed();
byte[] name = sha.ComputeHash(ASCIIEncoding.ASCII.GetBytes(toolcode));
byte[] key = Convert.FromBase64String(regcode);
return f.VerifySignature(name, key);
}
}
catch
{
return false;
}
}
开发者ID:shumaojie,项目名称:Packaging,代码行数:34,代码来源:PublicFunc.cs
示例6: VerifySignature
public DigitalSignatureVerificationResult VerifySignature(DigitalSignatureVerificationArguments arguments)
{
var res = new DigitalSignatureVerificationResult();
try
{
var rsaProviderSender = new RSACryptoServiceProvider();
rsaProviderSender.FromXmlString(arguments.PublicKeyForSignatureVerification.ToString());
var deformatter = new RSAPKCS1SignatureDeformatter(rsaProviderSender);
deformatter.SetHashAlgorithm(_hashingService.HashAlgorithmCode());
var hashResult = _hashingService.Hash(arguments.CipherText);
res.SignaturesMatch = deformatter.VerifySignature(hashResult.HashedBytes, arguments.Signature);
if (res.SignaturesMatch)
{
var rsaProviderReceiver = new RSACryptoServiceProvider();
rsaProviderReceiver.FromXmlString(arguments.FullKeyForDecryption.ToString());
var decryptedBytes = rsaProviderReceiver.Decrypt(Convert.FromBase64String(arguments.CipherText), false);
res.DecodedText = Encoding.UTF8.GetString(decryptedBytes);
}
res.Success = true;
}
catch (Exception ex)
{
res.ExceptionMessage = ex.Message;
}
return res;
}
开发者ID:richardkundl,项目名称:SampleDI-IoC,代码行数:28,代码来源:RsaPkcs1DigitalSignatureService.cs
示例7: verify
public bool verify(byte[] sig)
{
m_cs.Close();
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSA.ImportParameters(m_RSAKeyInfo);
RSAPKCS1SignatureDeformatter RSADeformatter = new RSAPKCS1SignatureDeformatter(RSA);
RSADeformatter.SetHashAlgorithm("SHA1");
long i = 0;
long j = 0;
byte[] tmp;
if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0)
{
long i1 = (sig[i++] << 24) & 0xff000000;
long i2 = (sig[i++] << 16) & 0x00ff0000;
long i3 = (sig[i++] << 8) & 0x0000ff00;
long i4 = (sig[i++]) & 0x000000ff;
j = i1 | i2 | i3 | i4;
i += j;
i1 = (sig[i++] << 24) & 0xff000000;
i2 = (sig[i++] << 16) & 0x00ff0000;
i3 = (sig[i++] << 8) & 0x0000ff00;
i4 = (sig[i++]) & 0x000000ff;
j = i1 | i2 | i3 | i4;
tmp = new byte[j];
Array.Copy(sig, i, tmp, 0, j);
sig = tmp;
}
return RSADeformatter.VerifySignature(m_sha1, sig);
}
开发者ID:x893,项目名称:SharpSSH,代码行数:34,代码来源:SignatureRSA.cs
示例8: ValidatePathWithEncodedRSAPKCS1SignatureAndPublicRSAKey
public static bool ValidatePathWithEncodedRSAPKCS1SignatureAndPublicRSAKey(string path, string base64Signature, string publicKey) {
try {
byte[] signature = Convert.FromBase64String(base64Signature);
byte[] data = File.ReadAllBytes(path);
SHA256CryptoServiceProvider cryptoTransformSHA256 = new SHA256CryptoServiceProvider();
byte[] sha256Hash = cryptoTransformSHA256.ComputeHash(data);
string cleanKey = "";
string[] lines = publicKey.Split(new char[] {'\n', '\r'});
foreach (string line in lines) {
cleanKey += line.Trim();
}
byte[] publicKeyData = Convert.FromBase64String(cleanKey);
RSACryptoServiceProvider provider = new RSACryptoServiceProvider();
provider.ImportCspBlob(publicKeyData);
RSAPKCS1SignatureDeformatter formatter = new RSAPKCS1SignatureDeformatter(provider);
formatter.SetHashAlgorithm("SHA256");
return formatter.VerifySignature(sha256Hash, signature);
} catch (Exception ex) {
Console.WriteLine(ex.Message);
return false;
}
}
开发者ID:bt-browser,项目名称:SparkleDotNET,代码行数:30,代码来源:SURSAPKCS1Verifier.cs
示例9: CreateDeformatter
public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key)
{
if (key == null)
throw new ArgumentNullException(nameof(key));
var d = new RSAPKCS1SignatureDeformatter(key);
d.SetHashAlgorithm(SHA_512);
return d;
}
开发者ID:nofuture-git,项目名称:31g,代码行数:8,代码来源:Misc.cs
示例10: RSAConstructors
public void RSAConstructors ()
{
RSAPKCS1SignatureDeformatter fmt;
fmt = new RSAPKCS1SignatureDeformatter ();
AssertNotNull ("RSAPKCS1SignatureDeformatter()", fmt);
fmt = new RSAPKCS1SignatureDeformatter (rsa);
AssertNotNull ("RSAPKCS1SignatureDeformatter(rsa)", fmt);
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:RSAPKCS1SignatureDeformatterTest.cs
示例11: CreateDeformatter
public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key)
{
if (key == null)
throw new ArgumentNullException("key");
RSAPKCS1SignatureDeformatter deformatter = new RSAPKCS1SignatureDeformatter(key);
deformatter.SetHashAlgorithm("SHA256");
return deformatter;
}
开发者ID:scholtz,项目名称:FastZep,代码行数:9,代码来源:RSAPKCS1SHA256SignatureDescription.cs
示例12: CreateDeformatter
/// <summary>
/// Create a deformatter
/// </summary>
/// <param name="key">Key</param>
/// <returns>Deformatter</returns>
public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key)
{
if (key == null)
{
throw new ArgumentNullException(nameof(key));
}
var df = new RSAPKCS1SignatureDeformatter(key);
df.SetHashAlgorithm(typeof(SHA256Managed).FullName);
return df;
}
开发者ID:CDHDeveloper,项目名称:authservices,代码行数:16,代码来源:ManagedSha256SignatureDescription.cs
示例13: VerifySignature
public bool VerifySignature(byte[] hash, byte[] signedhash)
{
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSAParameters RSAKeyInfo = new RSAParameters();
RSAKeyInfo.Modulus = m_public.Modulus;
RSAKeyInfo.Exponent = m_public.Exponent;
RSA.ImportParameters(RSAKeyInfo);
RSAPKCS1SignatureDeformatter RSADeformatter = new RSAPKCS1SignatureDeformatter(RSA);
RSADeformatter.SetHashAlgorithm("MD5");
return RSADeformatter.VerifySignature(hash, signedhash);
}
开发者ID:sasha2567,项目名称:8--,代码行数:11,代码来源:DigitalSignatureHelper+.cs
示例14: CreateDeformatter
public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key)
{
if (key == null)
{
throw new Exception("Invalid key specified for RSAPKCS1SHA256SignatureDescription!");
}
RSAPKCS1SignatureDeformatter deformatter = new RSAPKCS1SignatureDeformatter(key);
deformatter.SetHashAlgorithm("SHA256");
return deformatter;
}
开发者ID:MNLGD,项目名称:IDES-Data-Preparation-Dot-Net,代码行数:12,代码来源:RSAPKCS1SHA256SignatureDescription.cs
示例15: VerifySignature
public bool VerifySignature(byte[] hashOfDataToSign, byte[] signature)
{
using (var rsa = new RSACryptoServiceProvider(2048))
{
rsa.ImportParameters(_publicKey);
var rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
rsaDeformatter.SetHashAlgorithm("SHA256");
return rsaDeformatter.VerifySignature(hashOfDataToSign, signature);
}
}
开发者ID:dance2die,项目名称:Project.EncryptTwitter,代码行数:12,代码来源:DigitalSignature.cs
示例16: VerifyString
/// <summary>
/// RSA验证
/// </summary>
/// <param name="CypherText">签名后的Base64字符串</param>
/// <param name="xmlString">密钥(至少含公钥)</param>
/// <param name="PlainText">原始串</param>
public static bool VerifyString(string CypherText, string xmlString, string PlainText)
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(xmlString);
RSAPKCS1SignatureDeformatter f = new RSAPKCS1SignatureDeformatter(rsa);
f.SetHashAlgorithm("SHA1");
SHA1Managed sha = new SHA1Managed();
byte[] bText = System.Convert.FromBase64String(CypherText);
byte[] bEnc = sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(PlainText));
return f.VerifySignature(bEnc, bText);
}
开发者ID:lujinlong,项目名称:Apq,代码行数:18,代码来源:Common.cs
示例17: VerifyDigitalSignature
/// <summary>
/// デジタル署名を検証する
/// </summary>
/// <param name="message">署名の付いたメッセージ</param>
/// <param name="signature">署名</param>
/// <param name="publicKey">送信者の公開鍵</param>
/// <returns>認証に成功した時はTrue。失敗した時はFalse。</returns>
public static bool VerifyDigitalSignature(byte[] message, byte[] signature, string publicKey)
{
byte[] hashData = SHA256.Create().ComputeHash(message);
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
rsa.FromXmlString(publicKey);
RSAPKCS1SignatureDeformatter rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
rsaDeformatter.SetHashAlgorithm("SHA256");
return rsaDeformatter.VerifySignature(hashData, signature);
}
}
开发者ID:asapo,项目名称:Profes,代码行数:20,代码来源:DigitalSignature.cs
示例18: ValidateSignature
public bool ValidateSignature(OAuthContext authContext, SigningContext signingContext)
{
if (signingContext.Algorithm == null) throw Error.AlgorithmPropertyNotSetOnSigningContext();
SHA1CryptoServiceProvider sha1 = GenerateHash(signingContext);
var deformatter = new RSAPKCS1SignatureDeformatter(signingContext.Algorithm);
deformatter.SetHashAlgorithm("MD5");
byte[] signature = Convert.FromBase64String(authContext.Signature);
return deformatter.VerifySignature(sha1, signature);
}
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:13,代码来源:RsaSha1SignatureImplementation.cs
示例19: Verify
public bool Verify(byte[] signature, byte[] securedInput, object key)
{
using (var sha = HashAlgorithm)
{
var publicKey = Ensure.Type<AsymmetricAlgorithm>(key, "RsaUsingSha alg expects key to be of AsymmetricAlgorithm type.");
byte[] hash = sha.ComputeHash(securedInput);
var pkcs1 = new RSAPKCS1SignatureDeformatter(publicKey);
pkcs1.SetHashAlgorithm(hashMethod);
return pkcs1.VerifySignature(hash, signature);
}
}
开发者ID:coryflucas,项目名称:jose-jwt,代码行数:14,代码来源:RsaUsingSha.cs
示例20: Verify
public static bool Verify(byte[] publicKey, byte[] signature, Stream stream)
{
#if Windows
try
{
using (var rsa = new RSACryptoServiceProvider())
{
rsa.FromXmlString(Encoding.ASCII.GetString(publicKey));
var rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
rsaDeformatter.SetHashAlgorithm("SHA256");
using (var Sha256 = SHA256.Create())
{
return rsaDeformatter.VerifySignature(Sha256.ComputeHash(stream), signature);
}
}
}
catch (Exception)
{
return false;
}
#endif
#if Unix
lock (_lockObject)
{
try
{
using (var rsa = new RSACryptoServiceProvider())
{
rsa.FromXmlString(Encoding.ASCII.GetString(publicKey));
var rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
rsaDeformatter.SetHashAlgorithm("SHA256");
using (var Sha256 = SHA256.Create())
{
return rsaDeformatter.VerifySignature(Sha256.ComputeHash(stream), signature);
}
}
}
catch (Exception)
{
return false;
}
}
#endif
}
开发者ID:Alliance-Network,项目名称:Library,代码行数:49,代码来源:Rsa2048_Sha512.cs
注:本文中的System.Security.Cryptography.RSAPKCS1SignatureDeformatter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论