Sign with a named key and verify using the keystore

Use if the sender and the receiver exchange multiple XML documents signed with different keys.

How to sign

  1. Create a HMAC, RSA or DSA key with the constructor of the CryptoKey class.
  2. Set the HMAC key or load the RSA or DSA key in the CryptoKey object.
  3. Set the KeyName feature with the name identifying the key.
  4. Create a blank signature with the constructor of the Signature class.
  5. Assign the CryptoKey object to the Signature object.
  6. Create one or more references to be signed.
  7. Compute the signature.
  8. Retrieve the XML signature document from the Signature object.

How to verify

  1. Create a HMAC, RSA or DSA key with the constructor of the CryptoKey.
  2. Set the HMAC key or load the RSA or DSA key in the CryptoKey object.
  3. Set the KeyName feature with the name identifying the key.
  4. Register the key to be used by key name for any signature verification.
  5. Create a signature with the constructor of the Signature class and from a XML signature node obtained after the above compute operation.
  6. Verify the signature validity.
Note: It is recommended that steps 1 to 4 are done once at application start-up for each key used in the application. Steps 5 - 6 can then be executed quickly for any XML signature to be checked.