aboutsummaryrefslogtreecommitdiff
path: root/com/BLAKE2/test_fns.c
blob: ca3551ac1fb7b916d28fe79aaa9fb7a26f00f11d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "blake2s.h"
#include <assert.h>
#include <stdio.h>

_Static_assert(sizeof(struct BLAKE2s_param) == (8 * sizeof(uint32_t)), "sizeof struct BLAKE2s_param");

int
main(void)
{
  assert(rotr_u32(0xdecafade, 16) == 0xfadedeca);
  assert(rotr_u32(0xdecafade, 8) == 0xdedecafa);

  union {
    struct BLAKE2s_param block;
    uint32_t data[8];
  } p;
  p.block.outlen = 32;
  p.block.keylen = 0;
  p.block.fanout = 1;
  p.block.depth = 1;
  p.block.leaf_length = 0;
  p.block.node_offset = 0;
  p.block.node_offset_ex = 0;
  p.block.node_depth = 0;
  p.block.inner_length = 0;
  p.block.salt = 0;
  p.block.personalization = 0;

  for (int i = 0; i < 8; ++i) printf("%08x ", p.data[i]);
  printf("\n");

  assert(p.data[0] == (0x01010000 ^ 32));

}