Discuss this help topic in SecureBlackbox Forum

XML: Change prefix of elements

By default the EncryptedData element is generated with default prefix:


<EncryptedData Type="..."
  xmlns="http://www.w3.org/2001/04/xmlenc#"
  xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
  xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
...
</EncryptedData>

If you need to change the prefix of encryption elements, then you need to use TElXMLEncryptedData.EncryptionPrefix property. The instance of TElXMLEncryptedData class can be accessed using TElXMLEncryptor.EncryptedData property after it has been generated by TElXMLEncryptor.Encrypt() method.

If you need to change the prefix of XML-DSig elements (such as ds:KeyInfo element), then you need to use TElXMLEncryptedData.SignaturePrefix property of the above mentioned instance of TElXMLEncryptedData class.

The default value of EncryptionPrefix property is "#default xenc" and the default value of SignaturePrefix property is "ds".

If you change prefixes with the below code,

C#:


Encryptor.Encrypt(...);
...
Encryptor.EncryptedData.EncryptionPrefix = "xenc";
Encryptor.EncryptedData.SignaturePrefix = "dsig";
Delphi:

Encryptor.Encrypt(...);
...
Encryptor.EncryptedData.EncryptionPrefix := 'xenc';
Encryptor.EncryptedData.SignaturePrefix := 'dsig';

then the resulting document will look like


<xenc:EncryptedData Type="..."
  xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
  xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
...
</xenc:EncryptedData>

How To articles about XML encryption (XMLEnc)

Discuss this help topic in SecureBlackbox Forum