2009-01-03 21:22:43 +00:00
|
|
|
/**
|
|
|
|
* \file havege.h
|
2009-01-04 16:27:10 +00:00
|
|
|
*
|
2011-01-27 15:24:17 +00:00
|
|
|
* \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
|
2018-01-05 15:33:17 +00:00
|
|
|
*/
|
|
|
|
/*
|
2015-07-27 09:11:48 +00:00
|
|
|
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
2015-09-04 12:21:07 +00:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2010-07-18 20:36:00 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2010-07-18 20:36:00 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-01-04 16:27:10 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2009-01-04 16:27:10 +00:00
|
|
|
*
|
2015-09-04 12:21:07 +00:00
|
|
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
2009-01-03 21:22:43 +00:00
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
#ifndef MBEDTLS_HAVEGE_H
|
|
|
|
#define MBEDTLS_HAVEGE_H
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2015-02-06 13:43:58 +00:00
|
|
|
#include <stddef.h>
|
2011-11-27 21:07:34 +00:00
|
|
|
|
2015-04-08 10:49:31 +00:00
|
|
|
#define MBEDTLS_HAVEGE_COLLECT_SIZE 1024
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2013-06-27 12:29:21 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-01-03 21:22:43 +00:00
|
|
|
/**
|
|
|
|
* \brief HAVEGE state structure
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int PT1, PT2, offset[2];
|
2015-04-08 10:49:31 +00:00
|
|
|
int pool[MBEDTLS_HAVEGE_COLLECT_SIZE];
|
2009-01-03 21:22:43 +00:00
|
|
|
int WALK[8192];
|
|
|
|
}
|
2015-04-08 10:49:31 +00:00
|
|
|
mbedtls_havege_state;
|
2009-01-03 21:22:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief HAVEGE initialization
|
|
|
|
*
|
|
|
|
* \param hs HAVEGE state to be initialized
|
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
void mbedtls_havege_init( mbedtls_havege_state *hs );
|
2009-01-03 21:22:43 +00:00
|
|
|
|
2014-06-18 14:44:11 +00:00
|
|
|
/**
|
|
|
|
* \brief Clear HAVEGE state
|
|
|
|
*
|
|
|
|
* \param hs HAVEGE state to be cleared
|
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
void mbedtls_havege_free( mbedtls_havege_state *hs );
|
2014-06-18 14:44:11 +00:00
|
|
|
|
2009-01-03 21:22:43 +00:00
|
|
|
/**
|
|
|
|
* \brief HAVEGE rand function
|
|
|
|
*
|
2009-07-28 07:18:38 +00:00
|
|
|
* \param p_rng A HAVEGE state
|
2011-11-27 21:07:34 +00:00
|
|
|
* \param output Buffer to fill
|
|
|
|
* \param len Length of buffer
|
2009-01-03 21:22:43 +00:00
|
|
|
*
|
2012-02-03 08:13:57 +00:00
|
|
|
* \return 0
|
2009-01-03 21:22:43 +00:00
|
|
|
*/
|
2015-04-08 10:49:31 +00:00
|
|
|
int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len );
|
2009-01-03 21:22:43 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* havege.h */
|