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.
hash.h
00001 /* hash.h 00002 * 00003 * Copyright (C) 2006-2017 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSL. 00006 * 00007 * wolfSSL 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 * wolfSSL 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 00020 */ 00021 00022 /*! 00023 \file wolfssl/wolfcrypt/hash.h 00024 */ 00025 00026 #ifndef WOLF_CRYPT_HASH_H 00027 #define WOLF_CRYPT_HASH_H 00028 00029 #include <wolfcrypt/types.h> 00030 00031 #ifndef NO_MD5 00032 #include <wolfcrypt/md5.h> 00033 #endif 00034 #ifndef NO_SHA 00035 #include <wolfcrypt/sha.h> 00036 #endif 00037 #if defined(WOLFSSL_SHA224) || !defined(NO_SHA256) 00038 #include <wolfcrypt/sha256.h> 00039 #endif 00040 #if defined(WOLFSSL_SHA384) || defined(WOLFSSL_SHA512) 00041 #include <wolfcrypt/sha512.h> 00042 #endif 00043 #ifdef HAVE_BLAKE2 00044 #include <wolfcrypt/blake2.h> 00045 #endif 00046 #ifdef WOLFSSL_SHA3 00047 #include <wolfcrypt/sha3.h> 00048 #endif 00049 #ifndef NO_MD4 00050 #include <wolfcrypt/md4.h> 00051 #endif 00052 #ifdef WOLFSSL_MD2 00053 #include <wolfcrypt/md2.h> 00054 #endif 00055 00056 00057 #ifdef __cplusplus 00058 extern "C" { 00059 #endif 00060 00061 #if !defined(HAVE_FIPS) && !defined(NO_OLD_WC_NAMES) 00062 #define MAX_DIGEST_SIZE WC_MAX_DIGEST_SIZE 00063 #endif 00064 00065 00066 typedef union { 00067 #ifndef NO_MD5 00068 wc_Md5 md5; 00069 #endif 00070 #ifndef NO_SHA 00071 wc_Sha sha; 00072 #endif 00073 #ifdef WOLFSSL_SHA224 00074 wc_Sha224 sha224; 00075 #endif 00076 #ifndef NO_SHA256 00077 wc_Sha256 sha256; 00078 #endif 00079 #ifdef WOLFSSL_SHA384 00080 wc_Sha384 sha384; 00081 #endif 00082 #ifdef WOLFSSL_SHA512 00083 wc_Sha512 sha512; 00084 #endif 00085 } wc_HashAlg; 00086 00087 /* Find largest possible digest size 00088 Note if this gets up to the size of 80 or over check smallstack build */ 00089 #if defined(WOLFSSL_SHA3) 00090 #define WC_MAX_DIGEST_SIZE WC_SHA3_512_DIGEST_SIZE 00091 #define WC_MAX_BLOCK_SIZE WC_SHA3_224_BLOCK_SIZE /* 224 is the largest block size */ 00092 #elif defined(WOLFSSL_SHA512) 00093 #define WC_MAX_DIGEST_SIZE WC_SHA512_DIGEST_SIZE 00094 #define WC_MAX_BLOCK_SIZE WC_SHA512_BLOCK_SIZE 00095 #elif defined(HAVE_BLAKE2) 00096 #define WC_MAX_DIGEST_SIZE BLAKE2B_OUTBYTES 00097 #define WC_MAX_BLOCK_SIZE BLAKE2B_BLOCKBYTES 00098 #elif defined(WOLFSSL_SHA384) 00099 #define WC_MAX_DIGEST_SIZE WC_SHA384_DIGEST_SIZE 00100 #define WC_MAX_BLOCK_SIZE WC_SHA384_BLOCK_SIZE 00101 #elif !defined(NO_SHA256) 00102 #define WC_MAX_DIGEST_SIZE WC_SHA256_DIGEST_SIZE 00103 #define WC_MAX_BLOCK_SIZE WC_SHA256_BLOCK_SIZE 00104 #elif defined(WOLFSSL_SHA224) 00105 #define WC_MAX_DIGEST_SIZE WC_SHA224_DIGEST_SIZE 00106 #define WC_MAX_BLOCK_SIZE WC_SHA224_BLOCK_SIZE 00107 #elif !defined(NO_SHA) 00108 #define WC_MAX_DIGEST_SIZE WC_SHA_DIGEST_SIZE 00109 #define WC_MAX_BLOCK_SIZE WC_SHA_BLOCK_SIZE 00110 #elif !defined(NO_MD5) 00111 #define WC_MAX_DIGEST_SIZE WC_MD5_DIGEST_SIZE 00112 #define WC_MAX_BLOCK_SIZE WC_MD5_BLOCK_SIZE 00113 #else 00114 #define WC_MAX_DIGEST_SIZE 64 /* default to max size of 64 */ 00115 #define WC_MAX_BLOCK_SIZE 128 00116 #endif 00117 00118 #if !defined(NO_ASN) || !defined(NO_DH) || defined(HAVE_ECC) 00119 WOLFSSL_API int wc_HashGetOID(enum wc_HashType hash_type); 00120 WOLFSSL_API enum wc_HashType wc_OidGetHash(int oid); 00121 #endif 00122 00123 WOLFSSL_API enum wc_HashType wc_HashTypeConvert(int hashType); 00124 00125 WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type); 00126 WOLFSSL_API int wc_HashGetBlockSize(enum wc_HashType hash_type); 00127 WOLFSSL_API int wc_Hash(enum wc_HashType hash_type, 00128 const byte* data, word32 data_len, 00129 byte* hash, word32 hash_len); 00130 00131 /* generic hash operation wrappers */ 00132 WOLFSSL_API int wc_HashInit(wc_HashAlg* hash, enum wc_HashType type); 00133 WOLFSSL_API int wc_HashUpdate(wc_HashAlg* hash, enum wc_HashType type, 00134 const byte* data, word32 dataSz); 00135 WOLFSSL_API int wc_HashFinal(wc_HashAlg* hash, enum wc_HashType type, 00136 byte* out); 00137 00138 00139 #ifndef NO_MD5 00140 #include <wolfcrypt/md5.h> 00141 WOLFSSL_API int wc_Md5Hash(const byte* data, word32 len, byte* hash); 00142 #endif 00143 00144 #ifndef NO_SHA 00145 #include <wolfcrypt/sha.h> 00146 WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*); 00147 #endif 00148 00149 #ifdef WOLFSSL_SHA224 00150 #include <wolfcrypt/sha256.h> 00151 WOLFSSL_API int wc_Sha224Hash(const byte*, word32, byte*); 00152 #endif /* defined(WOLFSSL_SHA224) */ 00153 00154 #ifndef NO_SHA256 00155 #include <wolfcrypt/sha256.h> 00156 WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*); 00157 #endif 00158 00159 #ifdef WOLFSSL_SHA384 00160 #include <wolfcrypt/sha512.h> 00161 WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*); 00162 #endif /* defined(WOLFSSL_SHA384) */ 00163 00164 #ifdef WOLFSSL_SHA512 00165 #include <wolfcrypt/sha512.h> 00166 WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*); 00167 #endif /* WOLFSSL_SHA512 */ 00168 00169 #ifdef __cplusplus 00170 } /* extern "C" */ 00171 #endif 00172 00173 #endif /* WOLF_CRYPT_HASH_H */ 00174
Generated on Tue Jul 12 2022 16:58:06 by
1.7.2