1 /* -*- buffer-read-only: t -*- vi: set ro: */ 2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 3 /* Declaration of functions and data types used for MD5 sum computing 4 library functions. 5 Copyright (C) 1995-1997, 1999-2001, 2004-2006, 2008-2010 Free Software 6 Foundation, Inc. 7 This file is part of the GNU C Library. 8 9 This program is free software; you can redistribute it and/or modify it 10 under the terms of the GNU General Public License as published by the 11 Free Software Foundation; either version 3, or (at your option) any 12 later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software Foundation, 21 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 22 23 #ifndef _MD5_H 24 #define _MD5_H 1 25 26 #include <stdio.h> 27 #include <stdint.h> 28 29 #define MD5_DIGEST_SIZE 16 30 #define MD5_BLOCK_SIZE 64 31 32 #ifndef __GNUC_PREREQ 33 # if defined __GNUC__ && defined __GNUC_MINOR__ 34 # define __GNUC_PREREQ(maj, min) \ 35 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) 36 # else 37 # define __GNUC_PREREQ(maj, min) 0 38 # endif 39 #endif 40 41 #ifndef __THROW 42 # if defined __cplusplus && __GNUC_PREREQ (2,8) 43 # define __THROW throw () 44 # else 45 # define __THROW 46 # endif 47 #endif 48 49 #ifndef _LIBC 50 # define __md5_buffer md5_buffer 51 # define __md5_finish_ctx md5_finish_ctx 52 # define __md5_init_ctx md5_init_ctx 53 # define __md5_process_block md5_process_block 54 # define __md5_process_bytes md5_process_bytes 55 # define __md5_read_ctx md5_read_ctx 56 # define __md5_stream md5_stream 57 #endif 58 59 # ifdef __cplusplus 60 extern "C" { 61 # endif 62 63 /* Structure to save state of computation between the single steps. */ 64 struct md5_ctx 65 { 66 uint32_t A; 67 uint32_t B; 68 uint32_t C; 69 uint32_t D; 70 71 uint32_t total[2]; 72 uint32_t buflen; 73 uint32_t buffer[32]; 74 }; 75 76 /* 77 * The following three functions are build up the low level used in 78 * the functions `md5_stream' and `md5_buffer'. 79 */ 80 81 /* Initialize structure containing state of computation. 82 (RFC 1321, 3.3: Step 3) */ 83 extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW; 84 85 /* Starting with the result of former calls of this function (or the 86 initialization function update the context for the next LEN bytes 87 starting at BUFFER. 88 It is necessary that LEN is a multiple of 64!!! */ 89 extern void __md5_process_block (const void *buffer, size_t len, 90 struct md5_ctx *ctx) __THROW; 91 92 /* Starting with the result of former calls of this function (or the 93 initialization function update the context for the next LEN bytes 94 starting at BUFFER. 95 It is NOT required that LEN is a multiple of 64. */ 96 extern void __md5_process_bytes (const void *buffer, size_t len, 97 struct md5_ctx *ctx) __THROW; 98 99 /* Process the remaining bytes in the buffer and put result from CTX 100 in first 16 bytes following RESBUF. The result is always in little 101 endian byte order, so that a byte-wise output yields to the wanted 102 ASCII representation of the message digest. */ 103 extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW; 104 105 106 /* Put result from CTX in first 16 bytes following RESBUF. The result is 107 always in little endian byte order, so that a byte-wise output yields 108 to the wanted ASCII representation of the message digest. */ 109 extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW; 110 111 112 /* Compute MD5 message digest for bytes read from STREAM. The 113 resulting message digest number will be written into the 16 bytes 114 beginning at RESBLOCK. */ 115 extern int __md5_stream (FILE *stream, void *resblock) __THROW; 116 117 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The 118 result is always in little endian byte order, so that a byte-wise 119 output yields to the wanted ASCII representation of the message 120 digest. */ 121 extern void *__md5_buffer (const char *buffer, size_t len, 122 void *resblock) __THROW; 123 124 # ifdef __cplusplus 125 } 126 # endif 127 128 #endif /* md5.h */ 129