Discuss this help topic in SecureBlackbox Forum

XML: Use OpenPGP keys for signing

To sign the data with OpenPGP keys, you need to employ TElXMLKeyInfoPGPData class. All you need to do is

  1. Create an instance of TElXMLKeyInfoPGPData class.
  2. Load the OpenPGP secret key to the instance of TElPGPSecretKey class.
  3. Set the passphrase for the secret key to Passphrase property of TElXMLKeyInfoPGPData class.
  4. Set the loaded key to SecretKey property of TElXMLKeyInfoPGPData class. Note, that the original object is set. No copy is made.
  5. Set KeyData property of TElXMLSigner to the instance of TElXMLKeyInfoPGPData class which contains the key.
Additionally, you may need to set TElXMLKeyInfoPGPData.IncludeDataParam and TElXMLKeyInfoPGPData.IncludeKeyValue properties, that control, what data is included in PGPData element and whether KeyValue element should be created.


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

TElXMLKeyInfoPGPData PGPKeyData = new TElXMLKeyInfoPGPData(true);
PGPKeyData.SecretKey = new TElPGPSecretKey();
PGPKeyData.SecretKey.Passphrase = "password";
Signer.KeyData = PGPKeyData;

Signer.SignatureMethodType := xmtSig;
Signer.SignatureMethod := xsmRSA_SHA256; // using RSA with SHA 256-bit
PGPKeyData := TElXMLKeyInfoPGPData.Create(True);
PGPKeyData.SecretKey := TElPGPSecretKey.Create;
PGPKeyData.SecretKey.Passphrase := 'password';
Signer.KeyData := PGPKeyData;
// when signing is finished we need to clear KeyData object

How To articles about XML signing (XMLDSig and XAdES)

Discuss this help topic in SecureBlackbox Forum