md5.h (3157B)
1 /* md5.h 2 * 3 * Copyright (C) 2006-2025 wolfSSL Inc. 4 * 5 * This file is part of wolfSSL. 6 * 7 * wolfSSL is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * wolfSSL is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 */ 21 22 /* md5.h for openssl */ 23 24 25 #ifndef WOLFSSL_MD5_H_ 26 #define WOLFSSL_MD5_H_ 27 28 #include <wolfssl/wolfcrypt/settings.h> 29 30 #ifndef NO_MD5 31 32 #include <wolfssl/wolfcrypt/hash.h> 33 34 #ifdef WOLFSSL_PREFIX 35 #include "prefix_md5.h" 36 #endif 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 43 typedef struct WOLFSSL_MD5_CTX { 44 /* big enough to hold wolfcrypt md5, but check on init */ 45 #ifdef STM32_HASH 46 void* holder[(112 + WC_ASYNC_DEV_SIZE + sizeof(STM32_HASH_Context)) / sizeof(void*)]; 47 #else 48 void* holder[(112 + WC_ASYNC_DEV_SIZE) / sizeof(void*)]; 49 #endif 50 } WOLFSSL_MD5_CTX; 51 52 WOLFSSL_API int wolfSSL_MD5_Init(WOLFSSL_MD5_CTX* md5); 53 WOLFSSL_API int wolfSSL_MD5_Update(WOLFSSL_MD5_CTX* md5, const void* input, 54 unsigned long sz); 55 WOLFSSL_API int wolfSSL_MD5_Final(unsigned char* output, WOLFSSL_MD5_CTX* md5); 56 WOLFSSL_API int wolfSSL_MD5_Transform(WOLFSSL_MD5_CTX* md5, const unsigned char* data); 57 58 WOLFSSL_API unsigned char *wolfSSL_MD5(const unsigned char* data, size_t len, 59 unsigned char* hash); 60 61 #ifndef OPENSSL_COEXIST 62 63 typedef WOLFSSL_MD5_CTX MD5_CTX; 64 65 #define MD5_Init wolfSSL_MD5_Init 66 #define MD5_Update wolfSSL_MD5_Update 67 #define MD5_Final wolfSSL_MD5_Final 68 #define MD5_Transform wolfSSL_MD5_Transform 69 70 #ifdef OPENSSL_EXTRA_BSD 71 #define MD5Init wolfSSL_MD5_Init 72 #define MD5Update wolfSSL_MD5_Update 73 #define MD5Final wolfSSL_MD5_Final 74 #endif 75 76 /* "MD5" has some conflicts 77 * If not FIPS and NO_OLD_SHA_NAMES defined 78 * If FIPS V2 or higher and NO_OLD_MD5_NAME defined 79 * If FIPS V2 and NO_OLD_WC_NAMES defined 80 * If FIPS v1 not allowed 81 */ 82 #if (defined(NO_OLD_MD5_NAME) && !defined(HAVE_FIPS)) || \ 83 (defined(NO_OLD_MD5_NAME) && defined(HAVE_FIPS) && \ 84 defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 2) || \ 85 (defined(NO_OLD_WC_NAMES) && defined(HAVE_FIPS) && \ 86 defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION == 2) 87 88 #define MD5 wolfSSL_MD5 89 #endif 90 91 /* FIPS v1 uses old MD5_DIGEST_SIZE naming */ 92 #if (!defined(HAVE_FIPS) || \ 93 (defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 2)) && \ 94 defined(OPENSSL_EXTRA) 95 #define MD5_DIGEST_LENGTH WC_MD5_DIGEST_SIZE 96 #else 97 #define MD5_DIGEST_LENGTH MD5_DIGEST_SIZE 98 #endif 99 100 #endif /* !OPENSSL_COEXIST */ 101 102 #ifdef __cplusplus 103 } /* extern "C" */ 104 #endif 105 106 #endif /* NO_MD5 */ 107 108 #endif /* WOLFSSL_MD5_H_ */