xref: /openbsd/include/rmd160.h (revision 4a39ccd0)
1*4a39ccd0Sderaadt /*	$OpenBSD: rmd160.h,v 1.17 2012/12/05 23:19:57 deraadt 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 
28e5c6a985Smillert #define	RMD160_BLOCK_LENGTH		64
29e5c6a985Smillert #define	RMD160_DIGEST_LENGTH		20
30e5c6a985Smillert #define	RMD160_DIGEST_STRING_LENGTH	(RMD160_DIGEST_LENGTH * 2 + 1)
31e5c6a985Smillert 
32479fd71aSmarkus /* RMD160 context. */
33479fd71aSmarkus typedef struct RMD160Context {
34479fd71aSmarkus 	u_int32_t state[5];			/* state */
35e5c6a985Smillert 	u_int64_t count;			/* number of bits, mod 2^64 */
36e5c6a985Smillert 	u_int8_t buffer[RMD160_BLOCK_LENGTH];	/* input buffer */
37780327d8Smillert } RMD160_CTX;
38780327d8Smillert 
39232cf197Smillert __BEGIN_DECLS
40c72b5b24Smillert void	 RMD160Init(RMD160_CTX *);
41e5c6a985Smillert void	 RMD160Transform(u_int32_t [5], const u_int8_t [RMD160_BLOCK_LENGTH])
42d9dd16ceSavsm 		__attribute__((__bounded__(__minbytes__,1,5)))
43e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,2,RMD160_BLOCK_LENGTH)));
449dfc8d30Smillert void	 RMD160Update(RMD160_CTX *, const u_int8_t *, size_t)
45d9dd16ceSavsm 		__attribute__((__bounded__(__string__,2,3)));
469dfc8d30Smillert void	 RMD160Pad(RMD160_CTX *);
47e5c6a985Smillert void	 RMD160Final(u_int8_t [RMD160_DIGEST_LENGTH], RMD160_CTX *)
48e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,1,RMD160_DIGEST_LENGTH)));
496cb58d42Smillert char	*RMD160End(RMD160_CTX *, char *)
50e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
51e4803734Sjfb char	*RMD160File(const char *, char *)
52e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
53e4803734Sjfb char	*RMD160FileChunk(const char *, char *, off_t, off_t)
549dfc8d30Smillert 		__attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
556cb58d42Smillert char	*RMD160Data(const u_int8_t *, size_t, char *)
56d9dd16ceSavsm 		__attribute__((__bounded__(__string__,1,2)))
57e5c6a985Smillert 		__attribute__((__bounded__(__minbytes__,3,RMD160_DIGEST_STRING_LENGTH)));
58232cf197Smillert __END_DECLS
59780327d8Smillert 
60780327d8Smillert #endif  /* _RMD160_H */
61