/// <summary> /// Default constructor /// </summary> public SignaturePolicyId() { this.sigPolicyId = new ObjectIdentifier("SigPolicyId"); this.transforms = new Transforms(); this.sigPolicyHash = new DigestAlgAndValueType("SigPolicyHash"); this.sigPolicyQualifiers = new SigPolicyQualifiers(); }
/// <summary> /// Load state from an XML element /// </summary> /// <param name="xmlElement">XML element containing new state</param> public void LoadXml(System.Xml.XmlElement xmlElement) { XmlNamespaceManager xmlNamespaceManager; XmlNodeList xmlNodeList; if (xmlElement == null) { throw new ArgumentNullException("xmlElement"); } xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable); xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri); xmlNodeList = xmlElement.SelectNodes("xsd:OCSPIdentifier", xmlNamespaceManager); if (xmlNodeList.Count == 0) { throw new CryptographicException("OCSPIdentifier missing"); } this.ocspIdentifier = new OCSPIdentifier(); this.ocspIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0)); xmlNodeList = xmlElement.SelectNodes("xsd:DigestAlgAndValue", xmlNamespaceManager); if (xmlNodeList.Count == 0) { this.digestAlgAndValue = null; } else { this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue"); this.digestAlgAndValue.LoadXml((XmlElement)xmlNodeList.Item(0)); } }
/// <summary> /// Load state from an XML element /// </summary> /// <param name="xmlElement">XML element containing new state</param> public void LoadXml(System.Xml.XmlElement xmlElement) { XmlNamespaceManager xmlNamespaceManager; XmlNodeList xmlNodeList; if (xmlElement == null) { throw new ArgumentNullException("xmlElement"); } xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable); xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl); xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri); xmlNodeList = xmlElement.SelectNodes("xsd:CertDigest", xmlNamespaceManager); if (xmlNodeList.Count == 0) { throw new CryptographicException("CertDigest missing"); } this.certDigest = new DigestAlgAndValueType("CertDigest"); this.certDigest.LoadXml((XmlElement)xmlNodeList.Item(0)); xmlNodeList = xmlElement.SelectNodes("xsd:IssuerSerial", xmlNamespaceManager); if (xmlNodeList.Count == 0) { throw new CryptographicException("IssuerSerial missing"); } this.issuerSerial = new IssuerSerial(); this.issuerSerial.LoadXml((XmlElement)xmlNodeList.Item(0)); }
/// <summary> /// Load state from an XML element /// </summary> /// <param name="xmlElement">XML element containing new state</param> public void LoadXml(System.Xml.XmlElement xmlElement) { XmlNamespaceManager xmlNamespaceManager; XmlNodeList xmlNodeList; if (xmlElement == null) { throw new ArgumentNullException("xmlElement"); } xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable); xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl); xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri); xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyId", xmlNamespaceManager); if (xmlNodeList.Count == 0) { throw new CryptographicException("SigPolicyId missing"); } this.sigPolicyId = new ObjectIdentifier("SigPolicyId"); this.sigPolicyId.LoadXml((XmlElement)xmlNodeList.Item(0)); xmlNodeList = xmlElement.SelectNodes("ds:Transforms", xmlNamespaceManager); if (xmlNodeList.Count != 0) { this.transforms = new Transforms(); this.transforms.LoadXml((XmlElement)xmlNodeList.Item(0)); } xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyHash", xmlNamespaceManager); if (xmlNodeList.Count == 0) { throw new CryptographicException("SigPolicyHash missing"); } this.sigPolicyHash = new DigestAlgAndValueType("SigPolicyHash"); this.sigPolicyHash.LoadXml((XmlElement)xmlNodeList.Item(0)); xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyQualifiers", xmlNamespaceManager); if (xmlNodeList.Count != 0) { this.sigPolicyQualifiers = new SigPolicyQualifiers(); this.sigPolicyQualifiers.LoadXml((XmlElement)xmlNodeList.Item(0)); } }
/// <summary> /// Default constructor /// </summary> public CRLRef() { this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue"); this.crlIdentifier = new CRLIdentifier(); }
/// <summary> /// Load state from an XML element /// </summary> /// <param name="xmlElement">XML element containing new state</param> public void LoadXml(System.Xml.XmlElement xmlElement) { XmlNamespaceManager xmlNamespaceManager; XmlNodeList xmlNodeList; if (xmlElement == null) { throw new ArgumentNullException("xmlElement"); } xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable); xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri); xmlNodeList = xmlElement.SelectNodes("xsd:DigestAlgAndValue", xmlNamespaceManager); if (xmlNodeList.Count == 0) { throw new CryptographicException("DigestAlgAndValue missing"); } this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue"); this.digestAlgAndValue.LoadXml((XmlElement)xmlNodeList.Item(0)); xmlNodeList = xmlElement.SelectNodes("xsd:CRLIdentifier", xmlNamespaceManager); if (xmlNodeList.Count == 0) { this.crlIdentifier = null; } else { this.crlIdentifier = new CRLIdentifier(); this.crlIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0)); } }
/// <summary> /// Default constructor /// </summary> public OCSPRef() { this.ocspIdentifier = new OCSPIdentifier(); this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue"); }
/// <summary> /// Default constructor /// </summary> public Cert() { this.certDigest = new DigestAlgAndValueType("CertDigest"); this.issuerSerial = new IssuerSerial(); }
public static void SetCertDigest(byte[] rawCert, string digestAlgorithm, DigestAlgAndValueType destination) { using (var hashAlg = GetHashAlg(digestAlgorithm)) { destination.DigestMethod.Algorithm = digestAlgorithm; destination.DigestValue = hashAlg.ComputeHash(rawCert); } }
public static void SetCertDigest(byte[] rawCert, DigestMethod digestMethod, DigestAlgAndValueType destination) { string digestAlgorithm = null; switch (digestMethod) { case DigestMethod.SHA1: digestAlgorithm = FirmaXades.SHA1Uri; break; case DigestMethod.SHA256: digestAlgorithm = FirmaXades.SHA256Uri; break; case DigestMethod.SHA512: digestAlgorithm = FirmaXades.SHA512Uri; break; } SetCertDigest(rawCert, digestAlgorithm, destination); }