Renesas / SecureDweet
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers md5.h Source File

md5.h

00001 /* md5.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_MD5_H
00024 #define WOLF_CRYPT_MD5_H
00025 
00026 #include <wolfssl/wolfcrypt/types.h>
00027 
00028 #ifndef NO_MD5
00029 
00030 #ifdef HAVE_FIPS
00031     #define wc_InitMd5   InitMd5
00032     #define wc_Md5Update Md5Update
00033     #define wc_Md5Final  Md5Final
00034     #define wc_Md5Hash   Md5Hash
00035 #endif
00036 
00037 #ifdef __cplusplus
00038     extern "C" {
00039 #endif
00040 
00041 /* in bytes */
00042 enum {
00043 #ifdef STM32F2_HASH
00044     MD5_REG_SIZE    =  4,      /* STM32 register size, bytes */
00045 #endif
00046     MD5             =  0,      /* hash type unique */
00047     MD5_BLOCK_SIZE  = 64,
00048     MD5_DIGEST_SIZE = 16,
00049     MD5_PAD_SIZE    = 56
00050 };
00051 
00052 #if defined(WOLFSSL_PIC32MZ_HASH)
00053 #include "port/pic32/pic32mz-crypt.h"
00054 #endif
00055 
00056 #ifndef WOLFSSL_TI_HASH
00057 
00058 /* MD5 digest */
00059 typedef struct Md5 {
00060     word32  buffLen;   /* in bytes          */
00061     word32  loLen;     /* length in bytes   */
00062     word32  hiLen;     /* length in bytes   */
00063     word32  buffer[MD5_BLOCK_SIZE  / sizeof(word32)];
00064     #if !defined(WOLFSSL_PIC32MZ_HASH)
00065     word32  digest[MD5_DIGEST_SIZE / sizeof(word32)];
00066     #else
00067     word32  digest[PIC32_HASH_SIZE / sizeof(word32)];
00068     pic32mz_desc desc ; /* Crypt Engine descriptor */
00069     #endif
00070 } Md5;
00071 
00072 #else /* WOLFSSL_TI_HASH */
00073     #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
00074 #endif
00075 
00076 WOLFSSL_API void wc_InitMd5(Md5*);
00077 WOLFSSL_API void wc_Md5Update(Md5*, const byte*, word32);
00078 WOLFSSL_API void wc_Md5Final(Md5*, byte*);
00079 WOLFSSL_API int  wc_Md5Hash(const byte*, word32, byte*);
00080 
00081 #ifdef __cplusplus
00082     } /* extern "C" */
00083 #endif
00084 
00085 #endif /* NO_MD5 */
00086 #endif /* WOLF_CRYPT_MD5_H */
00087