Skip to content

Commit

Permalink
Merge pull request #1228 from dnovatchev/dn-hash-blake3
Browse files Browse the repository at this point in the history
– Adding the BLAKE3 hashing algorithm to fn:hash
  • Loading branch information
ndw authored Sep 3, 2024
2 parents 58638a0 + a7ef0c6 commit 9895610
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
38 changes: 31 additions & 7 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5371,15 +5371,17 @@ return normalize-unicode(concat($v1, $v2))</eg>
the value through <code>fn:upper-case(fn:normalize-space())</code>. </p>
<p>Conforming implementations <rfc2119>must</rfc2119> support the following
options and the functions referred to by them:</p>
<ulist>
<ulist>
<item><p><code>MD5</code>: the MD5 Message-Digest algorithm defined by <bibref
ref="rfc6151"/> (update to <bibref ref="rfc1321"/>).</p></item>
<item><p><code>SHA-1</code>: the <code>SHA-1</code> algorithm, defined by <bibref
<item><p><code>BLAKE3</code>: the <code>BLAKE3</code> algorithm defined by <bibref
ref="BLAKE3"/>.</p></item>
<item><p><code>CRC-32</code>: the <code>CRC-32</code> algorithm, defined by <bibref
ref="ieee802-3"/>. </p></item>
<item><p><code>SHA-1</code>: the <code>SHA-1</code> algorithm, defined by <bibref
ref="fips180-4"/>. </p></item>
<item><p><code>SHA-256</code>: the <code>SHA-256</code> algorithm, defined by <bibref
ref="fips180-4"/>. </p></item>
<item><p><code>CRC-32</code>: the <code>CRC-32</code> algorithm, defined by <bibref
ref="ieee802-3"/>. </p></item>
</ulist>
<p>Conforming implementations <rfc2119>may</rfc2119> support other checksum and
hash functions with implementation-defined semantics.</p>
Expand All @@ -5395,9 +5397,18 @@ return normalize-unicode(concat($v1, $v2))</eg>
</fos:errors>
<fos:notes>
<p>It is common for secure algorithms to be cryptographically broken, as has happened to
the algorithms <code>MD5</code> and <code>SHA-1</code>. Developers are responsible for
the algorithms <code>MD5</code>, <code>SHA-1</code>, and <code>SHA-256</code>.
And the <code>CRC-32</code> algorithm is not intended for cryptographic purposes.
Developers are responsible for
ensuring that the algorithm chosen meets any expected security protocols, if
relevant.</p>
<p>The <code>BLAKE3</code> algorithm is included in the list of hashing algorithms
because at the time of writing it appears to be a promising candidate as a secure and fast algorithm
that shows signs of gaining widespread support.
However, this is a fast moving field and the community group recognizes that this decision might eventually not stand the test of time.
As the technology evolves in the future, implementations are free to drop support for this algorithm and substitute another
that appears to better meet requirements.
</p>
<p>Additional security practices, such as salting, may be applied as a preprocessing step,
or <code>fn:hash()</code> can be incorporated into more complex functions.</p>
<p>In most cases, the <code>xs:hexBinary</code> output of the function will be sought in
Expand Down Expand Up @@ -5426,6 +5437,19 @@ return normalize-unicode(concat($v1, $v2))</eg>
<fos:result>xs:hexBinary("3C01BDBB26F358BAB27F267924AA2C9A03FCFDB8")</fos:result>
</fos:test>
<fos:test>
<fos:expression><eg>hash("ABC", { "algorithm": "BLAKE3" })
=> string() => lower-case()</eg></fos:expression>
<fos:result>"d1717274597cf0289694f75d96d444b992a096f1afd8e7bbfa6ebb1d360fedfc"</fos:result>
</fos:test>
<fos:test>
<fos:expression><eg>hash("ABC", { "algorithm": "BLAKE3" })
=> xs:base64Binary() => string()</eg></fos:expression>
<fos:result>"0XFydFl88CiWlPddltREuZKglvGv2Oe7+m67HTYP7fw="</fos:result>
</fos:test>
<fos:test>
<fos:expression><eg>hash("ABC", { "algorithm": "sha-256" })
=> string()</eg></fos:expression>
<fos:result>"B5D4045C3F466FA91FE2CC6ABE79232A1A57CDF104F7A26E716E0A1E2789DF78"</fos:result>
<fos:expression><eg>hash("ABC", { "algorithm": "sha-256" })</eg></fos:expression>
<fos:result>xs:hexBinary("B5D4045C3F466FA91FE2CC6ABE79232A1A57CDF104F7A26E716E0A1E2789DF78")</fos:result>
</fos:test>
Expand All @@ -5435,7 +5459,7 @@ return normalize-unicode(concat($v1, $v2))</eg>
</fos:test>
<fos:test use="v-hash-doc">
<fos:expression><eg>hash(serialize($doc), { "algorithm": "sha-1" })
=> xs:base64Binary()
=> xs:base64Binary()
=> string()</eg></fos:expression>
<fos:result>"8PzN28NtxQv5RlxQ5/w6DcnrpEU="</fos:result>
</fos:test>
Expand Down Expand Up @@ -32212,4 +32236,4 @@ return pin($data)??languages[. = 'German'] ! label()?path()[1]</eg></fos:express
</fos:changes>
</fos:function>

</fos:functions>
</fos:functions>
4 changes: 4 additions & 0 deletions specifications/xpath-functions-40/src/xpath-functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11204,6 +11204,10 @@ currently, Version 9.0.0.
<div2 id="non-normative-biblio">
<head>Non-normative references</head>
<blist>
<bibl id="BLAKE3" key="BLAKE3 Hashing">
<emph>Blake3 Algorithm Specification</emph>. Available at:
<loc href="https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf">https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf</loc>
</bibl>
<bibl id="CALCALC"
key="Calendrical Calculations">Edward M. Reingold and Nachum Dershowitz.
<emph>Calendrical Calculations Millennium edition (2nd Edition)</emph>. Cambridge University Press,
Expand Down

0 comments on commit 9895610

Please sign in to comment.