sandbox / mbedtls

Fork of mbedtls by Christopher Haster

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers havege.h Source File

havege.h

Go to the documentation of this file.
00001 /**
00002  * \file havege.h
00003  *
00004  * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
00005  *
00006  *  Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
00007  *  SPDX-License-Identifier: Apache-2.0
00008  *
00009  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
00010  *  not use this file except in compliance with the License.
00011  *  You may obtain a copy of the License at
00012  *
00013  *  http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  *  Unless required by applicable law or agreed to in writing, software
00016  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00017  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  *  See the License for the specific language governing permissions and
00019  *  limitations under the License.
00020  *
00021  *  This file is part of mbed TLS (https://tls.mbed.org)
00022  */
00023 #ifndef MBEDTLS_HAVEGE_H
00024 #define MBEDTLS_HAVEGE_H
00025 
00026 #include <stddef.h>
00027 
00028 #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 /**
00035  * \brief          HAVEGE state structure
00036  */
00037 typedef struct
00038 {
00039     int PT1, PT2, offset[2];
00040     int pool[MBEDTLS_HAVEGE_COLLECT_SIZE];
00041     int WALK[8192];
00042 }
00043 mbedtls_havege_state;
00044 
00045 /**
00046  * \brief          HAVEGE initialization
00047  *
00048  * \param hs       HAVEGE state to be initialized
00049  */
00050 void mbedtls_havege_init( mbedtls_havege_state *hs );
00051 
00052 /**
00053  * \brief          Clear HAVEGE state
00054  *
00055  * \param hs       HAVEGE state to be cleared
00056  */
00057 void mbedtls_havege_free( mbedtls_havege_state *hs );
00058 
00059 /**
00060  * \brief          HAVEGE rand function
00061  *
00062  * \param p_rng    A HAVEGE state
00063  * \param output   Buffer to fill
00064  * \param len      Length of buffer
00065  *
00066  * \return         0
00067  */
00068 int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len );
00069 
00070 #ifdef __cplusplus
00071 }
00072 #endif
00073 
00074 #endif /* havege.h */