2022-03-21 14:25:48 +00:00
|
|
|
#ifndef COSMOPOLITAN_THIRD_PARTY_ARGON2_BLAKE2_H_
|
|
|
|
#define COSMOPOLITAN_THIRD_PARTY_ARGON2_BLAKE2_H_
|
2021-09-28 05:58:51 +00:00
|
|
|
#include "third_party/argon2/argon2.h"
|
2022-03-21 14:25:48 +00:00
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
2021-09-28 05:58:51 +00:00
|
|
|
COSMOPOLITAN_C_START_
|
2021-09-15 23:57:18 +00:00
|
|
|
|
|
|
|
enum blake2b_constant {
|
2022-03-21 14:25:48 +00:00
|
|
|
BLAKE2B_BLOCKBYTES = 128,
|
|
|
|
BLAKE2B_OUTBYTES = 64,
|
|
|
|
BLAKE2B_KEYBYTES = 64,
|
|
|
|
BLAKE2B_SALTBYTES = 16,
|
|
|
|
BLAKE2B_PERSONALBYTES = 16
|
2021-09-15 23:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct __blake2b_param {
|
2022-03-21 14:25:48 +00:00
|
|
|
uint8_t digest_length; /* 1 */
|
|
|
|
uint8_t key_length; /* 2 */
|
|
|
|
uint8_t fanout; /* 3 */
|
|
|
|
uint8_t depth; /* 4 */
|
|
|
|
uint8_t leaf_length[4]; /* 8 */
|
|
|
|
uint8_t node_offset[8]; /* 16 */
|
|
|
|
uint8_t node_depth; /* 17 */
|
|
|
|
uint8_t inner_length; /* 18 */
|
|
|
|
uint8_t reserved[14]; /* 32 */
|
|
|
|
uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */
|
|
|
|
uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */
|
2021-09-15 23:57:18 +00:00
|
|
|
} blake2b_param;
|
|
|
|
|
|
|
|
typedef struct __blake2b_state {
|
2022-03-21 14:25:48 +00:00
|
|
|
uint64_t h[8];
|
|
|
|
uint64_t t[2];
|
|
|
|
uint64_t f[2];
|
|
|
|
uint8_t buf[BLAKE2B_BLOCKBYTES];
|
|
|
|
unsigned buflen;
|
|
|
|
unsigned outlen;
|
|
|
|
uint8_t last_node;
|
2021-09-15 23:57:18 +00:00
|
|
|
} blake2b_state;
|
|
|
|
|
|
|
|
/* Streaming API */
|
2022-03-21 14:25:48 +00:00
|
|
|
int blake2b_init(blake2b_state *, size_t);
|
|
|
|
int blake2b_init_key(blake2b_state *, size_t, const void *, size_t);
|
|
|
|
int blake2b_init_param(blake2b_state *, const blake2b_param *);
|
|
|
|
int blake2b_update(blake2b_state *, const void *, size_t);
|
|
|
|
int blake2b_final(blake2b_state *, void *, size_t);
|
2021-09-15 23:57:18 +00:00
|
|
|
|
|
|
|
/* Simple API */
|
2022-03-21 14:25:48 +00:00
|
|
|
int blake2b(void *, size_t, const void *, size_t, const void *, size_t);
|
|
|
|
int blake2b_long(void *, size_t, const void *, size_t);
|
2021-09-15 23:57:18 +00:00
|
|
|
|
2021-09-28 05:58:51 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
2022-03-21 14:25:48 +00:00
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_THIRD_PARTY_ARGON2_BLAKE2_H_ */
|