sandbox / mbedtls

Fork of mbedtls by Christopher Haster

Committer:
Brian Daniels
Date:
Thu Apr 07 11:11:18 2016 +0100
Revision:
4:bef26f687287
Parent:
1:24750b9ad5ef
Adding ported selftest test case

Who changed what in which revision?

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