SecureBlackbox 16: How to fill the SigPolicyHash for XAdES

Note: This article applies only to SecureBlackbox Legacy. For future development please consider using the latest version.

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(
  SBEncoding.Unit.Base64DecodeString("zURNiVLyZRVTImCjiv/NKLQiq4M=="));

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.