83 lines
3.8 KiB
C#
83 lines
3.8 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace System.Security.Cryptography
|
|
{
|
|
/// <summary>Verifies a Digital Signature Algorithm (<see cref="T:System.Security.Cryptography.DSA" />) PKCS#1 v1.5 signature.</summary>
|
|
// Token: 0x020004FC RID: 1276
|
|
[ComVisible(true)]
|
|
public class DSASignatureDeformatter : AsymmetricSignatureDeformatter
|
|
{
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.DSASignatureDeformatter" /> class.</summary>
|
|
// Token: 0x06002F31 RID: 12081 RVA: 0x0009808C File Offset: 0x0009628C
|
|
public DSASignatureDeformatter()
|
|
{
|
|
}
|
|
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Cryptography.DSASignatureDeformatter" /> class with the specified key.</summary>
|
|
/// <param name="key">The instance of Digital Signature Algorithm (<see cref="T:System.Security.Cryptography.DSA" />) that holds the key. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="key" /> is null.</exception>
|
|
// Token: 0x06002F32 RID: 12082 RVA: 0x00098094 File Offset: 0x00096294
|
|
public DSASignatureDeformatter(AsymmetricAlgorithm key)
|
|
{
|
|
this.SetKey(key);
|
|
}
|
|
|
|
/// <summary>Specifies the hash algorithm for the Digital Signature Algorithm (<see cref="T:System.Security.Cryptography.DSA" />) signature deformatter.</summary>
|
|
/// <param name="strName">The name of the hash algorithm to use for the signature deformatter. </param>
|
|
/// <exception cref="T:System.Security.Cryptography.CryptographicUnexpectedOperationException">The <paramref name="strName" /> parameter does not map to the <see cref="T:System.Security.Cryptography.SHA1" /> hash algorithm. </exception>
|
|
// Token: 0x06002F33 RID: 12083 RVA: 0x000980A4 File Offset: 0x000962A4
|
|
public override void SetHashAlgorithm(string strName)
|
|
{
|
|
if (strName == null)
|
|
{
|
|
throw new ArgumentNullException("strName");
|
|
}
|
|
try
|
|
{
|
|
SHA1.Create(strName);
|
|
}
|
|
catch (InvalidCastException)
|
|
{
|
|
throw new CryptographicUnexpectedOperationException(Locale.GetText("DSA requires SHA1"));
|
|
}
|
|
}
|
|
|
|
/// <summary>Specifies the key to be used for the Digital Signature Algorithm (<see cref="T:System.Security.Cryptography.DSA" />) signature deformatter.</summary>
|
|
/// <param name="key">The instance of <see cref="T:System.Security.Cryptography.DSA" /> that holds the key. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="key" /> is null.</exception>
|
|
// Token: 0x06002F34 RID: 12084 RVA: 0x00098100 File Offset: 0x00096300
|
|
public override void SetKey(AsymmetricAlgorithm key)
|
|
{
|
|
if (key != null)
|
|
{
|
|
this.dsa = (DSA)key;
|
|
return;
|
|
}
|
|
throw new ArgumentNullException("key");
|
|
}
|
|
|
|
/// <summary>Verifies the Digital Signature Algorithm (<see cref="T:System.Security.Cryptography.DSA" />) signature on the data.</summary>
|
|
/// <returns>true if the signature is valid for the data; otherwise, false.</returns>
|
|
/// <param name="rgbHash">The data signed with <paramref name="rgbSignature" />. </param>
|
|
/// <param name="rgbSignature">The signature to be verified for <paramref name="rgbHash" />. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="rgbHash" /> is null.-or-<paramref name="rgbSignature" /> is null.</exception>
|
|
/// <exception cref="T:System.Security.Cryptography.CryptographicUnexpectedOperationException">The DSA key is missing.</exception>
|
|
// Token: 0x06002F35 RID: 12085 RVA: 0x00098130 File Offset: 0x00096330
|
|
public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature)
|
|
{
|
|
if (this.dsa == null)
|
|
{
|
|
throw new CryptographicUnexpectedOperationException(Locale.GetText("missing key"));
|
|
}
|
|
return this.dsa.VerifySignature(rgbHash, rgbSignature);
|
|
}
|
|
|
|
// Token: 0x04001346 RID: 4934
|
|
private DSA dsa;
|
|
}
|
|
}
|