summaryrefslogtreecommitdiff
path: root/include/trng.h
blob: ca8144eeecb1fefa7cb2ba13bf586fd5ebf015e4 (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
/* Copyright 2015 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#ifndef __EC_INCLUDE_TRNG_H
#define __EC_INCLUDE_TRNG_H

#include <stddef.h>
#include <stdint.h>

#include <common.h>

#ifdef CONFIG_ZEPHYR
/*
 * Zephyr driver is responsible for initializing, enabling and disabling
 * hardware. In this case, trng_init() and trng_exit() does nothing.
 */
#define trng_init()
#define trng_exit()
#else
/**
 * Initialize the true random number generator.
 *
 * Not supported by all platforms.
 **/
void trng_init(void);

/**
 * Shutdown the true random number generator.
 *
 * The opposite operation of trng_init(), disable the hardware resources
 * used by the TRNG to save power.
 *
 * Not supported by all platforms.
 **/
void trng_exit(void);
#endif /* CONFIG_ZEPHYR */

/**
 * Output len random bytes into buffer.
 *
 * Not supported on all platforms.
 **/
void trng_rand_bytes(void *buffer, size_t len);

#endif /* __EC_INCLUDE_TRNG_H */