Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:15

0001 /* md5.h
0002 
0003    The MD5 hash function, described in RFC 1321.
0004 
0005    Copyright (C) 2001 Niels Möller
0006 
0007    This file is part of GNU Nettle.
0008 
0009    GNU Nettle is free software: you can redistribute it and/or
0010    modify it under the terms of either:
0011 
0012      * the GNU Lesser General Public License as published by the Free
0013        Software Foundation; either version 3 of the License, or (at your
0014        option) any later version.
0015 
0016    or
0017 
0018      * the GNU General Public License as published by the Free
0019        Software Foundation; either version 2 of the License, or (at your
0020        option) any later version.
0021 
0022    or both in parallel, as here.
0023 
0024    GNU Nettle is distributed in the hope that it will be useful,
0025    but WITHOUT ANY WARRANTY; without even the implied warranty of
0026    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0027    General Public License for more details.
0028 
0029    You should have received copies of the GNU General Public License and
0030    the GNU Lesser General Public License along with this program.  If
0031    not, see http://www.gnu.org/licenses/.
0032 */
0033  
0034 #ifndef NETTLE_MD5_H_INCLUDED
0035 #define NETTLE_MD5_H_INCLUDED
0036 
0037 #include "nettle-types.h"
0038 
0039 #ifdef __cplusplus
0040 extern "C" {
0041 #endif
0042 
0043 /* Name mangling */
0044 #define md5_init nettle_md5_init
0045 #define md5_update nettle_md5_update
0046 #define md5_digest nettle_md5_digest
0047 #define md5_compress nettle_md5_compress
0048 
0049 #define MD5_DIGEST_SIZE 16
0050 #define MD5_BLOCK_SIZE 64
0051 /* For backwards compatibility */
0052 #define MD5_DATA_SIZE MD5_BLOCK_SIZE
0053 
0054 /* Digest is kept internally as 4 32-bit words. */
0055 #define _MD5_DIGEST_LENGTH 4
0056 
0057 struct md5_ctx
0058 {
0059   uint32_t state[_MD5_DIGEST_LENGTH];
0060   uint64_t count;               /* Block count */
0061   unsigned index;               /* Into buffer */
0062   uint8_t block[MD5_BLOCK_SIZE]; /* Block buffer */
0063 };
0064 
0065 void
0066 md5_init(struct md5_ctx *ctx);
0067 
0068 void
0069 md5_update(struct md5_ctx *ctx,
0070        size_t length,
0071        const uint8_t *data);
0072 
0073 void
0074 md5_digest(struct md5_ctx *ctx,
0075        size_t length,
0076        uint8_t *digest);
0077 
0078 /* MD5 compression function. STATE points to 4 uint32_t words,
0079    and DATA points to 64 bytes of input data, possibly unaligned. */
0080 void
0081 md5_compress(uint32_t *state, const uint8_t *data);
0082 
0083 /* Old name, for backwards compatibility. */
0084 #define _nettle_md5_compress nettle_md5_compress
0085 
0086 #ifdef __cplusplus
0087 }
0088 #endif
0089 
0090 #endif /* NETTLE_MD5_H_INCLUDED */