Statistics
| Branch: | Revision:

iof-bird-daemon / lib / sha512.h @ c8cafc8e

History | View | Annotate | Download (1 KB)

1 f312a837 Pavel Tvrdík
/*
2 de2a27e2 Ondrej Zajicek (work)
 *        BIRD Library -- SHA-512 and SHA-384 Hash Functions
3 f312a837 Pavel Tvrdík
 *
4
 *        (c) 2015 CZ.NIC z.s.p.o.
5
 *
6
 *        Based on the code from libgcrypt-1.6.0, which is
7
 *        (c) 2003, 2006, 2008, 2009 Free Software Foundation, Inc.
8
 *
9
 *        Can be freely distributed and used under the terms of the GNU GPL.
10
 */
11
12
#ifndef _BIRD_SHA512_H_
13
#define _BIRD_SHA512_H_
14
15 5126380b Ondrej Zajicek (work)
#include "nest/bird.h"
16
17 f312a837 Pavel Tvrdík
18
#define SHA384_SIZE                 48
19
#define SHA384_HEX_SIZE                97
20
#define SHA384_BLOCK_SIZE        128
21
22
#define SHA512_SIZE                 64
23
#define SHA512_HEX_SIZE                129
24
#define SHA512_BLOCK_SIZE        128
25
26 5126380b Ondrej Zajicek (work)
27 de2a27e2 Ondrej Zajicek (work)
struct hash_context;
28
29 5126380b Ondrej Zajicek (work)
struct sha512_context {
30 de2a27e2 Ondrej Zajicek (work)
  u64  h0, h1, h2, h3, h4, h5, h6, h7;
31 5126380b Ondrej Zajicek (work)
  byte buf[SHA512_BLOCK_SIZE];
32
  uint nblocks;
33
  uint count;
34 f312a837 Pavel Tvrdík
};
35
36 5126380b Ondrej Zajicek (work)
#define sha384_context sha512_context
37 f312a837 Pavel Tvrdík
38
39 de2a27e2 Ondrej Zajicek (work)
void sha512_init(struct hash_context *ctx);
40
void sha384_init(struct hash_context *ctx);
41 f312a837 Pavel Tvrdík
42 de2a27e2 Ondrej Zajicek (work)
void sha512_update(struct hash_context *ctx, const byte *buf, uint len);
43
#define sha384_update sha512_update
44 f312a837 Pavel Tvrdík
45 de2a27e2 Ondrej Zajicek (work)
byte *sha512_final(struct hash_context *ctx);
46
#define sha384_final sha512_final
47 f312a837 Pavel Tvrdík
48 5126380b Ondrej Zajicek (work)
49 f312a837 Pavel Tvrdík
#endif /* _BIRD_SHA512_H_ */