2 * Argon2 reference source code package - reference C implementations
5 * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
7 * You may use this work under the terms of a Creative Commons CC0 1.0
8 * License/Waiver or the Apache Public License 2.0, at your option. The terms of
9 * these licenses can be found at:
11 * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
12 * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
14 * You should have received a copy of both of these licenses along with this
15 * software. If not, they may be obtained at the above URLs.
22 #define ARGON2_MAX_DECODED_LANES UINT32_C(255)
23 #define ARGON2_MIN_DECODED_SALT_LEN UINT32_C(8)
24 #define ARGON2_MIN_DECODED_OUT_LEN UINT32_C(12)
27 * encode an Argon2 hash string into the provided buffer. 'dst_len'
28 * contains the size, in characters, of the 'dst' buffer; if 'dst_len'
29 * is less than the number of required characters (including the
30 * terminating 0), then this function returns ARGON2_ENCODING_ERROR.
32 * on success, ARGON2_OK is returned.
34 int encode_string(char *dst, size_t dst_len, argon2_context *ctx,
38 * Decodes an Argon2 hash string into the provided structure 'ctx'.
39 * The only fields that must be set prior to this call are ctx.saltlen and
40 * ctx.outlen (which must be the maximal salt and out length values that are
41 * allowed), ctx.salt and ctx.out (which must be buffers of the specified
42 * length), and ctx.pwd and ctx.pwdlen which must hold a valid password.
44 * Invalid input string causes an error. On success, the ctx is valid and all
45 * fields have been initialized.
47 * Returned value is ARGON2_OK on success, other ARGON2_ codes on error.
49 int decode_string(argon2_context *ctx, const char *str, argon2_type type);
51 /* Returns the length of the encoded byte stream with length len */
52 size_t b64len(uint32_t len);
54 /* Returns the length of the encoded number num */
55 size_t numlen(uint32_t num);