Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

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