aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/blake2.h
blob: 0add2ca50090be73ab99eacd152e4e4bb846829e (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

/*
   BLAKE2 reference source code package - reference C implementations

   Copyright 2012, Samuel Neves <sneves@dei.uc.pt>.  You may use this under the
   terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
   your option.  The terms of these licenses can be found at:

   - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
   - OpenSSL license   : https://www.openssl.org/source/license.html
   - Apache 2.0        : http://www.apache.org/licenses/LICENSE-2.0

   More information about the BLAKE2 hash function can be found at
   https://blake2.net.

   Note: This file has been modified/adapted to the SLUL project.
   It has been changed to be compatible with C89 compilers, and code that
   is not needed for SLUL has been removed (e.g. blake2b, safe memory
   clearing, etc.).

*/
#ifndef BLAKE2_H
#define BLAKE2_H

#include <stddef.h>
#include "compiler.h"

  enum blake2s_constant
  {
    BLAKE2S_BLOCKBYTES = 64,
    BLAKE2S_OUTBYTES   = 32,
    BLAKE2S_KEYBYTES   = 32,
    BLAKE2S_SALTBYTES  = 8,
    BLAKE2S_PERSONALBYTES = 8
  };

  typedef struct blake2s_state__
  {
    SlulInt h[8];
    SlulInt t[2];
    SlulInt f[2];
    unsigned char  buf[BLAKE2S_BLOCKBYTES];
    size_t   buflen;
    size_t   outlen;
    unsigned char  last_node;
  } blake2s_state;

  /* Streaming API */
  int blake2s_init( blake2s_state *S, size_t outlen );
  int blake2s_update( blake2s_state *S, const void *in, size_t inlen );
  /* Unlike the original blake2s_final, this one skips secure_zero_memory
     which is not needed for SLUL */
  int blake2s_final( blake2s_state *S, void *out, size_t outlen );

#endif