Name

p:hash — The standard p:hash step.

Synopsis

The p:hash step generates a hash, or digital “fingerprint”, for some value and injects it into the source document.

Input portPrimarySequenceContent types
source✔  xml html 
Output portPrimarySequenceContent types
result✔  text xml html 
Option nameTypeDefault valueRequired
algorithmxs:QName ✔ 
valuexs:string ✔ 
matchXSLTSelectionPattern'/*/node()' 
parametersmap(xs:QName,item()*)?() 
versionxs:string?() 
Declaration
 1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
   |   <p:input port="source" primary="true" content-types="xml html"/>
   |   <p:output port="result" content-types="text xml html"/>
   |   <p:option name="parameters" as="map(xs:QName,item()*)?"/>
 5 |   <p:option name="value" required="true" as="xs:string"/>
   |   <p:option name="algorithm" required="true" as="xs:QName"/>
   |   <p:option xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax"
   |             name="match"
   |             as="xs:string"
10 |             select="'/*/node()'"
   |             e:type="XSLTSelectionPattern"/>
   |   <p:option name="version" as="xs:string?"/>
   |</p:declare-step>
Errors
CodeDescription
err:XC0036It is a dynamic error (err:XC0036) if the requested hash algorithm is not one that the processor understands or if the value or parameters are not appropriate for that algorithm.
Implementation defined features

Description

The p:hash step is defined in the XProc 3.0: Standard Step Library. It is also described on XProcRef.org.

Supported algorithms

The crc, md, and sha algorithms are supported as well as cx:hmac and cx:blake3.

crc

Generates a CRC-32 checksum. The default, and only accepted, version for the crc algorithm is “32”.

md

Generates an MD2 or MD5 digest. The default version for the md algorithm is “5”. XML Calabash defers implementation to the JVM MessageDigest class.

The MD2 digest algorithm is defined in RFC 1319. The MD5 digest algorithm is defined in RFC 1321.

sha

Generates a SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, or SHA-512/256 digest. The default version for the sha algorithm is “1”. XML Calabash defers implementation to the JVM MessageDigest class.

The digest algorithms are defined in FIPS 180-4.

cx:hmac

Generates an HMAC signature with the HMAC SHA1 algorithm. The version option is ignored. The algorithm requires an access key which must be provided in the access-key property of the parameters option.

cx:blake3

Generates a Blake3 digest. The version option is ignored. XML Calabash defers implementation to the Apache Commons Codec project.

  • If no parameters are provided, a Blake3 hash is generated.

  • If a key property is provided in the parameters option, a Blake3 keyed hash is generated.

    If a key is provided, no other properties may be provided.

  • If a shared-secret, sender-id, and recipient-id are all provided in the parameters option, a Blake3 key derivation digest is generated.

    If any of shared-secret, sender-id, or recipient-id are provided, they must all be provided. No other properties may be provided.

No other algorithms are supported at this time.