How to fill the SigPolicyHash for XAdES

The digest value of the signature policy is calculated over the SigPolicyId \Identifier element. If the Identifier element contains a URI, then the hash is calculated on the downloaded file (for example using the TElHashFunction class), and in most cases you can cache the digest value.

Example: Calculating a digest value (Delphi)

var Data: ByteArray; // contains the data of the downloaded file
XAdESSigner.PolicyId.SigPolicyHash.DigestMethod := SBXMLSec.DigestMethodToURI(xdmSHA1);
XAdESSigner.PolicyId.SigPolicyHash.DigestValue := SBXMLSec.CalculateDigest(@Data[0], Length(Data), xdmSHA1); // or use TElHashFunction class to calculate a hash

Example: Filling DigestValue with a cached value (C#)

XAdESSigner.PolicyId.SigPolicyHash.DigestMethod = SBXMLSec.Unit.DigestMethodToURI(SBXMLSec.Unit.xdmSHA1);
XAdESSigner.PolicyId.SigPolicyHash.DigestValue = SBUtils.Unit.BytesOfString(

Ready to get started?

Learn more about SecureBlackbox or download a free trial.

Download Now