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-2016 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 #ifndef WOLF_CRYPT_HASH_H 00024 #define WOLF_CRYPT_HASH_H 00025 00026 #include <wolfssl/wolfcrypt/types.h> 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 /* Hash types */ 00033 enum wc_HashType { 00034 WC_HASH_TYPE_NONE = 0, 00035 WC_HASH_TYPE_MD2 = 1, 00036 WC_HASH_TYPE_MD4 = 2, 00037 WC_HASH_TYPE_MD5 = 3, 00038 WC_HASH_TYPE_SHA = 4, /* SHA-1 (not old SHA-0) */ 00039 WC_HASH_TYPE_SHA256 = 5, 00040 WC_HASH_TYPE_SHA384 = 6, 00041 WC_HASH_TYPE_SHA512 = 7, 00042 }; 00043 00044 /* Find largest possible digest size 00045 Note if this gets up to the size of 80 or over check smallstack build */ 00046 #if defined(WOLFSSL_SHA512) 00047 #define WC_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE 00048 #elif defined(WOLFSSL_SHA384) 00049 #define WC_MAX_DIGEST_SIZE SHA384_DIGEST_SIZE 00050 #elif !defined(NO_SHA256) 00051 #define WC_MAX_DIGEST_SIZE SHA256_DIGEST_SIZE 00052 #elif !defined(NO_SHA) 00053 #define WC_MAX_DIGEST_SIZE SHA_DIGEST_SIZE 00054 #elif !defined(NO_MD5) 00055 #define WC_MAX_DIGEST_SIZE MD5_DIGEST_SIZE 00056 #else 00057 #define WC_MAX_DIGEST_SIZE 64 /* default to max size of 64 */ 00058 #endif 00059 00060 #ifndef NO_ASN 00061 WOLFSSL_API int wc_HashGetOID(enum wc_HashType hash_type); 00062 #endif 00063 00064 WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type); 00065 WOLFSSL_API int wc_Hash(enum wc_HashType hash_type, 00066 const byte* data, word32 data_len, 00067 byte* hash, word32 hash_len); 00068 00069 00070 #ifndef NO_MD5 00071 #include <wolfssl/wolfcrypt/md5.h> 00072 WOLFSSL_API void wc_Md5GetHash(Md5*, byte*); 00073 WOLFSSL_API void wc_Md5RestorePos(Md5*, Md5*); 00074 #if defined(WOLFSSL_TI_HASH) 00075 WOLFSSL_API void wc_Md5Free(Md5*); 00076 #else 00077 #define wc_Md5Free(d) 00078 #endif 00079 #endif 00080 00081 #ifndef NO_SHA 00082 #include <wolfssl/wolfcrypt/sha.h> 00083 WOLFSSL_API int wc_ShaGetHash(Sha*, byte*); 00084 WOLFSSL_API void wc_ShaRestorePos(Sha*, Sha*); 00085 WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*); 00086 #if defined(WOLFSSL_TI_HASH) 00087 WOLFSSL_API void wc_ShaFree(Sha*); 00088 #else 00089 #define wc_ShaFree(d) 00090 #endif 00091 #endif 00092 00093 #ifndef NO_SHA256 00094 #include <wolfssl/wolfcrypt/sha256.h> 00095 WOLFSSL_API int wc_Sha256GetHash(Sha256*, byte*); 00096 WOLFSSL_API void wc_Sha256RestorePos(Sha256*, Sha256*); 00097 WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*); 00098 #if defined(WOLFSSL_TI_HASH) 00099 WOLFSSL_API void wc_Sha256Free(Sha256*); 00100 #else 00101 #define wc_Sha256Free(d) 00102 #endif 00103 #endif 00104 00105 #ifdef WOLFSSL_SHA512 00106 #include <wolfssl/wolfcrypt/sha512.h> 00107 WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*); 00108 #if defined(WOLFSSL_TI_HASH) 00109 WOLFSSL_API void wc_Sha512Free(Sha512*); 00110 #else 00111 #define wc_Sha512Free(d) 00112 #endif 00113 #if defined(WOLFSSL_SHA384) 00114 WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*); 00115 #if defined(WOLFSSL_TI_HASH) 00116 WOLFSSL_API void wc_Sha384Free(Sha384*); 00117 #else 00118 #define wc_Sha384Free(d) 00119 #endif 00120 #endif /* defined(WOLFSSL_SHA384) */ 00121 #endif /* WOLFSSL_SHA512 */ 00122 00123 00124 #ifdef __cplusplus 00125 } /* extern "C" */ 00126 #endif 00127 00128 #endif /* WOLF_CRYPT_HASH_H */ 00129
Generated on Tue Jul 12 2022 15:55:18 by
1.7.2