Discuss this help topic in SecureBlackbox Forum

XML: Use raw keys for signing

To sign using RSA / DSA / ECDSA / GOST raw key you would need to

  1. set TElXMLSigner.SignatureMethodType property to xmtSig;
  2. set SignatureMethod property to desired signature algorithm;
  3. create the needed asymmetric key data object of TElXMLKeyInfoRSAData / TElXMLKeyInfoDSAData / TElXMLKeyInfoECData / TElXMLKeyInfoGOST2001Data type;
  4. load the key into the created key data object.

C#:


Signer.SignatureMethodType = TElXMLSigMethodType.xmtSig;
Signer.SignatureMethod = TElXMLSignatureMethod.xsmRSA_SHA256;

TElXMLKeyInfoRSAData RSAKeyData = new TElXMLKeyInfoRSAData(true);
RSAKeyData.RSAKeyMaterial.Passphrase = "password";
RSAKeyData.RSAKeyMaterial.LoadSecret(FileStream);
Signer.KeyData = RSAKeyData;
Delphi:

Signer.SignatureMethodType := xmtSig;
Signer.SignatureMethod := xsmRSA_SHA256; // using RSA with SHA 256-bit
...
RSAKeyData := TElXMLKeyInfoRSAData.Create(True);
RSAKeyData.RSAKeyMaterial.Passphrase := 'password';
RSAKeyData.RSAKeyMaterial.LoadSecret(FileStream);
Signer.KeyData := RSAKeyData;
...
// when signing is finished we need to clear KeyData object
RSAKeyData.Free();

How To articles about XML signing (XMLDSig and XAdES)

Discuss this help topic in SecureBlackbox Forum