X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/4b8483ae278577a3adc8d84da81d77019704466f..b7a8b5277d37b289361ff0cc881632f527e4d5db:/md5.h?ds=sidebyside diff --git a/md5.h b/md5.h index 65a2159..92f45db 100644 --- a/md5.h +++ b/md5.h @@ -1,23 +1,67 @@ -#ifndef __MD5_H__ -#define __MD5_H__ +/* Declaration of functions and data types used for MD5 sum computing + library functions. + Copyright (C) 1995,1996,1997,1999,2000,2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MD5_H +#define _MD5_H 1 #include -#include -#include -#include +#include +#include +typedef size_t md5_uintptr; + +/* Structure to save state of computation between the single steps. */ +struct md5_ctx +{ + char buffer[128]; + uint32_t A; + uint32_t B; + uint32_t C; + uint32_t D; + + uint32_t total[2]; + uint32_t buflen; +}; + +/* + * The following three functions are build up the low level used in + * the functions `md5_stream' and `md5_buffer'. + */ + +/* Initialize structure containing state of computation. + (RFC 1321, 3.3: Step 3) */ +extern void md5_init(struct md5_ctx *ctx); -#include "bithelp.h" +/* Starting with the result of former calls of this function (or the + initialization function update the context for the next LEN bytes + starting at BUFFER. + It is NOT required that LEN is a multiple of 64. */ +extern void md5_update(struct md5_ctx *ctx, unsigned length, + const uint8_t *buffer); -typedef struct { - unsigned int A,B,C,D; /* chaining variables */ - unsigned int nblocks; - unsigned char buf[64]; - int count; -} MD5_CONTEXT; +/* Process the remaining bytes in the buffer and put result from CTX + in first 16 bytes following RESBUF. The result is always in little + endian byte order, so that a byte-wise output yields to the wanted + ASCII representation of the message digest. -void md5_init(MD5_CONTEXT *); -void md5_write(MD5_CONTEXT *, unsigned char *, size_t); -void md5_final(MD5_CONTEXT *); -unsigned char *md5_read(MD5_CONTEXT *); + IMPORTANT: On some systems it is required that RESBUF is correctly + aligned for a 32 bits value. */ +extern void md5_digest(struct md5_ctx *ctx, unsigned length, uint8_t *resbuf); -#endif /* __MD5_H__ */ +#endif /* md5.h */