using System; using System.Runtime.InteropServices; using System.Text; using Mono.Security; namespace System.Security.Cryptography { /// Represents the abstract base class from which all implementations of the Digital Signature Algorithm () must inherit. // Token: 0x020004F9 RID: 1273 [ComVisible(true)] public abstract class DSA : AsymmetricAlgorithm { /// Creates the default cryptographic object used to perform the asymmetric algorithm. /// A cryptographic object used to perform the asymmetric algorithm. /// /// /// // Token: 0x06002F0B RID: 12043 RVA: 0x00097824 File Offset: 0x00095A24 public new static DSA Create() { return DSA.Create("System.Security.Cryptography.DSA"); } /// Creates the specified cryptographic object used to perform the asymmetric algorithm. /// A cryptographic object used to perform the asymmetric algorithm. /// The name of the specific implementation of to use. // Token: 0x06002F0C RID: 12044 RVA: 0x00097830 File Offset: 0x00095A30 public new static DSA Create(string algName) { return (DSA)CryptoConfig.CreateFromName(algName); } /// When overridden in a derived class, creates the signature for the specified data. /// The digital signature for the specified data. /// The data to be signed. // Token: 0x06002F0D RID: 12045 public abstract byte[] CreateSignature(byte[] rgbHash); /// When overridden in a derived class, exports the . /// The parameters for . /// true to include private parameters; otherwise, false. // Token: 0x06002F0E RID: 12046 public abstract DSAParameters ExportParameters(bool includePrivateParameters); // Token: 0x06002F0F RID: 12047 RVA: 0x00097840 File Offset: 0x00095A40 internal void ZeroizePrivateKey(DSAParameters parameters) { if (parameters.X != null) { Array.Clear(parameters.X, 0, parameters.X.Length); } } /// Reconstructs a object from an XML string. /// The XML string to use to reconstruct the object. /// The parameter is null. /// The format of the parameter is not valid. // Token: 0x06002F10 RID: 12048 RVA: 0x00097870 File Offset: 0x00095A70 public override void FromXmlString(string xmlString) { if (xmlString == null) { throw new ArgumentNullException("xmlString"); } DSAParameters dsaparameters = default(DSAParameters); try { dsaparameters.P = AsymmetricAlgorithm.GetNamedParam(xmlString, "P"); dsaparameters.Q = AsymmetricAlgorithm.GetNamedParam(xmlString, "Q"); dsaparameters.G = AsymmetricAlgorithm.GetNamedParam(xmlString, "G"); dsaparameters.J = AsymmetricAlgorithm.GetNamedParam(xmlString, "J"); dsaparameters.Y = AsymmetricAlgorithm.GetNamedParam(xmlString, "Y"); dsaparameters.X = AsymmetricAlgorithm.GetNamedParam(xmlString, "X"); dsaparameters.Seed = AsymmetricAlgorithm.GetNamedParam(xmlString, "Seed"); byte[] namedParam = AsymmetricAlgorithm.GetNamedParam(xmlString, "PgenCounter"); if (namedParam != null) { byte[] array = new byte[4]; Buffer.BlockCopy(namedParam, 0, array, 0, namedParam.Length); dsaparameters.Counter = BitConverterLE.ToInt32(array, 0); } this.ImportParameters(dsaparameters); } catch { this.ZeroizePrivateKey(dsaparameters); throw; } finally { this.ZeroizePrivateKey(dsaparameters); } } /// When overridden in a derived class, imports the specified . /// The parameters for . // Token: 0x06002F11 RID: 12049 public abstract void ImportParameters(DSAParameters parameters); /// Creates and returns an XML string representation of the current object. /// An XML string encoding of the current object. /// true to include private parameters; otherwise, false. // Token: 0x06002F12 RID: 12050 RVA: 0x000979A0 File Offset: 0x00095BA0 public override string ToXmlString(bool includePrivateParameters) { StringBuilder stringBuilder = new StringBuilder(); DSAParameters dsaparameters = this.ExportParameters(includePrivateParameters); try { stringBuilder.Append(""); stringBuilder.Append("

"); stringBuilder.Append(Convert.ToBase64String(dsaparameters.P)); stringBuilder.Append("

"); stringBuilder.Append(""); stringBuilder.Append(Convert.ToBase64String(dsaparameters.Q)); stringBuilder.Append(""); stringBuilder.Append(""); stringBuilder.Append(Convert.ToBase64String(dsaparameters.G)); stringBuilder.Append(""); stringBuilder.Append(""); stringBuilder.Append(Convert.ToBase64String(dsaparameters.Y)); stringBuilder.Append(""); if (dsaparameters.J != null) { stringBuilder.Append(""); stringBuilder.Append(Convert.ToBase64String(dsaparameters.J)); stringBuilder.Append(""); } if (dsaparameters.Seed != null) { stringBuilder.Append(""); stringBuilder.Append(Convert.ToBase64String(dsaparameters.Seed)); stringBuilder.Append(""); stringBuilder.Append(""); if (dsaparameters.Counter != 0) { byte[] bytes = BitConverterLE.GetBytes(dsaparameters.Counter); int num = bytes.Length; while (bytes[num - 1] == 0) { num--; } stringBuilder.Append(Convert.ToBase64String(bytes, 0, num)); } else { stringBuilder.Append("AA=="); } stringBuilder.Append(""); } if (dsaparameters.X != null) { stringBuilder.Append(""); stringBuilder.Append(Convert.ToBase64String(dsaparameters.X)); stringBuilder.Append(""); } else if (includePrivateParameters) { throw new ArgumentNullException("X"); } stringBuilder.Append("
"); } catch { this.ZeroizePrivateKey(dsaparameters); throw; } return stringBuilder.ToString(); } /// When overridden in a derived class, verifies the signature for the specified data. /// true if matches the signature computed using the specified hash algorithm and key on ; otherwise, false. /// The hash of the data signed with . /// The signature to be verified for . // Token: 0x06002F13 RID: 12051 public abstract bool VerifySignature(byte[] rgbHash, byte[] rgbSignature); } }