1 /* @(#)rmd160.h 1.5 10/08/27 2009-2010 J. Schilling */ 2 /* 3 * RMD160 hash code taken from OpenBSD 4 * 5 * Portions Copyright (c) 2009-2010 J. Schilling 6 */ 7 /* $OpenBSD: rmd160.h,v 1.16 2004/06/22 01:57:30 jfb Exp $ */ 8 /* 9 * Copyright (c) 2001 Markus Friedl. All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 #ifndef _SCHILY_RMD160_H 32 #define _SCHILY_RMD160_H 33 34 #ifndef _SCHILY_MCONFIG_H 35 #include <schily/mconfig.h> 36 #endif 37 #include <schily/utypes.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 #define RMD160_BLOCK_LENGTH 64 44 #define RMD160_DIGEST_LENGTH 20 45 #define RMD160_DIGEST_STRING_LENGTH (RMD160_DIGEST_LENGTH * 2 + 1) 46 47 /* RMD160 context. */ 48 typedef struct RMD160Context { 49 UInt32_t state[5]; /* state */ 50 UInt32_t count[2]; /* number of bits, mod 2^64 */ 51 UInt8_t buffer[RMD160_BLOCK_LENGTH]; /* input buffer */ 52 } RMD160_CTX; 53 54 extern void RMD160Init __PR((RMD160_CTX *)); 55 extern void RMD160Transform __PR((UInt32_t [5], 56 const UInt8_t [RMD160_BLOCK_LENGTH])); 57 extern void RMD160Update __PR((RMD160_CTX *, const UInt8_t *, size_t)); 58 extern void RMD160Pad __PR((RMD160_CTX *)); 59 extern void RMD160Final __PR((UInt8_t [RMD160_DIGEST_LENGTH], 60 RMD160_CTX *)); 61 extern char *RMD160End __PR((RMD160_CTX *, char *)); 62 extern char *RMD160File __PR((const char *, char *)); 63 extern char *RMD160FileChunk __PR((const char *, char *, off_t, off_t)); 64 extern char *RMD160Data __PR((const UInt8_t *, size_t, char *)); 65 66 #ifdef __cplusplus 67 } 68 #endif 69 70 #endif /* _SCHILY_RMD160_H */ 71