wolfSSL 3.11.1 for TLS1.3 beta
Fork of wolfSSL by
wolfssl/wolfcrypt/md5.h@11:cee25a834751, 2017-05-30 (annotated)
- Committer:
- wolfSSL
- Date:
- Tue May 30 01:44:10 2017 +0000
- Revision:
- 11:cee25a834751
wolfSSL 3.11.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 11:cee25a834751 | 1 | /* md5.h |
wolfSSL | 11:cee25a834751 | 2 | * |
wolfSSL | 11:cee25a834751 | 3 | * Copyright (C) 2006-2016 wolfSSL Inc. |
wolfSSL | 11:cee25a834751 | 4 | * |
wolfSSL | 11:cee25a834751 | 5 | * This file is part of wolfSSL. |
wolfSSL | 11:cee25a834751 | 6 | * |
wolfSSL | 11:cee25a834751 | 7 | * wolfSSL is free software; you can redistribute it and/or modify |
wolfSSL | 11:cee25a834751 | 8 | * it under the terms of the GNU General Public License as published by |
wolfSSL | 11:cee25a834751 | 9 | * the Free Software Foundation; either version 2 of the License, or |
wolfSSL | 11:cee25a834751 | 10 | * (at your option) any later version. |
wolfSSL | 11:cee25a834751 | 11 | * |
wolfSSL | 11:cee25a834751 | 12 | * wolfSSL is distributed in the hope that it will be useful, |
wolfSSL | 11:cee25a834751 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wolfSSL | 11:cee25a834751 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wolfSSL | 11:cee25a834751 | 15 | * GNU General Public License for more details. |
wolfSSL | 11:cee25a834751 | 16 | * |
wolfSSL | 11:cee25a834751 | 17 | * You should have received a copy of the GNU General Public License |
wolfSSL | 11:cee25a834751 | 18 | * along with this program; if not, write to the Free Software |
wolfSSL | 11:cee25a834751 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
wolfSSL | 11:cee25a834751 | 20 | */ |
wolfSSL | 11:cee25a834751 | 21 | |
wolfSSL | 11:cee25a834751 | 22 | |
wolfSSL | 11:cee25a834751 | 23 | #ifndef WOLF_CRYPT_MD5_H |
wolfSSL | 11:cee25a834751 | 24 | #define WOLF_CRYPT_MD5_H |
wolfSSL | 11:cee25a834751 | 25 | |
wolfSSL | 11:cee25a834751 | 26 | #include <wolfssl/wolfcrypt/types.h> |
wolfSSL | 11:cee25a834751 | 27 | |
wolfSSL | 11:cee25a834751 | 28 | #ifndef NO_MD5 |
wolfSSL | 11:cee25a834751 | 29 | |
wolfSSL | 11:cee25a834751 | 30 | #ifdef HAVE_FIPS |
wolfSSL | 11:cee25a834751 | 31 | #define wc_InitMd5 InitMd5 |
wolfSSL | 11:cee25a834751 | 32 | #define wc_Md5Update Md5Update |
wolfSSL | 11:cee25a834751 | 33 | #define wc_Md5Final Md5Final |
wolfSSL | 11:cee25a834751 | 34 | #define wc_Md5Hash Md5Hash |
wolfSSL | 11:cee25a834751 | 35 | #endif |
wolfSSL | 11:cee25a834751 | 36 | |
wolfSSL | 11:cee25a834751 | 37 | #ifdef __cplusplus |
wolfSSL | 11:cee25a834751 | 38 | extern "C" { |
wolfSSL | 11:cee25a834751 | 39 | #endif |
wolfSSL | 11:cee25a834751 | 40 | |
wolfSSL | 11:cee25a834751 | 41 | /* in bytes */ |
wolfSSL | 11:cee25a834751 | 42 | enum { |
wolfSSL | 11:cee25a834751 | 43 | #if defined(STM32F2_HASH) || defined(STM32F4_HASH) |
wolfSSL | 11:cee25a834751 | 44 | MD5_REG_SIZE = 4, /* STM32 register size, bytes */ |
wolfSSL | 11:cee25a834751 | 45 | #endif |
wolfSSL | 11:cee25a834751 | 46 | MD5 = 0, /* hash type unique */ |
wolfSSL | 11:cee25a834751 | 47 | MD5_BLOCK_SIZE = 64, |
wolfSSL | 11:cee25a834751 | 48 | MD5_DIGEST_SIZE = 16, |
wolfSSL | 11:cee25a834751 | 49 | MD5_PAD_SIZE = 56 |
wolfSSL | 11:cee25a834751 | 50 | }; |
wolfSSL | 11:cee25a834751 | 51 | |
wolfSSL | 11:cee25a834751 | 52 | #if defined(WOLFSSL_PIC32MZ_HASH) |
wolfSSL | 11:cee25a834751 | 53 | #include "port/pic32/pic32mz-crypt.h" |
wolfSSL | 11:cee25a834751 | 54 | #endif |
wolfSSL | 11:cee25a834751 | 55 | #ifdef WOLFSSL_ASYNC_CRYPT |
wolfSSL | 11:cee25a834751 | 56 | #include <wolfssl/wolfcrypt/async.h> |
wolfSSL | 11:cee25a834751 | 57 | #endif |
wolfSSL | 11:cee25a834751 | 58 | |
wolfSSL | 11:cee25a834751 | 59 | #ifdef WOLFSSL_TI_HASH |
wolfSSL | 11:cee25a834751 | 60 | #include "wolfssl/wolfcrypt/port/ti/ti-hash.h" |
wolfSSL | 11:cee25a834751 | 61 | #else |
wolfSSL | 11:cee25a834751 | 62 | |
wolfSSL | 11:cee25a834751 | 63 | /* MD5 digest */ |
wolfSSL | 11:cee25a834751 | 64 | typedef struct Md5 { |
wolfSSL | 11:cee25a834751 | 65 | word32 buffLen; /* in bytes */ |
wolfSSL | 11:cee25a834751 | 66 | word32 loLen; /* length in bytes */ |
wolfSSL | 11:cee25a834751 | 67 | word32 hiLen; /* length in bytes */ |
wolfSSL | 11:cee25a834751 | 68 | word32 buffer[MD5_BLOCK_SIZE / sizeof(word32)]; |
wolfSSL | 11:cee25a834751 | 69 | #if !defined(WOLFSSL_PIC32MZ_HASH) |
wolfSSL | 11:cee25a834751 | 70 | word32 digest[MD5_DIGEST_SIZE / sizeof(word32)]; |
wolfSSL | 11:cee25a834751 | 71 | #else |
wolfSSL | 11:cee25a834751 | 72 | word32 digest[PIC32_HASH_SIZE / sizeof(word32)]; |
wolfSSL | 11:cee25a834751 | 73 | pic32mz_desc desc; /* Crypt Engine descriptor */ |
wolfSSL | 11:cee25a834751 | 74 | #endif |
wolfSSL | 11:cee25a834751 | 75 | void* heap; |
wolfSSL | 11:cee25a834751 | 76 | #ifdef WOLFSSL_ASYNC_CRYPT |
wolfSSL | 11:cee25a834751 | 77 | WC_ASYNC_DEV asyncDev; |
wolfSSL | 11:cee25a834751 | 78 | #endif /* WOLFSSL_ASYNC_CRYPT */ |
wolfSSL | 11:cee25a834751 | 79 | } Md5; |
wolfSSL | 11:cee25a834751 | 80 | |
wolfSSL | 11:cee25a834751 | 81 | #endif /* WOLFSSL_TI_HASH */ |
wolfSSL | 11:cee25a834751 | 82 | |
wolfSSL | 11:cee25a834751 | 83 | WOLFSSL_API int wc_InitMd5(Md5*); |
wolfSSL | 11:cee25a834751 | 84 | WOLFSSL_API int wc_InitMd5_ex(Md5*, void*, int); |
wolfSSL | 11:cee25a834751 | 85 | WOLFSSL_API int wc_Md5Update(Md5*, const byte*, word32); |
wolfSSL | 11:cee25a834751 | 86 | WOLFSSL_API int wc_Md5Final(Md5*, byte*); |
wolfSSL | 11:cee25a834751 | 87 | WOLFSSL_API void wc_Md5Free(Md5*); |
wolfSSL | 11:cee25a834751 | 88 | |
wolfSSL | 11:cee25a834751 | 89 | WOLFSSL_API int wc_Md5GetHash(Md5*, byte*); |
wolfSSL | 11:cee25a834751 | 90 | WOLFSSL_API int wc_Md5Copy(Md5*, Md5*); |
wolfSSL | 11:cee25a834751 | 91 | |
wolfSSL | 11:cee25a834751 | 92 | |
wolfSSL | 11:cee25a834751 | 93 | #ifdef __cplusplus |
wolfSSL | 11:cee25a834751 | 94 | } /* extern "C" */ |
wolfSSL | 11:cee25a834751 | 95 | #endif |
wolfSSL | 11:cee25a834751 | 96 | |
wolfSSL | 11:cee25a834751 | 97 | #endif /* NO_MD5 */ |
wolfSSL | 11:cee25a834751 | 98 | #endif /* WOLF_CRYPT_MD5_H */ |
wolfSSL | 11:cee25a834751 | 99 |