Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
Blake2b cryptographic hash function More...
#include <assert.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
Macros | |
#define | bb 128 |
for asserts | |
#define | KK_MAX 64 |
@define KK_MAX | |
#define | NN_MAX 64 |
@define NN_MAX | |
#define | CEIL(a, b) (((a) / (b)) + ((a) % (b) != 0)) |
@define CEIL | |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
@define MIN | |
#define | MAX(a, b) ((a) > (b) ? (a) : (b)) |
@define MAX | |
#define | ROTR64(n, offset) (((n) >> (offset)) ^ ((n) << (64 - (offset)))) |
@define ROTR64 | |
#define | U128_ZERO |
@define U128_ZERO | |
Typedefs | |
typedef uint64_t | u128[2] |
128-bit number represented as two uint64's | |
typedef uint64_t | block_t[bb/sizeof(uint64_t)] |
Padded input block containing bb bytes. | |
Functions | |
static void | u128_fill (u128 dest, size_t n) |
put value of n into dest | |
static void | u128_increment (u128 dest, uint64_t n) |
increment an 128-bit number by a given amount | |
static void | G (block_t v, uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint64_t x, uint64_t y) |
blake2b mixing function G | |
static void | F (uint64_t h[8], block_t m, u128 t, int f) |
compression function F | |
static int | BLAKE2B (uint8_t *dest, block_t *d, size_t dd, u128 ll, uint8_t kk, uint8_t nn) |
driver function to perform the hashing as described in specification | |
uint8_t * | blake2b (const uint8_t *message, size_t len, const uint8_t *key, uint8_t kk, uint8_t nn) |
static void | assert_bytes (const uint8_t *expected, const uint8_t *actual, uint8_t len) |
Self-test implementations. | |
int | main () |
Main function. | |
Variables | |
static const uint8_t | R1 = 32 |
Rotation constant 1 for mixing function G. | |
static const uint8_t | R2 = 24 |
Rotation constant 2 for mixing function G. | |
static const uint8_t | R3 = 16 |
Rotation constant 3 for mixing function G. | |
static const uint8_t | R4 = 63 |
Rotation constant 4 for mixing function G. | |
static const uint64_t | blake2b_iv [8] |
BLAKE2b Initialization vector blake2b_iv[i] = floor(2**64 * frac(sqrt(prime(i+1)))), where prime(i) is the i:th prime number. | |
static const uint8_t | blake2b_sigma [12][16] |
word schedule permutations for each round of the algorithm | |
Blake2b cryptographic hash function
The Blake2b cryptographic hash function provides hashes for data that are secure enough to be used in cryptographic applications. It is designed to perform optimally on 64-bit platforms. The algorithm can output digests between 1 and 64 bytes long, for messages up to 128 bits in length. Keyed hashing is also supported for keys up to 64 bytes in length.
|
static |
Self-test implementations.
int main | ( | void | ) |
Main function.