Xuyi Wang / wolfSSL

Dependents:   OS

Committer:
sPymbed
Date:
Tue Nov 19 14:32:16 2019 +0000
Revision:
16:048e5e270a58
Parent:
15:117db924cf7c
working ssl

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 15:117db924cf7c 1 /* md5.h
wolfSSL 15:117db924cf7c 2 *
wolfSSL 15:117db924cf7c 3 * Copyright (C) 2006-2017 wolfSSL Inc.
wolfSSL 15:117db924cf7c 4 *
wolfSSL 15:117db924cf7c 5 * This file is part of wolfSSL.
wolfSSL 15:117db924cf7c 6 *
wolfSSL 15:117db924cf7c 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 15:117db924cf7c 8 * it under the terms of the GNU General Public License as published by
wolfSSL 15:117db924cf7c 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 15:117db924cf7c 10 * (at your option) any later version.
wolfSSL 15:117db924cf7c 11 *
wolfSSL 15:117db924cf7c 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 15:117db924cf7c 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 15:117db924cf7c 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 15:117db924cf7c 15 * GNU General Public License for more details.
wolfSSL 15:117db924cf7c 16 *
wolfSSL 15:117db924cf7c 17 * You should have received a copy of the GNU General Public License
wolfSSL 15:117db924cf7c 18 * along with this program; if not, write to the Free Software
wolfSSL 15:117db924cf7c 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 15:117db924cf7c 20 */
wolfSSL 15:117db924cf7c 21
wolfSSL 15:117db924cf7c 22 /*!
wolfSSL 15:117db924cf7c 23 \file wolfssl/wolfcrypt/md5.h
wolfSSL 15:117db924cf7c 24 */
wolfSSL 15:117db924cf7c 25
wolfSSL 15:117db924cf7c 26
wolfSSL 15:117db924cf7c 27 #ifndef WOLF_CRYPT_MD5_H
wolfSSL 15:117db924cf7c 28 #define WOLF_CRYPT_MD5_H
wolfSSL 15:117db924cf7c 29
wolfSSL 15:117db924cf7c 30 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 15:117db924cf7c 31
wolfSSL 15:117db924cf7c 32 #ifndef NO_MD5
wolfSSL 15:117db924cf7c 33
wolfSSL 15:117db924cf7c 34 #ifdef HAVE_FIPS
wolfSSL 15:117db924cf7c 35 #define wc_InitMd5 InitMd5
wolfSSL 15:117db924cf7c 36 #define wc_Md5Update Md5Update
wolfSSL 15:117db924cf7c 37 #define wc_Md5Final Md5Final
wolfSSL 15:117db924cf7c 38 #define wc_Md5Hash Md5Hash
wolfSSL 15:117db924cf7c 39 #endif
wolfSSL 15:117db924cf7c 40
wolfSSL 15:117db924cf7c 41 #ifdef __cplusplus
wolfSSL 15:117db924cf7c 42 extern "C" {
wolfSSL 15:117db924cf7c 43 #endif
wolfSSL 15:117db924cf7c 44
wolfSSL 15:117db924cf7c 45 #ifndef NO_OLD_WC_NAMES
wolfSSL 15:117db924cf7c 46 #define Md5 wc_Md5
wolfSSL 15:117db924cf7c 47 #define MD5 WC_MD5
wolfSSL 15:117db924cf7c 48 #define MD5_BLOCK_SIZE WC_MD5_BLOCK_SIZE
wolfSSL 15:117db924cf7c 49 #define MD5_DIGEST_SIZE WC_MD5_DIGEST_SIZE
wolfSSL 15:117db924cf7c 50 #define WC_MD5_PAD_SIZE WC_MD5_PAD_SIZE
wolfSSL 15:117db924cf7c 51 #endif
wolfSSL 15:117db924cf7c 52
wolfSSL 15:117db924cf7c 53 /* in bytes */
wolfSSL 15:117db924cf7c 54 enum {
wolfSSL 15:117db924cf7c 55 WC_MD5 = WC_HASH_TYPE_MD5,
wolfSSL 15:117db924cf7c 56 WC_MD5_BLOCK_SIZE = 64,
wolfSSL 15:117db924cf7c 57 WC_MD5_DIGEST_SIZE = 16,
wolfSSL 15:117db924cf7c 58 WC_MD5_PAD_SIZE = 56
wolfSSL 15:117db924cf7c 59 };
wolfSSL 15:117db924cf7c 60
wolfSSL 15:117db924cf7c 61
wolfSSL 15:117db924cf7c 62 #ifdef WOLFSSL_MICROCHIP_PIC32MZ
wolfSSL 15:117db924cf7c 63 #include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h>
wolfSSL 15:117db924cf7c 64 #endif
wolfSSL 15:117db924cf7c 65 #ifdef STM32_HASH
wolfSSL 15:117db924cf7c 66 #include <wolfssl/wolfcrypt/port/st/stm32.h>
wolfSSL 15:117db924cf7c 67 #endif
wolfSSL 15:117db924cf7c 68 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 15:117db924cf7c 69 #include <wolfssl/wolfcrypt/async.h>
wolfSSL 15:117db924cf7c 70 #endif
wolfSSL 15:117db924cf7c 71
wolfSSL 15:117db924cf7c 72 #ifdef WOLFSSL_TI_HASH
wolfSSL 15:117db924cf7c 73 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
wolfSSL 15:117db924cf7c 74 #elif defined(WOLFSSL_IMX6_CAAM)
wolfSSL 15:117db924cf7c 75 #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h"
wolfSSL 15:117db924cf7c 76 #else
wolfSSL 15:117db924cf7c 77
wolfSSL 15:117db924cf7c 78 /* MD5 digest */
wolfSSL 15:117db924cf7c 79 typedef struct wc_Md5 {
wolfSSL 15:117db924cf7c 80 #ifdef STM32_HASH
wolfSSL 15:117db924cf7c 81 STM32_HASH_Context stmCtx;
wolfSSL 15:117db924cf7c 82 #else
wolfSSL 15:117db924cf7c 83 word32 buffLen; /* in bytes */
wolfSSL 15:117db924cf7c 84 word32 loLen; /* length in bytes */
wolfSSL 15:117db924cf7c 85 word32 hiLen; /* length in bytes */
wolfSSL 15:117db924cf7c 86 word32 buffer[WC_MD5_BLOCK_SIZE / sizeof(word32)];
wolfSSL 15:117db924cf7c 87 #ifdef WOLFSSL_PIC32MZ_HASH
wolfSSL 15:117db924cf7c 88 word32 digest[PIC32_DIGEST_SIZE / sizeof(word32)];
wolfSSL 15:117db924cf7c 89 #else
wolfSSL 15:117db924cf7c 90 word32 digest[WC_MD5_DIGEST_SIZE / sizeof(word32)];
wolfSSL 15:117db924cf7c 91 #endif
wolfSSL 15:117db924cf7c 92 void* heap;
wolfSSL 15:117db924cf7c 93 #ifdef WOLFSSL_PIC32MZ_HASH
wolfSSL 15:117db924cf7c 94 hashUpdCache cache; /* cache for updates */
wolfSSL 15:117db924cf7c 95 #endif
wolfSSL 15:117db924cf7c 96 #endif /* STM32_HASH */
wolfSSL 15:117db924cf7c 97 #ifdef WOLFSSL_ASYNC_CRYPT
wolfSSL 15:117db924cf7c 98 WC_ASYNC_DEV asyncDev;
wolfSSL 15:117db924cf7c 99 #endif /* WOLFSSL_ASYNC_CRYPT */
wolfSSL 15:117db924cf7c 100 } wc_Md5;
wolfSSL 15:117db924cf7c 101
wolfSSL 15:117db924cf7c 102 #endif /* WOLFSSL_TI_HASH */
wolfSSL 15:117db924cf7c 103
wolfSSL 15:117db924cf7c 104 WOLFSSL_API int wc_InitMd5(wc_Md5*);
wolfSSL 15:117db924cf7c 105 WOLFSSL_API int wc_InitMd5_ex(wc_Md5*, void*, int);
wolfSSL 15:117db924cf7c 106 WOLFSSL_API int wc_Md5Update(wc_Md5*, const byte*, word32);
wolfSSL 15:117db924cf7c 107 WOLFSSL_API int wc_Md5Final(wc_Md5*, byte*);
wolfSSL 15:117db924cf7c 108 WOLFSSL_API void wc_Md5Free(wc_Md5*);
wolfSSL 15:117db924cf7c 109
wolfSSL 15:117db924cf7c 110 WOLFSSL_API int wc_Md5GetHash(wc_Md5*, byte*);
wolfSSL 15:117db924cf7c 111 WOLFSSL_API int wc_Md5Copy(wc_Md5*, wc_Md5*);
wolfSSL 15:117db924cf7c 112
wolfSSL 15:117db924cf7c 113 #ifdef WOLFSSL_PIC32MZ_HASH
wolfSSL 15:117db924cf7c 114 WOLFSSL_API void wc_Md5SizeSet(wc_Md5* md5, word32 len);
wolfSSL 15:117db924cf7c 115 #endif
wolfSSL 15:117db924cf7c 116
wolfSSL 15:117db924cf7c 117 #ifdef __cplusplus
wolfSSL 15:117db924cf7c 118 } /* extern "C" */
wolfSSL 15:117db924cf7c 119 #endif
wolfSSL 15:117db924cf7c 120
wolfSSL 15:117db924cf7c 121 #endif /* NO_MD5 */
wolfSSL 15:117db924cf7c 122 #endif /* WOLF_CRYPT_MD5_H */
wolfSSL 15:117db924cf7c 123