xref: /openbsd/include/rmd160.h (revision e5c6a985)
1*e5c6a985Smillert /*	$OpenBSD: rmd160.h,v 1.13 2004/04/26 19:38:12 millert Exp $	*/
2479fd71aSmarkus /*
3479fd71aSmarkus  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
4780327d8Smillert  *
5479fd71aSmarkus  * Redistribution and use in source and binary forms, with or without
6479fd71aSmarkus  * modification, are permitted provided that the following conditions
7479fd71aSmarkus  * are met:
8479fd71aSmarkus  * 1. Redistributions of source code must retain the above copyright
9479fd71aSmarkus  *    notice, this list of conditions and the following disclaimer.
10479fd71aSmarkus  * 2. Redistributions in binary form must reproduce the above copyright
11479fd71aSmarkus  *    notice, this list of conditions and the following disclaimer in the
12479fd71aSmarkus  *    documentation and/or other materials provided with the distribution.
13780327d8Smillert  *
14479fd71aSmarkus  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15479fd71aSmarkus  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16479fd71aSmarkus  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17479fd71aSmarkus  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18479fd71aSmarkus  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19479fd71aSmarkus  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20479fd71aSmarkus  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21479fd71aSmarkus  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22479fd71aSmarkus  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23479fd71aSmarkus  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24479fd71aSmarkus  */
25479fd71aSmarkus #ifndef  _RMD160_H
26780327d8Smillert #define  _RMD160_H
27780327d8Smillert 
28*e5c6a985Smillert #define	RMD160_BLOCK_LENGTH		64
29*e5c6a985Smillert #define	RMD160_DIGEST_LENGTH		20
30*e5c6a985Smillert #define	RMD160_DIGEST_STRING_LENGTH	(RMD160_DIGEST_LENGTH * 2 + 1)
31*e5c6a985Smillert 
32479fd71aSmarkus /* RMD160 context. */
33479fd71aSmarkus typedef struct RMD160Context {
34479fd71aSmarkus 	u_int32_t state[5];			/* state */
35*e5c6a985Smillert 	u_int64_t count;			/* number of bits, mod 2^64 */
36*e5c6a985Smillert 	u_int8_t buffer[RMD160_BLOCK_LENGTH];	/* input buffer */
37780327d8Smillert } RMD160_CTX;
38780327d8Smillert 
39232cf197Smillert #include <sys/cdefs.h>
40232cf197Smillert 
41232cf197Smillert __BEGIN_DECLS
42c72b5b24Smillert void	 RMD160Init(RMD160_CTX *);
43*e5c6a985Smillert void	 RMD160Transform(u_int32_t [5], const u_int8_t [RMD160_BLOCK_LENGTH])
44d9dd16ceSavsm 		__attribute__((__bounded__(__minbytes__,1,5)))
45*e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,2,RMD160_BLOCK_LENGTH)));
46*e5c6a985Smillert void	 RMD160Update(RMD160_CTX *, const u_int8_t *, u_int32_t)
47d9dd16ceSavsm 		__attribute__((__bounded__(__string__,2,3)));
48*e5c6a985Smillert void	 RMD160Final(u_int8_t [RMD160_DIGEST_LENGTH], RMD160_CTX *)
49*e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,1,RMD160_DIGEST_LENGTH)));
50*e5c6a985Smillert char	*RMD160End(RMD160_CTX *, char [RMD160_DIGEST_STRING_LENGTH])
51*e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
52*e5c6a985Smillert char	*RMD160File(char *, char [RMD160_DIGEST_STRING_LENGTH])
53*e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
54*e5c6a985Smillert char	*RMD160Data(const u_int8_t *, size_t, char [RMD160_DIGEST_STRING_LENGTH])
55d9dd16ceSavsm 		__attribute__((__bounded__(__string__,1,2)))
56*e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,3,RMD160_DIGEST_STRING_LENGTH)));
57232cf197Smillert __END_DECLS
58780327d8Smillert 
59780327d8Smillert #endif  /* _RMD160_H */
60