sha.h revision 44290
155714Skris/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 255714Skris * All rights reserved. 355714Skris * 455714Skris * This package is an SSL implementation written 555714Skris * by Eric Young (eay@cryptsoft.com). 655714Skris * The implementation was written so as to conform with Netscapes SSL. 755714Skris * 855714Skris * This library is free for commercial and non-commercial use as long as 955714Skris * the following conditions are aheared to. The following conditions 1055714Skris * apply to all code found in this distribution, be it the RC4, RSA, 1155714Skris * lhash, DES, etc., code; not just the SSL code. The SSL documentation 1255714Skris * included with this distribution is covered by the same copyright terms 1355714Skris * except that the holder is Tim Hudson (tjh@cryptsoft.com). 1455714Skris * 1555714Skris * Copyright remains Eric Young's, and as such any Copyright notices in 1655714Skris * the code are not to be removed. 1755714Skris * If this package is used in a product, Eric Young should be given attribution 1855714Skris * as the author of the parts of the library used. 1955714Skris * This can be in the form of a textual message at program startup or 2055714Skris * in documentation (online or textual) provided with the package. 2155714Skris * 2255714Skris * Redistribution and use in source and binary forms, with or without 2355714Skris * modification, are permitted provided that the following conditions 2455714Skris * are met: 2555714Skris * 1. Redistributions of source code must retain the copyright 2655714Skris * notice, this list of conditions and the following disclaimer. 2755714Skris * 2. Redistributions in binary form must reproduce the above copyright 2855714Skris * notice, this list of conditions and the following disclaimer in the 2955714Skris * documentation and/or other materials provided with the distribution. 3055714Skris * 3. All advertising materials mentioning features or use of this software 3155714Skris * must display the following acknowledgement: 3255714Skris * "This product includes cryptographic software written by 3355714Skris * Eric Young (eay@cryptsoft.com)" 3455714Skris * The word 'cryptographic' can be left out if the rouines from the library 3555714Skris * being used are not cryptographic related :-). 3655714Skris * 4. If you include any Windows specific code (or a derivative thereof) from 3755714Skris * the apps directory (application code) you must include an acknowledgement: 3855714Skris * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 3955714Skris * 4055714Skris * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 4155714Skris * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4255714Skris * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 4355714Skris * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 4455714Skris * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 4555714Skris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 4655714Skris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4755714Skris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 4855714Skris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 4955714Skris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5055714Skris * SUCH DAMAGE. 5155714Skris * 5255714Skris * The licence and distribution terms for any publically available version or 5355714Skris * derivative of this code cannot be changed. i.e. this code cannot simply be 5455714Skris * copied and put under another distribution licence 5555714Skris * [including the GNU Public Licence.] 5655714Skris * 5755714Skris * $Id$ 5855714Skris */ 59100936Snectar 60100936Snectar#ifndef _SHA_H_ 61100936Snectar#define _SHA_H_ 1 62100936Snectar 63100936Snectar#include <sys/cdefs.h> 64100936Snectar#include <sys/types.h> /* XXX switch to machine/ansi.h and __ types */ 65100936Snectar 6655714Skris#define SHA_CBLOCK 64 6755714Skris#define SHA_LBLOCK 16 6855714Skris#define SHA_BLOCK 16 6955714Skris#define SHA_LAST_BLOCK 56 7055714Skris#define SHA_LENGTH_BLOCK 8 7159191Skris#define SHA_DIGEST_LENGTH 20 7259191Skris 7359191Skristypedef struct SHAstate_st { 7459191Skris u_int32_t h0, h1, h2, h3, h4; 7555714Skris u_int32_t Nl, Nh; 7659191Skris u_int32_t data[SHA_LBLOCK]; 7759191Skris int num; 7859191Skris} SHA_CTX; 7979998Skris#define SHA1_CTX SHA_CTX 8055714Skris 8155714Skris__BEGIN_DECLS 8259191Skrisvoid SHA_Init(SHA_CTX *c); 8359191Skrisvoid SHA_Update(SHA_CTX *c, const unsigned char *data, u_int32_t len); 8459191Skrisvoid SHA_Final(unsigned char *md, SHA_CTX *c); 8559191Skrisvoid SHA_Transform(SHA_CTX *c, unsigned char *data); 8659191Skrischar *SHA_End(SHA_CTX *, char *); 8759191Skrischar *SHA_File(const char *, char *); 8868651Skrischar *SHA_Data(const unsigned char *, unsigned int, char *); 8959191Skrisvoid SHA1_Init(SHA_CTX *c); 9059191Skrisvoid SHA1_Update(SHA_CTX *c, const unsigned char *data, unsigned long len); 9159191Skrisvoid SHA1_Final(unsigned char *md, SHA_CTX *c); 9259191Skrisunsigned char *SHA1(unsigned char *d, unsigned long n, unsigned char *md); 9359191Skrisvoid SHA1_Transform(SHA_CTX *c, unsigned char *data); 9459191Skrischar *SHA1_End(SHA_CTX *, char *); 9559191Skrischar *SHA1_File(const char *, char *); 9659191Skrischar *SHA1_Data(const unsigned char *, unsigned int, char *); 9759191Skris__END_DECLS 9859191Skris 9959191Skris#endif /* !_SHA_H_ */ 10059191Skris