summaryrefslogtreecommitdiff
path: root/src/include/s390_drbg_sha512.h
blob: d4458f8c872b1d038fdbe4c87b3cb3a04f5ad3d5 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * This program is released under the Common Public License V1.0
 *
 * You should have received a copy of Common Public License V1.0 along with
 * with this program.
 *
 * DRBG conforming to NIST SP800-90A
 *
 * Author(s): Patrick Steuer <patrick.steuer@de.ibm.com>
 *
 * Copyright IBM Corp. 2015
 */

#ifndef S390_DRBG_SHA512_H
#define S390_DRBG_SHA512_H

#include <stdint.h>

#include "ica_api.h"

#define DRBG_SHA512_SEED_LEN (888 / 8)

/*
 * SHA-512 DRBG mechanism working state type (see POP)
 */
struct drbg_sha512_ws{
	uint32_t rsvd0;				/* padding */
	uint32_t reseed_ctr;			/* reseed counter */
	uint64_t stream_bytes;			/* no. of generated bytes */
	unsigned char rsvd1;			/* padding */
	unsigned char v[DRBG_SHA512_SEED_LEN];	/* V */
	unsigned char rsvd2;			/* padding */
	unsigned char c[DRBG_SHA512_SEED_LEN];	/* C */
};

/*
 * SHA-512 DRBG mechanism functions
 */
int drbg_sha512_instantiate(void **ws,
			    int sec_strength,
			    const unsigned char *pers,
			    size_t pers_len,
			    const unsigned char *entropy,
			    size_t entropy_len,
			    const unsigned char *nonce,
			    size_t nonce_len);

int drbg_sha512_instantiate_ppno(void **ws,
				 int sec_strength,
				 const unsigned char *pers,
				 size_t pers_len,
				 const unsigned char *entropy,
				 size_t entropy_len,
				 const unsigned char *nonce,
				 size_t nonce_len);

int drbg_sha512_reseed(void *ws,
		       const unsigned char *add,
		       size_t add_len,
		       const unsigned char *entropy,
		       size_t entropy_len);

int drbg_sha512_reseed_ppno(void *ws,
			    const unsigned char *add,
			    size_t add_len,
			    const unsigned char *entropy,
			    size_t entropy_len);

int drbg_sha512_generate(void *ws,
			 const unsigned char *add,
			 size_t add_len,
			 unsigned char *prnd,
			 size_t prnd_len);

int drbg_sha512_generate_ppno(void *ws,
			      const unsigned char *add,
			      size_t add_len,
			      unsigned char *prnd,
			      size_t prnd_len);

int drbg_sha512_uninstantiate(void **ws,
			      bool test_mode);

int drbg_sha512_health_test(void *func,
			    int sec,
			    bool pr);

#endif