aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-01 15:32:20 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-08-01 15:32:20 +0000
commitbc165e28aee689a45535afda8012c9b63f87b24c (patch)
tree193af8bed741664139376047f23ea084a0924d28
parent3cbee1e840ea1beff566555f1221b2791091e20c (diff)
Embelish documentation of new Hash functions
-rw-r--r--src/libutil/hash.hh13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh
index ffc397ce0..00ce7bb6f 100644
--- a/src/libutil/hash.hh
+++ b/src/libutil/hash.hh
@@ -36,21 +36,26 @@ struct Hash
/* Create a zero-filled hash object. */
Hash(HashType type);
- /* Initialize the hash from a string representation, in the format
+ /* Parse the hash from a string representation in the format
"[<type>:]<base16|base32|base64>" or "<type>-<base64>" (a
Subresource Integrity hash expression). If the 'type' argument
is not present, then the hash type must be specified in the
string. */
static Hash parseAny(std::string_view s, std::optional<HashType> type);
- /* hash type must be part of string */
+
+ /* Parse a hash from a string representation like the above, except the
+ type prefix is mandatory is there is no separate arguement. */
static Hash parseAnyPrefixed(std::string_view s);
- /* prefix parsed separately; non SRI hash */
+
+ /* Parse a plain hash that musst not have any prefix indicating the type.
+ The type is passed in to disambiguate. */
static Hash parseNonSRIUnprefixed(std::string_view s, HashType type);
static Hash parseSRI(std::string_view original);
private:
- // type must be provided, s must not include <type> prefix
+ /* The type must be provided, the string view must not include <type>
+ prefix. `isSRI` helps disambigate the various base-* encodings. */
Hash(std::string_view s, HashType type, bool isSRI);
public: