Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

– Adding the BLAKE3 hashing algorithm to fn:hash #1228

Merged
merged 13 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -5369,15 +5369,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 @@ -5393,9 +5395,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 @@ -5424,6 +5435,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 @@ -5433,7 +5457,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 @@ -32174,4 +32198,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 @@ -11197,6 +11197,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
Loading