Esempio n. 1
0
 /// <summary>
 /// Verify the signature of an XML string against an asymmetric algorithm and return the result.
 /// </summary>
 /// <param name="xmlData">XML string which holds the signed XML data.</param>
 /// <param name="signingKey">RSA public key that is associated with the key that was used in signing the XML.</param>
 /// <returns>The status of the verification.</returns>
 /// <exception cref="NotSupportedException">The key algorithm is not supported.</exception>
 /// <exception cref="XmlException">There is a load or parse error in the XML.</exception>
 /// <exception cref="ArgumentNullException">Any of the passed arguments is null.</exception>
 /// <exception cref="CryptographicException">The key value is not an RSA key, or the key is unreadable.
 /// -OR- No signature found or more than one signature found.
 /// -OR- The value parameter does not contain a valid signature or signature info.
 /// -OR- The signature algorithm of the key parameter does not match the signature method.
 /// -OR- The signature description could not be created.
 /// -OR- The hash algorithm could not be created.</exception>
 public static bool VerifyXml(string xmlData, X509Certificate2 signingKey)
 {
     return(XMLSigning.VerifyXml(xmlData, signingKey));
 }
Esempio n. 2
0
 /// <summary>
 /// Verify the signature of an XML string that contains key info against an asymmetric algorithm and return the result.
 /// </summary>
 /// <param name="xmlData">XML document as a string which holds the signed XML data with key info tag.</param>
 /// <returns>The status of the verification.</returns>
 /// <exception cref="XmlException">There is a load or parse error in the XML.</exception>
 /// <exception cref="CryptographicException">No signature found or more than one signature found.
 /// -OR- The value parameter does not contain a valid signature or signature info.
 /// -OR- The signature algorithm of the key parameter does not match the signature method.
 /// -OR- The signature description could not be created.
 /// -OR- The hash algorithm could not be created.</exception>
 public static bool VerifyXml(string xmlData)
 {
     return(XMLSigning.VerifyXml(xmlData));
 }
Esempio n. 3
0
 /// <summary>
 /// Sign XML data.
 /// </summary>
 /// <param name="xmlData">XML object as a string which will be signed.</param>
 /// <param name="signingKey">The certificate which will be used in signing the XML document.</param>
 /// <param name="addKey">Flag to indicate if the public key should be included in the signed XML document or not (only RSA keys supported).</param>
 /// <param name="pin">The pin of the CNG certificate.</param>
 /// <returns>Signed XML string object.</returns>
 /// <exception cref="XmlException">There is a load or parse error in the XML.</exception>
 /// <exception cref="ArgumentNullException">Private key is null or any of the passed arguments is null.</exception>
 /// <exception cref="CryptographicException">The key value is not an RSA key, or the key is unreadable.</exception>
 /// <exception cref="NotSupportedException">The key algorithm for this private key is not supported.</exception>
 /// <exception cref="CryptographicUnexpectedOperationException">The X.509 keys do not match.</exception>
 /// <exception cref="ArgumentException">The cryptographic service provider key is null.</exception>
 public static string SignXml(string xmlData, X509Certificate2 signingKey, bool addKey, string pin)
 {
     return(XMLSigning.SignXml(xmlData, signingKey, addKey, pin));
 }