1 | /* md5.h
|
---|
2 | *
|
---|
3 | * Copyright (C) 2006-2015 wolfSSL Inc.
|
---|
4 | *
|
---|
5 | * This file is part of wolfSSL. (formerly known as CyaSSL)
|
---|
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 2 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-1301, USA
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef WOLF_CRYPT_MD5_H
|
---|
23 | #define WOLF_CRYPT_MD5_H
|
---|
24 |
|
---|
25 | #include <wolfssl/wolfcrypt/types.h>
|
---|
26 |
|
---|
27 | #ifndef NO_MD5
|
---|
28 |
|
---|
29 | #ifdef HAVE_FIPS
|
---|
30 | #define wc_InitMd5 InitMd5
|
---|
31 | #define wc_Md5Update Md5Update
|
---|
32 | #define wc_Md5Final Md5Final
|
---|
33 | #define wc_Md5Hash Md5Hash
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #ifdef __cplusplus
|
---|
37 | extern "C" {
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | /* in bytes */
|
---|
41 | enum {
|
---|
42 | #ifdef STM32F2_HASH
|
---|
43 | MD5_REG_SIZE = 4, /* STM32 register size, bytes */
|
---|
44 | #endif
|
---|
45 | MD5 = 0, /* hash type unique */
|
---|
46 | MD5_BLOCK_SIZE = 64,
|
---|
47 | MD5_DIGEST_SIZE = 16,
|
---|
48 | MD5_PAD_SIZE = 56
|
---|
49 | };
|
---|
50 |
|
---|
51 | #if defined(WOLFSSL_PIC32MZ_HASH)
|
---|
52 | #include "port/pic32/pic32mz-crypt.h"
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #ifndef WOLFSSL_TI_HASH
|
---|
56 |
|
---|
57 | /* MD5 digest */
|
---|
58 | typedef struct Md5 {
|
---|
59 | word32 buffLen; /* in bytes */
|
---|
60 | word32 loLen; /* length in bytes */
|
---|
61 | word32 hiLen; /* length in bytes */
|
---|
62 | word32 buffer[MD5_BLOCK_SIZE / sizeof(word32)];
|
---|
63 | #if !defined(WOLFSSL_PIC32MZ_HASH)
|
---|
64 | word32 digest[MD5_DIGEST_SIZE / sizeof(word32)];
|
---|
65 | #else
|
---|
66 | word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
|
---|
67 | pic32mz_desc desc ; /* Crypt Engine descripter */
|
---|
68 | #endif
|
---|
69 | } Md5;
|
---|
70 |
|
---|
71 | #else /* WOLFSSL_TI_HASH */
|
---|
72 | #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | WOLFSSL_API void wc_InitMd5(Md5*);
|
---|
76 | WOLFSSL_API void wc_Md5Update(Md5*, const byte*, word32);
|
---|
77 | WOLFSSL_API void wc_Md5Final(Md5*, byte*);
|
---|
78 | WOLFSSL_API int wc_Md5Hash(const byte*, word32, byte*);
|
---|
79 |
|
---|
80 | #ifdef __cplusplus
|
---|
81 | } /* extern "C" */
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | #endif /* NO_MD5 */
|
---|
85 | #endif /* WOLF_CRYPT_MD5_H */
|
---|