144290Swollman/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
244290Swollman * All rights reserved.
344290Swollman *
444290Swollman * This package is an SSL implementation written
544290Swollman * by Eric Young (eay@cryptsoft.com).
644290Swollman * The implementation was written so as to conform with Netscapes SSL.
744290Swollman *
844290Swollman * This library is free for commercial and non-commercial use as long as
944290Swollman * the following conditions are aheared to.  The following conditions
1044290Swollman * apply to all code found in this distribution, be it the RC4, RSA,
1144290Swollman * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1244290Swollman * included with this distribution is covered by the same copyright terms
1344290Swollman * except that the holder is Tim Hudson (tjh@cryptsoft.com).
1444290Swollman *
1544290Swollman * Copyright remains Eric Young's, and as such any Copyright notices in
1644290Swollman * the code are not to be removed.
1744290Swollman * If this package is used in a product, Eric Young should be given attribution
1844290Swollman * as the author of the parts of the library used.
1944290Swollman * This can be in the form of a textual message at program startup or
2044290Swollman * in documentation (online or textual) provided with the package.
2144290Swollman *
2244290Swollman * Redistribution and use in source and binary forms, with or without
2344290Swollman * modification, are permitted provided that the following conditions
2444290Swollman * are met:
2544290Swollman * 1. Redistributions of source code must retain the copyright
2644290Swollman *    notice, this list of conditions and the following disclaimer.
2744290Swollman * 2. Redistributions in binary form must reproduce the above copyright
2844290Swollman *    notice, this list of conditions and the following disclaimer in the
2944290Swollman *    documentation and/or other materials provided with the distribution.
3044290Swollman * 3. All advertising materials mentioning features or use of this software
3144290Swollman *    must display the following acknowledgement:
3244290Swollman *    "This product includes cryptographic software written by
3344290Swollman *     Eric Young (eay@cryptsoft.com)"
3444290Swollman *    The word 'cryptographic' can be left out if the rouines from the library
3544290Swollman *    being used are not cryptographic related :-).
3644290Swollman * 4. If you include any Windows specific code (or a derivative thereof) from
3744290Swollman *    the apps directory (application code) you must include an acknowledgement:
3844290Swollman *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
3944290Swollman *
4044290Swollman * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4144290Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4244290Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4344290Swollman * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4444290Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4544290Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4644290Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4744290Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4844290Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4944290Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5044290Swollman * SUCH DAMAGE.
5144290Swollman *
5244290Swollman * The licence and distribution terms for any publically available version or
5344290Swollman * derivative of this code cannot be changed.  i.e. this code cannot simply be
5444290Swollman * copied and put under another distribution licence
5544290Swollman * [including the GNU Public Licence.]
5644290Swollman *
5750476Speter * $FreeBSD: stable/10/lib/libmd/sha.h 314157 2017-02-23 18:54:33Z avg $
5844290Swollman */
5944290Swollman
6044290Swollman#ifndef _SHA_H_
6144290Swollman#define _SHA_H_		1
6244290Swollman
6344290Swollman#include <sys/cdefs.h>
6444290Swollman#include <sys/types.h>		/* XXX switch to machine/ansi.h and __ types */
6544290Swollman
6644290Swollman#define	SHA_CBLOCK	64
6744290Swollman#define	SHA_LBLOCK	16
6844290Swollman#define	SHA_BLOCK	16
6944290Swollman#define	SHA_LAST_BLOCK  56
7044290Swollman#define	SHA_LENGTH_BLOCK 8
7144290Swollman#define	SHA_DIGEST_LENGTH 20
7244290Swollman
7344290Swollmantypedef struct SHAstate_st {
7444290Swollman	u_int32_t h0, h1, h2, h3, h4;
7544290Swollman	u_int32_t Nl, Nh;
7644290Swollman	u_int32_t data[SHA_LBLOCK];
7744290Swollman	int num;
7844290Swollman} SHA_CTX;
7944290Swollman#define	SHA1_CTX	SHA_CTX
8044290Swollman
8144290Swollman__BEGIN_DECLS
82314144Savg
83314144Savg/* Ensure libmd symbols do not clash with libcrypto */
84314144Savg
85314157Savg#ifndef SHA_Init
86314144Savg#define SHA_Init	_libmd_SHA_Init
87314157Savg#endif
88314157Savg#ifndef SHA_Update
89314144Savg#define SHA_Update	_libmd_SHA_Update
90314157Savg#endif
91314157Savg#ifndef SHA_Final
92314144Savg#define SHA_Final	_libmd_SHA_Final
93314157Savg#endif
94314157Savg#ifndef SHA_End
95314144Savg#define SHA_End		_libmd_SHA_End
96314157Savg#endif
97314157Savg#ifndef SHA_File
98314144Savg#define SHA_File	_libmd_SHA_File
99314157Savg#endif
100314157Savg#ifndef SHA_FileChunk
101314144Savg#define SHA_FileChunk	_libmd_SHA_FileChunk
102314157Savg#endif
103314157Savg#ifndef SHA_Data
104314144Savg#define SHA_Data	_libmd_SHA_Data
105314157Savg#endif
106314144Savg
107314157Savg#ifndef SHA_Transform
108314144Savg#define SHA_Transform	_libmd_SHA_Transform
109314157Savg#endif
110314157Savg#ifndef SHA_version
111314144Savg#define SHA_version	_libmd_SHA_version
112314157Savg#endif
113314157Savg#ifndef sha_block
114314144Savg#define sha_block	_libmd_sha_block
115314157Savg#endif
116314144Savg
117314157Savg#ifndef SHA1_Init
118314144Savg#define SHA1_Init	_libmd_SHA1_Init
119314157Savg#endif
120314157Savg#ifndef SHA1_Update
121314144Savg#define SHA1_Update	_libmd_SHA1_Update
122314157Savg#endif
123314157Savg#ifndef SHA1_Final
124314144Savg#define SHA1_Final	_libmd_SHA1_Final
125314157Savg#endif
126314157Savg#ifndef SHA1_End
127314144Savg#define SHA1_End	_libmd_SHA1_End
128314157Savg#endif
129314157Savg#ifndef SHA1_File
130314144Savg#define SHA1_File	_libmd_SHA1_File
131314157Savg#endif
132314157Savg#ifndef SHA1_FileChunk
133314144Savg#define SHA1_FileChunk	_libmd_SHA1_FileChunk
134314157Savg#endif
135314157Savg#ifndef SHA1_Data
136314144Savg#define SHA1_Data	_libmd_SHA1_Data
137314157Savg#endif
138314144Savg
139314157Savg#ifndef SHA1_Transform
140314144Savg#define SHA1_Transform	_libmd_SHA1_Transform
141314157Savg#endif
142314157Savg#ifndef SHA1_version
143314144Savg#define SHA1_version	_libmd_SHA1_version
144314157Savg#endif
145314157Savg#ifndef sha1_block
146314144Savg#define sha1_block	_libmd_sha1_block
147314157Savg#endif
148314144Savg
14944290Swollmanvoid	SHA_Init(SHA_CTX *c);
150154479Sphkvoid	SHA_Update(SHA_CTX *c, const void *data, size_t len);
15144290Swollmanvoid	SHA_Final(unsigned char *md, SHA_CTX *c);
15244290Swollmanchar   *SHA_End(SHA_CTX *, char *);
15344290Swollmanchar   *SHA_File(const char *, char *);
15474385Sphkchar   *SHA_FileChunk(const char *, char *, off_t, off_t);
155154479Sphkchar   *SHA_Data(const void *, unsigned int, char *);
156314144Savg
15744290Swollmanvoid	SHA1_Init(SHA_CTX *c);
158154479Sphkvoid	SHA1_Update(SHA_CTX *c, const void *data, size_t len);
15944290Swollmanvoid	SHA1_Final(unsigned char *md, SHA_CTX *c);
16044290Swollmanchar   *SHA1_End(SHA_CTX *, char *);
16144290Swollmanchar   *SHA1_File(const char *, char *);
16274385Sphkchar   *SHA1_FileChunk(const char *, char *, off_t, off_t);
163154479Sphkchar   *SHA1_Data(const void *, unsigned int, char *);
16444290Swollman__END_DECLS
16544290Swollman
16644290Swollman#endif /* !_SHA_H_ */
167