Discuss this help topic in SecureBlackbox Forum

XML: Set signature policy ID

The signature policy is a set of rules for the creation and validation of an electronic signature, under which the signature can be determined to be valid. The signature policy can be identified in two ways: it can contain an explicit and unambiguous identifier of a signature policy together with a hash value of the signature policy (SigPolicyId element) or it can use SignaturePolicyImplied element. The SigPolicyId element contains an identifier, which uniquely identifies a specific version of the signature policy. To add this element, use TElXAdESSigner.PolicyId property. The digest value of the signature policy is calculated over SigPolicyId\Identifier element. If Identifier element contains an URI, then the hash is calculated on the downloaded file (for example using TElHashFunction class), in most cases you can cache this digest value.


XAdESSigner.PolicyId.SigPolicyId.Identifier = URL;
XAdESSigner.PolicyId.SigPolicyId.IdentifierQualifier = SBXMLXAdES.__Global.xqtOIDAsURI;
XAdESSigner.PolicyId.SigPolicyId.Description = "Description";
XAdESSigner.PolicyId.SigPolicyId.DocumentationReferences.Add("Documentation reference");
XAdESSigner.PolicyId.SigPolicyHash.DigestMethod = SBXMLSec.__Global.DigestMethodToURI(xdmSHA1);
ByteArray Buf = DownloadData(URL);
XAdESSigner.PolicyId.SigPolicyHash.DigestValue =
  SBXMLSec.__Global.CalculateDigest(Buf, SBXMLAdES.__Global.xdmSHA1); // or use TElHashFunction class to calculate a hash

XAdESSigner.PolicyId.SigPolicyId.Identifier := URL;
XAdESSigner.PolicyId.SigPolicyId.IdentifierQualifier := xqtOIDAsURI;
XAdESSigner.PolicyId.SigPolicyId.Description := 'Description';
XAdESSigner.PolicyId.SigPolicyId.DocumentationReferences.Add('Documentation reference');
XAdESSigner.PolicyId.SigPolicyHash.DigestMethod := SBXMLSec.DigestMethodToURI(xdmSHA1);
Buf := DownloadData(URL);
XAdESSigner.PolicyId.SigPolicyHash.DigestValue :=
  SBXMLSec.CalculateDigest(@Buf[0], Length(Buf), xdmSHA1); // or use TElHashFunction class to calculate a hash

How To articles about XML signing (XMLDSig and XAdES)

Discuss this help topic in SecureBlackbox Forum