aboutsummaryrefslogtreecommitdiffstats
path: root/libar2simplified.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-02-15 16:21:36 +0100
committerMattias Andrée <maandree@kth.se>2022-02-15 16:21:36 +0100
commitf74764136b8b0564aa0e75e5c667b9d11158a2a9 (patch)
tree4b21592981aa6e06ecd4b336e2ad940cc8957613 /libar2simplified.h
parentAdd libar2simplified_init_context (diff)
downloadlibar2simplified-f74764136b8b0564aa0e75e5c667b9d11158a2a9.tar.gz
libar2simplified-f74764136b8b0564aa0e75e5c667b9d11158a2a9.tar.bz2
libar2simplified-f74764136b8b0564aa0e75e5c667b9d11158a2a9.tar.xz
Add libar2simplified_decode_r
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libar2simplified.h')
-rw-r--r--libar2simplified.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/libar2simplified.h b/libar2simplified.h
index 0d005fb..e58e68c 100644
--- a/libar2simplified.h
+++ b/libar2simplified.h
@@ -105,6 +105,52 @@ struct libar2_argon2_parameters *
libar2simplified_decode(const char *str, char **tagp, char **endp, int (*random_byte_generator)(char *out, size_t n));
/**
+ * Decode hashing parameters
+ *
+ * If the salt's lengths is encoded, but not an
+ * actual salt, a random salt will be created
+ *
+ * The hashing string does not encode information
+ * about `params->key` or `params->ad`, therefore
+ * `params->key` and `params->ad` will be set to
+ * `NULL` and `params->keylen` and `params->adlen`
+ * will be set to 0; where `params` is the returned
+ * pointer
+ *
+ * @param str The hashing parameter string to decode
+ * @param tagp Output parameter for the tag (hash result), or `NULL`.
+ * Unless `NULL`, `NULL` will be stored in `*tagp` if `str`
+ * includes a tag length instead of an actual tag, otherwise
+ * unless `NULL`, the beginning of the tag, in `str`, will
+ * be stored in `*tagp`. `*endp` will (unless `endp` or
+ * `*tagp` is `NULL`) mark the end of the tag.
+ * @param endp Output parameter for the end of the hashing parameter
+ * string, or `NULL`. Unless `NULL`, one position beyond the
+ * last byte in `str` determined to be part of the hashing
+ * parameter string will be stored in `*endp`. The application
+ * shall make sure that `**endp` is a valid termination of
+ * the hashing parameter string; typically this would be a ':'
+ * or a NUL byte.
+ * @param random_byte_generator Random number generator function, used to generate salt if
+ * `str` does not contain one. The function shall output `n`
+ * random bytes (only the lower 6 bits in each byte need to
+ * be random) to `out` and return 0. On failure, the function
+ * shall return -1. If `NULL`, the function will use a random
+ * number generator provided by the C standard library or the
+ * operating system.
+ * @param user_data Will be parsed as is as the third argument of
+ * `random_byte_generator` and is otherwise unused.
+ * @return Decoded hashing parameters. Shall be deallocated using
+ * free(3) when no longer needed. Be aware than the allocation
+ * size of the returned object will exceed the size of the
+ * return type.
+ */
+LIBAR2_PUBLIC__ LIBAR2_NONNULL__(1)
+struct libar2_argon2_parameters *
+libar2simplified_decode_r(const char *str, char **tagp, char **endp,
+ int (*random_byte_generator)(char *out, size_t n, void *user_data), void *user_data);
+
+/**
* Calculate a password hash
*
* @param hash Output parameter for the tag (hash result).