1285031Sdes/*	$OpenBSD: rmd160.h,v 1.17 2012/12/05 23:19:57 deraadt Exp $	*/
2285031Sdes/*
3285031Sdes * Copyright (c) 2001 Markus Friedl.  All rights reserved.
4285031Sdes *
5285031Sdes * Redistribution and use in source and binary forms, with or without
6285031Sdes * modification, are permitted provided that the following conditions
7285031Sdes * are met:
8285031Sdes * 1. Redistributions of source code must retain the above copyright
9285031Sdes *    notice, this list of conditions and the following disclaimer.
10285031Sdes * 2. Redistributions in binary form must reproduce the above copyright
11285031Sdes *    notice, this list of conditions and the following disclaimer in the
12285031Sdes *    documentation and/or other materials provided with the distribution.
13285031Sdes *
14285031Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15285031Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16285031Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17285031Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18285031Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19285031Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20285031Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21285031Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22285031Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23285031Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24285031Sdes */
25285031Sdes#ifndef  _RMD160_H
26285031Sdes#define  _RMD160_H
27285031Sdes
28285031Sdes#ifndef WITH_OPENSSL
29285031Sdes
30285031Sdes#define	RMD160_BLOCK_LENGTH		64
31285031Sdes#define	RMD160_DIGEST_LENGTH		20
32285031Sdes#define	RMD160_DIGEST_STRING_LENGTH	(RMD160_DIGEST_LENGTH * 2 + 1)
33285031Sdes
34285031Sdes/* RMD160 context. */
35285031Sdestypedef struct RMD160Context {
36285031Sdes	u_int32_t state[5];			/* state */
37285031Sdes	u_int64_t count;			/* number of bits, mod 2^64 */
38285031Sdes	u_int8_t buffer[RMD160_BLOCK_LENGTH];	/* input buffer */
39285031Sdes} RMD160_CTX;
40285031Sdes
41285031Sdesvoid	 RMD160Init(RMD160_CTX *);
42285031Sdesvoid	 RMD160Transform(u_int32_t [5], const u_int8_t [RMD160_BLOCK_LENGTH])
43285031Sdes		__attribute__((__bounded__(__minbytes__,1,5)))
44285031Sdes		__attribute__((__bounded__(__minbytes__,2,RMD160_BLOCK_LENGTH)));
45285031Sdesvoid	 RMD160Update(RMD160_CTX *, const u_int8_t *, size_t)
46285031Sdes		__attribute__((__bounded__(__string__,2,3)));
47285031Sdesvoid	 RMD160Pad(RMD160_CTX *);
48285031Sdesvoid	 RMD160Final(u_int8_t [RMD160_DIGEST_LENGTH], RMD160_CTX *)
49285031Sdes		__attribute__((__bounded__(__minbytes__,1,RMD160_DIGEST_LENGTH)));
50285031Sdeschar	*RMD160End(RMD160_CTX *, char *)
51285031Sdes		__attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
52285031Sdeschar	*RMD160File(const char *, char *)
53285031Sdes		__attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
54285031Sdeschar	*RMD160FileChunk(const char *, char *, off_t, off_t)
55285031Sdes		__attribute__((__bounded__(__minbytes__,2,RMD160_DIGEST_STRING_LENGTH)));
56285031Sdeschar	*RMD160Data(const u_int8_t *, size_t, char *)
57285031Sdes		__attribute__((__bounded__(__string__,1,2)))
58285031Sdes		__attribute__((__bounded__(__minbytes__,3,RMD160_DIGEST_STRING_LENGTH)));
59285031Sdes
60285031Sdes#endif /* !WITH_OPENSSL */
61285031Sdes#endif  /* _RMD160_H */
62