forked from cryptape/omnilock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcd9b58
commit 29fb4dd
Showing
11 changed files
with
599 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
#ifndef __BLAKE2B_DECL_ONLY_H__ | ||
#define __BLAKE2B_DECL_ONLY_H__ | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#define BLAKE2_PACKED(x) x __attribute__((packed)) | ||
|
||
enum blake2b_constant { | ||
BLAKE2B_BLOCKBYTES = 128, | ||
BLAKE2B_OUTBYTES = 64, | ||
BLAKE2B_KEYBYTES = 64, | ||
BLAKE2B_SALTBYTES = 16, | ||
BLAKE2B_PERSONALBYTES = 16 | ||
}; | ||
BLAKE2_PACKED(struct blake2b_param__ { | ||
uint8_t digest_length; /* 1 */ | ||
uint8_t key_length; /* 2 */ | ||
uint8_t fanout; /* 3 */ | ||
uint8_t depth; /* 4 */ | ||
uint32_t leaf_length; /* 8 */ | ||
uint32_t node_offset; /* 12 */ | ||
uint32_t xof_length; /* 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 */ | ||
}); | ||
|
||
typedef struct blake2b_param__ blake2b_param; | ||
|
||
typedef struct blake2b_state__ { | ||
uint64_t h[8]; | ||
uint64_t t[2]; | ||
uint64_t f[2]; | ||
uint8_t buf[BLAKE2B_BLOCKBYTES]; | ||
size_t buflen; | ||
size_t outlen; | ||
uint8_t last_node; | ||
} blake2b_state; | ||
|
||
/* Streaming API */ | ||
int ckb_blake2b_init(blake2b_state *S, size_t outlen); | ||
int blake2b_init(blake2b_state *S, size_t outlen); | ||
int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, | ||
size_t keylen); | ||
int blake2b_update(blake2b_state *S, const void *in, size_t inlen); | ||
int blake2b_final(blake2b_state *S, void *out, size_t outlen); | ||
/* Simple API */ | ||
int blake2b(void *out, size_t outlen, const void *in, size_t inlen, | ||
const void *key, size_t keylen); | ||
|
||
/* This is simply an alias for blake2b */ | ||
int blake2(void *out, size_t outlen, const void *in, size_t inlen, | ||
const void *key, size_t keylen); | ||
|
||
int blake2b_init_param(blake2b_state *S, const blake2b_param *P); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.