xref: /freebsd/lib/libmd/ripemd.h (revision c02bc0aa0b22009e4bc209efae99c877167e1161)
1d00ed299SGarrett Wollman /* crypto/ripemd/ripemd.h */
2d00ed299SGarrett Wollman /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3d00ed299SGarrett Wollman  * All rights reserved.
4d00ed299SGarrett Wollman  *
5d00ed299SGarrett Wollman  * This package is an SSL implementation written
6d00ed299SGarrett Wollman  * by Eric Young (eay@cryptsoft.com).
7d00ed299SGarrett Wollman  * The implementation was written so as to conform with Netscapes SSL.
8d00ed299SGarrett Wollman  *
9d00ed299SGarrett Wollman  * This library is free for commercial and non-commercial use as long as
10d00ed299SGarrett Wollman  * the following conditions are aheared to.  The following conditions
11d00ed299SGarrett Wollman  * apply to all code found in this distribution, be it the RC4, RSA,
12d00ed299SGarrett Wollman  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13d00ed299SGarrett Wollman  * included with this distribution is covered by the same copyright terms
14d00ed299SGarrett Wollman  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15d00ed299SGarrett Wollman  *
16d00ed299SGarrett Wollman  * Copyright remains Eric Young's, and as such any Copyright notices in
17d00ed299SGarrett Wollman  * the code are not to be removed.
18d00ed299SGarrett Wollman  * If this package is used in a product, Eric Young should be given attribution
19d00ed299SGarrett Wollman  * as the author of the parts of the library used.
20d00ed299SGarrett Wollman  * This can be in the form of a textual message at program startup or
21d00ed299SGarrett Wollman  * in documentation (online or textual) provided with the package.
22d00ed299SGarrett Wollman  *
23d00ed299SGarrett Wollman  * Redistribution and use in source and binary forms, with or without
24d00ed299SGarrett Wollman  * modification, are permitted provided that the following conditions
25d00ed299SGarrett Wollman  * are met:
26d00ed299SGarrett Wollman  * 1. Redistributions of source code must retain the copyright
27d00ed299SGarrett Wollman  *    notice, this list of conditions and the following disclaimer.
28d00ed299SGarrett Wollman  * 2. Redistributions in binary form must reproduce the above copyright
29d00ed299SGarrett Wollman  *    notice, this list of conditions and the following disclaimer in the
30d00ed299SGarrett Wollman  *    documentation and/or other materials provided with the distribution.
31d00ed299SGarrett Wollman  * 3. All advertising materials mentioning features or use of this software
32d00ed299SGarrett Wollman  *    must display the following acknowledgement:
33d00ed299SGarrett Wollman  *    "This product includes cryptographic software written by
34d00ed299SGarrett Wollman  *     Eric Young (eay@cryptsoft.com)"
353e5a11d5SGordon Bergling  *    The word 'cryptographic' can be left out if the routines from the library
36d00ed299SGarrett Wollman  *    being used are not cryptographic related :-).
37d00ed299SGarrett Wollman  * 4. If you include any Windows specific code (or a derivative thereof) from
38d00ed299SGarrett Wollman  *    the apps directory (application code) you must include an acknowledgement:
39d00ed299SGarrett Wollman  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40d00ed299SGarrett Wollman  *
41d00ed299SGarrett Wollman  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42d00ed299SGarrett Wollman  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43d00ed299SGarrett Wollman  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44d00ed299SGarrett Wollman  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45d00ed299SGarrett Wollman  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46d00ed299SGarrett Wollman  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47d00ed299SGarrett Wollman  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48d00ed299SGarrett Wollman  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49d00ed299SGarrett Wollman  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50d00ed299SGarrett Wollman  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51d00ed299SGarrett Wollman  * SUCH DAMAGE.
52d00ed299SGarrett Wollman  *
53d00ed299SGarrett Wollman  * The licence and distribution terms for any publically available version or
54d00ed299SGarrett Wollman  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55d00ed299SGarrett Wollman  * copied and put under another distribution licence
56d00ed299SGarrett Wollman  * [including the GNU Public Licence.]
57d00ed299SGarrett Wollman  */
58d00ed299SGarrett Wollman 
598a24546cSPoul-Henning Kamp /*
608a24546cSPoul-Henning Kamp  */
618a24546cSPoul-Henning Kamp 
62d00ed299SGarrett Wollman #ifndef HEADER_RIPEMD_H
63d00ed299SGarrett Wollman #define HEADER_RIPEMD_H
64d00ed299SGarrett Wollman 
65d00ed299SGarrett Wollman #include <sys/types.h>		/* XXX switch to machine/ansi.h and __ types */
66d00ed299SGarrett Wollman 
67d00ed299SGarrett Wollman #define RIPEMD160_CBLOCK	64
68d00ed299SGarrett Wollman #define RIPEMD160_LBLOCK	16
69d00ed299SGarrett Wollman #define RIPEMD160_BLOCK		16
70d00ed299SGarrett Wollman #define RIPEMD160_LAST_BLOCK	56
71d00ed299SGarrett Wollman #define RIPEMD160_LENGTH_BLOCK	8
72d00ed299SGarrett Wollman #define RIPEMD160_DIGEST_LENGTH	20
73d00ed299SGarrett Wollman 
74d00ed299SGarrett Wollman typedef struct RIPEMD160state_st {
75d00ed299SGarrett Wollman 	u_int32_t A,B,C,D,E;
76d00ed299SGarrett Wollman 	u_int32_t Nl,Nh;
77d00ed299SGarrett Wollman 	u_int32_t data[RIPEMD160_LBLOCK];
78d00ed299SGarrett Wollman 	int num;
79d00ed299SGarrett Wollman } RIPEMD160_CTX;
80d00ed299SGarrett Wollman 
81d00ed299SGarrett Wollman __BEGIN_DECLS
829d8b6686SThomas Quinot 
839d8b6686SThomas Quinot /* Ensure libmd symbols do not clash with libcrypto */
849d8b6686SThomas Quinot 
8555b13095SThomas Quinot #ifndef RIPEMD160_Init
869d8b6686SThomas Quinot #define RIPEMD160_Init		_libmd_RIPEMD160_Init
8755b13095SThomas Quinot #endif
8855b13095SThomas Quinot #ifndef RIPEMD160_Update
899d8b6686SThomas Quinot #define RIPEMD160_Update	_libmd_RIPEMD160_Update
9055b13095SThomas Quinot #endif
9155b13095SThomas Quinot #ifndef RIPEMD160_Final
929d8b6686SThomas Quinot #define RIPEMD160_Final		_libmd_RIPEMD160_Final
9355b13095SThomas Quinot #endif
9455b13095SThomas Quinot #ifndef RIPEMD160_End
959d8b6686SThomas Quinot #define RIPEMD160_End		_libmd_RIPEMD160_End
9655b13095SThomas Quinot #endif
97de13c242SEd Maste #ifndef RIPEMD160_Fd
98de13c242SEd Maste #define RIPEMD160_Fd		_libmd_RIPEMD160_Fd
99de13c242SEd Maste #endif
100de13c242SEd Maste #ifndef RIPEMD160_FdChunk
101de13c242SEd Maste #define RIPEMD160_FdChunk	_libmd_RIPEMD160_FdChunk
102de13c242SEd Maste #endif
10355b13095SThomas Quinot #ifndef RIPEMD160_File
1049d8b6686SThomas Quinot #define RIPEMD160_File		_libmd_RIPEMD160_File
10555b13095SThomas Quinot #endif
10655b13095SThomas Quinot #ifndef RIPEMD160_FileChunk
1079d8b6686SThomas Quinot #define RIPEMD160_FileChunk	_libmd_RIPEMD160_FileChunk
10855b13095SThomas Quinot #endif
10955b13095SThomas Quinot #ifndef RIPEMD160_Data
1109d8b6686SThomas Quinot #define RIPEMD160_Data		_libmd_RIPEMD160_Data
11155b13095SThomas Quinot #endif
112*c02bc0aaSKyle Evans #ifndef RIPEMD160_Transform
113*c02bc0aaSKyle Evans #define RIPEMD160_Transform		_libmd_RIPEMD160_Transform
114*c02bc0aaSKyle Evans #endif
1159d8b6686SThomas Quinot 
11655b13095SThomas Quinot #ifndef ripemd160_block
1179d8b6686SThomas Quinot #define ripemd160_block		_libmd_ripemd160_block
11855b13095SThomas Quinot #endif
1199d8b6686SThomas Quinot 
120d00ed299SGarrett Wollman void	RIPEMD160_Init(RIPEMD160_CTX *c);
12125a14196SPoul-Henning Kamp void	RIPEMD160_Update(RIPEMD160_CTX *c, const void *data,
122d00ed299SGarrett Wollman 			 size_t len);
123d00ed299SGarrett Wollman void	RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
124d00ed299SGarrett Wollman char   *RIPEMD160_End(RIPEMD160_CTX *, char *);
125de13c242SEd Maste char   *RIPEMD160_Fd(int, char *);
126de13c242SEd Maste char   *RIPEMD160_FdChunk(int, char *, off_t, off_t);
127d00ed299SGarrett Wollman char   *RIPEMD160_File(const char *, char *);
1288a24546cSPoul-Henning Kamp char   *RIPEMD160_FileChunk(const char *, char *, off_t, off_t);
12925a14196SPoul-Henning Kamp char   *RIPEMD160_Data(const void *, unsigned int, char *);
130d00ed299SGarrett Wollman __END_DECLS
131d00ed299SGarrett Wollman 
132d00ed299SGarrett Wollman #endif
133