wolf SSL / wolfSSL-TLS13-Beta

Fork of wolfSSL by wolf SSL

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 #if defined(STM32F2_HASH) || defined(STM32F4_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 #ifdef WOLFSSL_ASYNC_CRYPT
00056     #include <wolfssl/wolfcrypt/async.h>
00057 #endif
00058 
00059 #ifdef WOLFSSL_TI_HASH
00060     #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
00061 #else
00062 
00063 /* MD5 digest */
00064 typedef struct Md5 {
00065     word32  buffLen;   /* in bytes          */
00066     word32  loLen;     /* length in bytes   */
00067     word32  hiLen;     /* length in bytes   */
00068     word32  buffer[MD5_BLOCK_SIZE  / sizeof(word32)];
00069 #if !defined(WOLFSSL_PIC32MZ_HASH)
00070     word32  digest[MD5_DIGEST_SIZE / sizeof(word32)];
00071 #else
00072     word32  digest[PIC32_HASH_SIZE / sizeof(word32)];
00073     pic32mz_desc desc; /* Crypt Engine descriptor */
00074 #endif
00075     void*   heap;
00076 #ifdef WOLFSSL_ASYNC_CRYPT
00077     WC_ASYNC_DEV asyncDev;
00078 #endif /* WOLFSSL_ASYNC_CRYPT */
00079 } Md5;
00080 
00081 #endif /* WOLFSSL_TI_HASH */
00082 
00083 WOLFSSL_API int wc_InitMd5(Md5*);
00084 WOLFSSL_API int wc_InitMd5_ex(Md5*, void*, int);
00085 WOLFSSL_API int wc_Md5Update(Md5*, const byte*, word32);
00086 WOLFSSL_API int wc_Md5Final(Md5*, byte*);
00087 WOLFSSL_API void wc_Md5Free(Md5*);
00088 
00089 WOLFSSL_API int  wc_Md5GetHash(Md5*, byte*);
00090 WOLFSSL_API int  wc_Md5Copy(Md5*, Md5*);
00091 
00092 
00093 #ifdef __cplusplus
00094     } /* extern "C" */
00095 #endif
00096 
00097 #endif /* NO_MD5 */
00098 #endif /* WOLF_CRYPT_MD5_H */
00099