Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MiniTLS-HTTPS-Example
crypto_prng.h
00001 /* 00002 MiniTLS - A super trimmed down TLS/SSL Library for embedded devices 00003 Author: Donatien Garnier 00004 Copyright (C) 2013-2014 AppNearMe Ltd 00005 00006 This program is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU General Public License 00008 as published by the Free Software Foundation; either version 2 00009 of the License, or (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 *//** 00020 * \file crypto_prng.h 00021 * \copyright Copyright (c) AppNearMe Ltd 2013 00022 * \author Donatien Garnier 00023 */ 00024 00025 #ifndef CRYPTO_PRNG_H_ 00026 #define CRYPTO_PRNG_H_ 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 #include "core/fwk.h" 00033 #include "inc/minitls_errors.h" 00034 00035 #include "crypto_aes_128.h" 00036 #include "crypto_sha1.h" 00037 00038 //This PRNG is based on Yarrow (AES128 + SHA1) 00039 00040 typedef struct __crypto_prng 00041 { 00042 crypto_aes_128_t cipher; 00043 //crypto_sha1_t hash; 00044 uint32_t counter; 00045 uint8_t pool[SHA1_SIZE]; 00046 uint8_t buf[AES_128_BLOCK_SIZE]; 00047 size_t buf_pos; 00048 bool fed; 00049 rtos_mtx_t* mtx; 00050 } 00051 crypto_prng_t; 00052 00053 //Thread safe if mutex supplied (can be NULL) 00054 void crypto_prng_init(crypto_prng_t* prng, rtos_mtx_t* mtx); 00055 void crypto_prng_feed(crypto_prng_t* prng, uint8_t* data, size_t size); 00056 void crypto_prng_update(crypto_prng_t* prng); 00057 void crypto_prng_get(crypto_prng_t* prng, uint8_t* data, size_t size); 00058 00059 #ifdef __cplusplus 00060 } 00061 #endif 00062 00063 #endif /* CRYPTO_PRNG_H_ */
Generated on Wed Jul 13 2022 00:22:54 by
1.7.2
