Update snapshot(2018-01-17)
[platform/upstream/iotivity.git] / extlibs / mbedtls / mbedtls / include / mbedtls / havege.h
1 /**
2  * \file havege.h
3  *
4  * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
5  *
6  *  Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
7  *  SPDX-License-Identifier: Apache-2.0
8  *
9  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
10  *  not use this file except in compliance with the License.
11  *  You may obtain a copy of the License at
12  *
13  *  http://www.apache.org/licenses/LICENSE-2.0
14  *
15  *  Unless required by applicable law or agreed to in writing, software
16  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  *  See the License for the specific language governing permissions and
19  *  limitations under the License.
20  *
21  *  This file is part of mbed TLS (https://tls.mbed.org)
22  */
23 #ifndef MBEDTLS_HAVEGE_H
24 #define MBEDTLS_HAVEGE_H
25
26 #include <stddef.h>
27
28 #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /**
35  * \brief          HAVEGE state structure
36  */
37 typedef struct
38 {
39     int PT1, PT2, offset[2];
40     int pool[MBEDTLS_HAVEGE_COLLECT_SIZE];
41     int WALK[8192];
42 }
43 mbedtls_havege_state;
44
45 /**
46  * \brief          HAVEGE initialization
47  *
48  * \param hs       HAVEGE state to be initialized
49  */
50 void mbedtls_havege_init( mbedtls_havege_state *hs );
51
52 /**
53  * \brief          Clear HAVEGE state
54  *
55  * \param hs       HAVEGE state to be cleared
56  */
57 void mbedtls_havege_free( mbedtls_havege_state *hs );
58
59 /**
60  * \brief          HAVEGE rand function
61  *
62  * \param p_rng    A HAVEGE state
63  * \param output   Buffer to fill
64  * \param len      Length of buffer
65  *
66  * \return         0
67  */
68 int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len );
69
70 #ifdef __cplusplus
71 }
72 #endif
73
74 #endif /* havege.h */