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.
random.h
00001 /* random.h 00002 * 00003 * Copyright (C) 2006-2013 wolfSSL Inc. 00004 * 00005 * This file is part of CyaSSL. 00006 * 00007 * CyaSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * CyaSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00020 */ 00021 00022 00023 #ifndef CTAO_CRYPT_RANDOM_H 00024 #define CTAO_CRYPT_RANDOM_H 00025 00026 #include <cyassl/ctaocrypt/types.h> 00027 00028 #ifndef NO_RC4 00029 #include <cyassl/ctaocrypt/arc4.h> 00030 #else 00031 #include <cyassl/ctaocrypt/sha256.h> 00032 #endif 00033 00034 #ifdef __cplusplus 00035 extern "C" { 00036 #endif 00037 00038 00039 #if defined(USE_WINDOWS_API) 00040 #if defined(_WIN64) 00041 typedef unsigned __int64 ProviderHandle; 00042 /* type HCRYPTPROV, avoid #include <windows.h> */ 00043 #else 00044 typedef unsigned long ProviderHandle; 00045 #endif 00046 #endif 00047 00048 00049 /* OS specific seeder */ 00050 typedef struct OS_Seed { 00051 #if defined(USE_WINDOWS_API) 00052 ProviderHandle handle; 00053 #else 00054 int fd; 00055 #endif 00056 } OS_Seed; 00057 00058 00059 CYASSL_LOCAL 00060 int GenerateSeed(OS_Seed* os, byte* seed, word32 sz); 00061 00062 #if defined(CYASSL_MDK_ARM) 00063 #undef RNG 00064 #define RNG CyaSSL_RNG /* for avoiding name conflict in "stm32f2xx.h" */ 00065 #endif 00066 00067 #ifndef NO_RC4 00068 00069 #define CYASSL_RNG_CAVIUM_MAGIC 0xBEEF0004 00070 00071 /* secure Random Nnumber Generator */ 00072 00073 00074 typedef struct RNG { 00075 OS_Seed seed; 00076 Arc4 cipher; 00077 #ifdef HAVE_CAVIUM 00078 int devId; /* nitrox device id */ 00079 word32 magic; /* using cavium magic */ 00080 #endif 00081 } RNG; 00082 00083 00084 #ifdef HAVE_CAVIUM 00085 CYASSL_API int InitRngCavium(RNG*, int); 00086 #endif 00087 00088 #else /* NO_RC4 */ 00089 00090 #define DBRG_SEED_LEN (440/8) 00091 00092 00093 /* secure Random Nnumber Generator */ 00094 typedef struct RNG { 00095 OS_Seed seed; 00096 00097 Sha256 sha; 00098 byte digest[SHA256_DIGEST_SIZE]; 00099 byte V[DBRG_SEED_LEN]; 00100 byte C[DBRG_SEED_LEN]; 00101 word64 reseed_ctr; 00102 } RNG; 00103 00104 #endif 00105 00106 CYASSL_API int InitRng(RNG*); 00107 CYASSL_API void RNG_GenerateBlock(RNG*, byte*, word32 sz); 00108 CYASSL_API byte RNG_GenerateByte(RNG*); 00109 00110 #ifdef NO_RC4 00111 CYASSL_API void FreeRng(RNG*); 00112 #endif 00113 00114 #ifdef __cplusplus 00115 } /* extern "C" */ 00116 #endif 00117 00118 #endif /* CTAO_CRYPT_RANDOM_H */ 00119
Generated on Tue Jul 12 2022 20:12:51 by
