Blame lib/crypto_backend/argon2/encoding.h

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