From b72f63786fd3d8a3dcbf389bde5b8e1e4482fbb3 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sat, 4 Jan 2025 17:45:21 +0100 Subject: [PATCH] clean(docs): Clarify supported MAC Hash Functions for Resource Integrity --- docs/use/fetch/index.md | 12 ++++-- .../common/io/hashbrown/Multihashes.java | 40 ++++++++++++++++--- .../common/io/resource/IPFSResource.java | 3 +- learn/jbang/digests.java | 27 +++++++++++++ 4 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 learn/jbang/digests.java diff --git a/docs/use/fetch/index.md b/docs/use/fetch/index.md index 0edee1496..64e17e46e 100644 --- a/docs/use/fetch/index.md +++ b/docs/use/fetch/index.md @@ -170,9 +170,10 @@ the Charset from the Media Type (if any) or any HTTP header like mechanisms. ### Integrity -Add `?integrity=...` verifies resource integrity via a [cryptographic digest ("hash")])(https://docs.ipfs.tech/concepts/hashing/) -using a [Multiformats's Multibase encoded Multihash](https://www.multiformats.io), this works for all schemes: -(Similarly e.g. to [HTML's Subresource Integrity (SRI)](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).) +Adding `?integrity=...` verifies resources via a [cryptographic digest ("hash")](https://docs.ipfs.tech/concepts/hashing/) +using a [Multiformats's Multibase encoded Multihash](https://www.multiformats.io). +(This is similar e.g. to [HTML's Subresource Integrity (SRI)](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).) +It works for all schemes: ```bash cd ../.././.. $ ./enola fetch "/tmp/hi.txt?integrity=z8VxiEEn4n7uuGrVQjeoH2KYypytUHttCubqN7rr65xSH3wjLDjHciXuTyTHkoRuJT1Njghj68RQdynADQt9vzLgyEs" @@ -187,13 +188,16 @@ $ ./enola fetch --http-scheme "https://www.vorburger.ch/hello.md?integrity=z8Vtt ``` In order to find the expected Multibase encoded Multihash, -it's simplest to once use a wrong one, and then replace it with the correct one shown by the error message: +it's simplest to once use a wrong one, and then replace it with the correct one which is shown by the error message: ```bash $? cd ../.././.. $ ./enola fetch --http-scheme "https://www.vorburger.ch/hello.md?integrity=z8VsnXyGnRwJpnrQXB8KcLstvgFYGZ2f5BCm3DVndcNZ8NswtkCqsut69e7yd1FKNtettjgy669GNVt8VSTGxkAiJaB" ... ``` +Note that while [Multihash](https://www.multiformats.io/multihash/) defines codes for [various hash functions](https://github.com/multiformats/multicodec/blob/master/table.csv), +Enola (currently) [intentionally](https://github.com/google/guava/issues/5990#issuecomment-2571350434) only actually supports `sha2-256` & `sha2-512`. +