sha.h revision 109998
172875Snik/* crypto/sha/sha.h */ 272875Snik/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 372875Snik * All rights reserved. 472875Snik * 572875Snik * This package is an SSL implementation written 672875Snik * by Eric Young (eay@cryptsoft.com). 772875Snik * The implementation was written so as to conform with Netscapes SSL. 872875Snik * 972875Snik * This library is free for commercial and non-commercial use as long as 1072875Snik * the following conditions are aheared to. The following conditions 1172875Snik * apply to all code found in this distribution, be it the RC4, RSA, 1272875Snik * lhash, DES, etc., code; not just the SSL code. The SSL documentation 1372875Snik * included with this distribution is covered by the same copyright terms 1472875Snik * except that the holder is Tim Hudson (tjh@cryptsoft.com). 1572875Snik * 1672875Snik * Copyright remains Eric Young's, and as such any Copyright notices in 1772875Snik * the code are not to be removed. 1872875Snik * If this package is used in a product, Eric Young should be given attribution 1972875Snik * as the author of the parts of the library used. 2072875Snik * This can be in the form of a textual message at program startup or 2172875Snik * in documentation (online or textual) provided with the package. 2272875Snik * 2372875Snik * Redistribution and use in source and binary forms, with or without 2472875Snik * modification, are permitted provided that the following conditions 2572875Snik * are met: 26173192Skeramida * 1. Redistributions of source code must retain the copyright 2772875Snik * notice, this list of conditions and the following disclaimer. 2872881Sru * 2. Redistributions in binary form must reproduce the above copyright 2972875Snik * notice, this list of conditions and the following disclaimer in the 3072881Sru * documentation and/or other materials provided with the distribution. 31107788Sru * 3. All advertising materials mentioning features or use of this software 3272875Snik * must display the following acknowledgement: 33107788Sru * "This product includes cryptographic software written by 3472875Snik * Eric Young (eay@cryptsoft.com)" 3572875Snik * The word 'cryptographic' can be left out if the rouines from the library 3672875Snik * being used are not cryptographic related :-). 37107788Sru * 4. If you include any Windows specific code (or a derivative thereof) from 3872881Sru * the apps directory (application code) you must include an acknowledgement: 3972875Snik * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 4072875Snik * 4172875Snik * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42166489Smpp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43166489Smpp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44166489Smpp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45166489Smpp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46166489Smpp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47233648Seadler * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48166489Smpp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49166489Smpp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50166489Smpp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51166489Smpp * SUCH DAMAGE. 52173192Skeramida * 53166489Smpp * The licence and distribution terms for any publically available version or 54166489Smpp * derivative of this code cannot be changed. i.e. this code cannot simply be 55166489Smpp * copied and put under another distribution licence 56166489Smpp * [including the GNU Public Licence.] 57166489Smpp */ 58166489Smpp 59166489Smpp#ifndef HEADER_SHA_H 60166489Smpp#define HEADER_SHA_H 61166489Smpp 62166489Smpp#include <openssl/e_os2.h> 63166489Smpp 64166489Smpp#ifdef __cplusplus 65166489Smppextern "C" { 66166489Smpp#endif 67166489Smpp 68166489Smpp#if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_SHA1)) 69166489Smpp#error SHA is disabled. 70166489Smpp#endif 71166489Smpp 72166489Smpp/* 73166489Smpp * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 74166489Smpp * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then ! 75233648Seadler * ! SHA_LONG_LOG2 has to be defined along. ! 76166489Smpp * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 77233648Seadler */ 78166489Smpp 79166489Smpp#if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) 80166489Smpp#define SHA_LONG unsigned long 81166489Smpp#elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) 82166489Smpp#define SHA_LONG unsigned long 83166489Smpp#define SHA_LONG_LOG2 3 84166489Smpp#else 85166489Smpp#define SHA_LONG unsigned int 86166489Smpp#endif 87166489Smpp 88166489Smpp#define SHA_LBLOCK 16 89166489Smpp#define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a 90166489Smpp * contiguous array of 32 bit 91166489Smpp * wide big-endian values. */ 92166489Smpp#define SHA_LAST_BLOCK (SHA_CBLOCK-8) 93166489Smpp#define SHA_DIGEST_LENGTH 20 94166489Smpp 95166489Smpptypedef struct SHAstate_st 96166489Smpp { 97166489Smpp SHA_LONG h0,h1,h2,h3,h4; 98166489Smpp SHA_LONG Nl,Nh; 99166489Smpp SHA_LONG data[SHA_LBLOCK]; 100166489Smpp int num; 101166489Smpp } SHA_CTX; 102166489Smpp 103166489Smpp#ifndef OPENSSL_NO_SHA0 104166489Smppint SHA_Init(SHA_CTX *c); 105166489Smppint SHA_Update(SHA_CTX *c, const void *data, unsigned long len); 106166489Smppint SHA_Final(unsigned char *md, SHA_CTX *c); 107233648Seadlerunsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md); 108233648Seadlervoid SHA_Transform(SHA_CTX *c, const unsigned char *data); 109166489Smpp#endif 110166489Smpp#ifndef OPENSSL_NO_SHA1 111166489Smppint SHA1_Init(SHA_CTX *c); 112166489Smppint SHA1_Update(SHA_CTX *c, const void *data, unsigned long len); 113166489Smppint SHA1_Final(unsigned char *md, SHA_CTX *c); 114166489Smppunsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md); 115166489Smppvoid SHA1_Transform(SHA_CTX *c, const unsigned char *data); 116166489Smpp#endif 117166489Smpp#ifdef __cplusplus 118166489Smpp} 119166489Smpp#endif 120166489Smpp 12172875Snik#endif 12272875Snik