本文整理汇总了C#中System.Security.Cryptography.AsymmetricAlgorithm类的典型用法代码示例。如果您正苦于以下问题:C# AsymmetricAlgorithm类的具体用法?C# AsymmetricAlgorithm怎么用?C# AsymmetricAlgorithm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsymmetricAlgorithm类属于System.Security.Cryptography命名空间,在下文中一共展示了AsymmetricAlgorithm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SignXml
private static string SignXml(XmlDocument unsignedXml,
AsymmetricAlgorithm key)
{
if (unsignedXml.DocumentElement == null)
{
throw new ArgumentNullException("unsignedXml");
}
// Create a reference to be signed. Blank == Everything
var emptyReference = new Reference { Uri = "" };
// Add an enveloped transformation to the reference.
var envelope = new XmlDsigEnvelopedSignatureTransform();
emptyReference.AddTransform(envelope);
var signedXml = new SignedXml(unsignedXml) { SigningKey = key };
signedXml.AddReference(emptyReference);
signedXml.ComputeSignature();
var digitalSignature = signedXml.GetXml();
unsignedXml.DocumentElement.AppendChild(
unsignedXml.ImportNode(digitalSignature, true));
var signedXmlOut = new StringBuilder();
using (var swOut = new StringWriter(signedXmlOut))
{
unsignedXml.Save(swOut);
}
return signedXmlOut.ToString();
}
开发者ID:huoxudong125,项目名称:HQF.Tutorial.Encryption,代码行数:32,代码来源:SignAndVerify.cs
示例2: CreateFormatter
public override AsymmetricSignatureFormatter CreateFormatter(AsymmetricAlgorithm key)
{
if (key == null)
{
throw new ArgumentNullException(nameof(key));
}
var provider = (RSACryptoServiceProvider)key;
// The provider is probably using the default ProviderType. That's
// a problem, because it doesn't support SHA256. Let's do some
// black magic and create a new provider of a type that supports
// SHA256 without the user ever knowing we fix this. This is what
// is done in X509AsymmetricKey.GetSignatureFormatter if
// http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 isn't
// a known algorithm, so users kind of expect this to be handled
// for them magically.
var cspParams = new CspParameters();
cspParams.ProviderType = 24; //PROV_RSA_AES
cspParams.KeyContainerName = provider.CspKeyContainerInfo.KeyContainerName;
cspParams.KeyNumber = (int)provider.CspKeyContainerInfo.KeyNumber;
SetMachineKeyFlag(provider, cspParams);
cspParams.Flags |= CspProviderFlags.UseExistingKey;
provider = new RSACryptoServiceProvider(cspParams);
var f = new RSAPKCS1SignatureFormatter(provider);
f.SetHashAlgorithm(typeof(SHA256Managed).FullName);
return f;
}
开发者ID:CDHDeveloper,项目名称:authservices,代码行数:32,代码来源:ManagedSha256SignatureDescription.cs
示例3: RsaCryptographicKey
/// <summary>
/// Initializes a new instance of the <see cref="RsaCryptographicKey" /> class.
/// </summary>
/// <param name="key">The RSA crypto service provider.</param>
/// <param name="algorithm">The algorithm.</param>
internal RsaCryptographicKey(RSA key, AsymmetricAlgorithm algorithm)
{
Requires.NotNull(key, "key");
this.key = key;
this.algorithm = algorithm;
}
开发者ID:gitter-badger,项目名称:PCLCrypto,代码行数:12,代码来源:RsaCryptographicKey.cs
示例4: CreateDeformatter
public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key)
{
AsymmetricSignatureDeformatter deformatter = (AsymmetricSignatureDeformatter) CryptoConfig.CreateFromName(base.DeformatterAlgorithm);
deformatter.SetKey(key);
deformatter.SetHashAlgorithm("SHA1");
return deformatter;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:RSAPKCS1SHA1SignatureDescription.cs
示例5: RSAPKCS1SignatureFormatter
public RSAPKCS1SignatureFormatter(AsymmetricAlgorithm key)
{
if (key == null)
throw new ArgumentNullException(nameof(key));
_rsaKey = (RSA)key;
}
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:RSAPKCS1SignatureFormatter.cs
示例6: SetKey
public override void SetKey(AsymmetricAlgorithm key) {
if (key == null)
throw new ArgumentNullException("key");
Contract.EndContractBlock();
_rsaKey = (RSA) key;
_rsaOverridesDecrypt = default(bool?);
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:7,代码来源:rsaoaepkeyexchangedeformatter.cs
示例7: Decrypt
internal static IEnumerable<XmlElement> Decrypt(this IEnumerable<XmlElement> elements, AsymmetricAlgorithm key)
{
foreach (var element in elements)
{
yield return element.Decrypt(key);
}
}
开发者ID:CDHDeveloper,项目名称:authservices,代码行数:7,代码来源:CryptographyExtensions.cs
示例8: CreateFormatter
public virtual AsymmetricSignatureFormatter CreateFormatter(AsymmetricAlgorithm key) {
AsymmetricSignatureFormatter item;
item = (AsymmetricSignatureFormatter) CryptoConfig.CreateFromName(_strFormatter);
item.SetKey(key);
return item;
}
开发者ID:uQr,项目名称:referencesource,代码行数:7,代码来源:signaturedescription.cs
示例9: CreateDeformatter
public override AsymmetricSignatureDeformatter CreateDeformatter(AsymmetricAlgorithm key)
{
var asymmetricSignatureDeformatter = (AsymmetricSignatureDeformatter)CryptoConfig.CreateFromName(DeformatterAlgorithm);
asymmetricSignatureDeformatter.SetKey(key);
asymmetricSignatureDeformatter.SetHashAlgorithm("SHA256");
return asymmetricSignatureDeformatter;
}
开发者ID:pereilif,项目名称:sikker-digital-post-klient-dotnet,代码行数:7,代码来源:RsaPkCs1Sha256SignatureDescription.cs
示例10: SetKey
public override void SetKey(AsymmetricAlgorithm key)
{
if (key == null)
throw new ArgumentNullException(nameof(key));
_rsaKey = (RSA)key;
}
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:RSAPKCS1SignatureFormatter.cs
示例11: CheckSignature
/// <summary>
/// Verifies the signature of the XmlDocument instance using the key given as a parameter.
/// </summary>
/// <param name="doc">The doc.</param>
/// <param name="alg">The algorithm.</param>
/// <returns><code>true</code> if the document's signature can be verified. <code>false</code> if the signature could
/// not be verified.</returns>
/// <exception cref="InvalidOperationException">if the XmlDocument instance does not contain a signed XML document.</exception>
public static bool CheckSignature(XmlDocument doc, AsymmetricAlgorithm alg)
{
CheckDocument(doc);
var signedXml = RetrieveSignature(doc);
return signedXml.CheckSignature(alg);
}
开发者ID:jbparker,项目名称:SAML2,代码行数:15,代码来源:XmlSignatureUtils.cs
示例12: HttpConnection
public HttpConnection(Socket sock, EndPointListener epl, bool secure, X509Certificate2 cert, AsymmetricAlgorithm key)
{
this.sock = sock;
this.epl = epl;
this.secure = secure;
this.key = key;
var networkstream = new NetworkStream(sock, false);
if (secure)
{
var sslstream = new System.Net.Security.SslStream(networkstream);
sslstream.AuthenticateAsServer(cert);
stream = sslstream;
}
else
{
stream = networkstream;
}
timer = new Timer(OnTimeout, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
if (buffer == null)
{
buffer = new byte[BufferSize];
}
Init();
}
开发者ID:jamesaxl,项目名称:reactor,代码行数:34,代码来源:HttpConnection.cs
示例13: DSASignatureFormatter
public DSASignatureFormatter(AsymmetricAlgorithm key) : this()
{
if (key == null)
throw new ArgumentNullException(nameof(key));
_dsaKey = (DSA)key;
}
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:DSASignatureFormatter.cs
示例14: SetKey
public override void SetKey(AsymmetricAlgorithm key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
this._rsaKey = (RSA) key;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:RSAPKCS1SignatureDeformatter.cs
示例15: RSAPKCS1SignatureDeformatter
public RSAPKCS1SignatureDeformatter(AsymmetricAlgorithm key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
this._rsaKey = (RSA) key;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:RSAPKCS1SignatureDeformatter.cs
示例16: Connector
/// <summary>
/// This constructor allows the caller to provide a preloaded private key for use
/// when OAuth calls are made.
/// </summary>
/// <param name="consumerKey"></param>
/// <param name="privateKey"></param>
public Connector(string consumerKey, AsymmetricAlgorithm privateKey)
{
this.ConsumerKey = consumerKey;
this.privateKey = privateKey;
// Turns the handling of a 100 HTTP server response ON
System.Net.ServicePointManager.Expect100Continue = true;
}
开发者ID:rehabayar,项目名称:mastercard-api-csharp,代码行数:14,代码来源:Connector.cs
示例17: CreateFormatter
public override AsymmetricSignatureFormatter CreateFormatter(AsymmetricAlgorithm key)
{
if (key == null)
throw new ArgumentNullException(nameof(key));
var f = new RSAPKCS1SignatureFormatter(key);
f.SetHashAlgorithm(SHA_512);
return f;
}
开发者ID:nofuture-git,项目名称:31g,代码行数:8,代码来源:Misc.cs
示例18: XmlFileIsValid
public static bool XmlFileIsValid(string signedXmlPath,
AsymmetricAlgorithm key)
{
var signedXml = new XmlDocument { PreserveWhitespace = false };
signedXml.Load(signedXmlPath);
return XmlIsValid(signedXml, key);
}
开发者ID:huoxudong125,项目名称:HQF.Tutorial.Encryption,代码行数:8,代码来源:SignAndVerify.cs
示例19: RSAOAEPKeyExchangeDeformatter
public RSAOAEPKeyExchangeDeformatter(AsymmetricAlgorithm key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
this._rsaKey = (RSA) key;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:RSAOAEPKeyExchangeDeformatter.cs
示例20: RequestTokenService
public RequestTokenService(Environments.Environment environment, string consumerKey, AsymmetricAlgorithm privateKey)
: base(consumerKey, privateKey)
{
this.environment = environment;
// ignore possible security certificate errors
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
}
开发者ID:rehabayar,项目名称:mastercard-api-csharp,代码行数:8,代码来源:RequestTokenService.cs
注:本文中的System.Security.Cryptography.AsymmetricAlgorithm类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论