1c177a86bSGarrett Wollman /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2c177a86bSGarrett Wollman * All rights reserved. 3c177a86bSGarrett Wollman * 4c177a86bSGarrett Wollman * This package is an SSL implementation written 5c177a86bSGarrett Wollman * by Eric Young (eay@cryptsoft.com). 6c177a86bSGarrett Wollman * The implementation was written so as to conform with Netscapes SSL. 7c177a86bSGarrett Wollman * 8c177a86bSGarrett Wollman * This library is free for commercial and non-commercial use as long as 9c177a86bSGarrett Wollman * the following conditions are aheared to. The following conditions 10c177a86bSGarrett Wollman * apply to all code found in this distribution, be it the RC4, RSA, 11c177a86bSGarrett Wollman * lhash, DES, etc., code; not just the SSL code. The SSL documentation 12c177a86bSGarrett Wollman * included with this distribution is covered by the same copyright terms 13c177a86bSGarrett Wollman * except that the holder is Tim Hudson (tjh@cryptsoft.com). 14c177a86bSGarrett Wollman * 15c177a86bSGarrett Wollman * Copyright remains Eric Young's, and as such any Copyright notices in 16c177a86bSGarrett Wollman * the code are not to be removed. 17c177a86bSGarrett Wollman * If this package is used in a product, Eric Young should be given attribution 18c177a86bSGarrett Wollman * as the author of the parts of the library used. 19c177a86bSGarrett Wollman * This can be in the form of a textual message at program startup or 20c177a86bSGarrett Wollman * in documentation (online or textual) provided with the package. 21c177a86bSGarrett Wollman * 22c177a86bSGarrett Wollman * Redistribution and use in source and binary forms, with or without 23c177a86bSGarrett Wollman * modification, are permitted provided that the following conditions 24c177a86bSGarrett Wollman * are met: 25c177a86bSGarrett Wollman * 1. Redistributions of source code must retain the copyright 26c177a86bSGarrett Wollman * notice, this list of conditions and the following disclaimer. 27c177a86bSGarrett Wollman * 2. Redistributions in binary form must reproduce the above copyright 28c177a86bSGarrett Wollman * notice, this list of conditions and the following disclaimer in the 29c177a86bSGarrett Wollman * documentation and/or other materials provided with the distribution. 30c177a86bSGarrett Wollman * 3. All advertising materials mentioning features or use of this software 31c177a86bSGarrett Wollman * must display the following acknowledgement: 32c177a86bSGarrett Wollman * "This product includes cryptographic software written by 33c177a86bSGarrett Wollman * Eric Young (eay@cryptsoft.com)" 34c177a86bSGarrett Wollman * The word 'cryptographic' can be left out if the rouines from the library 35c177a86bSGarrett Wollman * being used are not cryptographic related :-). 36c177a86bSGarrett Wollman * 4. If you include any Windows specific code (or a derivative thereof) from 37c177a86bSGarrett Wollman * the apps directory (application code) you must include an acknowledgement: 38c177a86bSGarrett Wollman * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 39c177a86bSGarrett Wollman * 40c177a86bSGarrett Wollman * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 41c177a86bSGarrett Wollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42c177a86bSGarrett Wollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43c177a86bSGarrett Wollman * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 44c177a86bSGarrett Wollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 45c177a86bSGarrett Wollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 46c177a86bSGarrett Wollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47c177a86bSGarrett Wollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 48c177a86bSGarrett Wollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 49c177a86bSGarrett Wollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 50c177a86bSGarrett Wollman * SUCH DAMAGE. 51c177a86bSGarrett Wollman * 52c177a86bSGarrett Wollman * The licence and distribution terms for any publically available version or 53c177a86bSGarrett Wollman * derivative of this code cannot be changed. i.e. this code cannot simply be 54c177a86bSGarrett Wollman * copied and put under another distribution licence 55c177a86bSGarrett Wollman * [including the GNU Public Licence.] 56c177a86bSGarrett Wollman * 577f3dea24SPeter Wemm * $FreeBSD$ 58c177a86bSGarrett Wollman */ 59c177a86bSGarrett Wollman 60c177a86bSGarrett Wollman #ifndef _SHA_H_ 61c177a86bSGarrett Wollman #define _SHA_H_ 1 62c177a86bSGarrett Wollman 63c177a86bSGarrett Wollman #include <sys/cdefs.h> 64c177a86bSGarrett Wollman #include <sys/types.h> /* XXX switch to machine/ansi.h and __ types */ 65c177a86bSGarrett Wollman 66c177a86bSGarrett Wollman #define SHA_CBLOCK 64 67c177a86bSGarrett Wollman #define SHA_LBLOCK 16 68c177a86bSGarrett Wollman #define SHA_BLOCK 16 69c177a86bSGarrett Wollman #define SHA_LAST_BLOCK 56 70c177a86bSGarrett Wollman #define SHA_LENGTH_BLOCK 8 71c177a86bSGarrett Wollman #define SHA_DIGEST_LENGTH 20 72c177a86bSGarrett Wollman 73c177a86bSGarrett Wollman typedef struct SHAstate_st { 74c177a86bSGarrett Wollman u_int32_t h0, h1, h2, h3, h4; 75c177a86bSGarrett Wollman u_int32_t Nl, Nh; 76c177a86bSGarrett Wollman u_int32_t data[SHA_LBLOCK]; 77c177a86bSGarrett Wollman int num; 78c177a86bSGarrett Wollman } SHA_CTX; 79c177a86bSGarrett Wollman #define SHA1_CTX SHA_CTX 80c177a86bSGarrett Wollman 81c177a86bSGarrett Wollman __BEGIN_DECLS 829d8b6686SThomas Quinot 839d8b6686SThomas Quinot /* Ensure libmd symbols do not clash with libcrypto */ 849d8b6686SThomas Quinot 8555b13095SThomas Quinot #ifndef SHA_Init 869d8b6686SThomas Quinot #define SHA_Init _libmd_SHA_Init 8755b13095SThomas Quinot #endif 8855b13095SThomas Quinot #ifndef SHA_Update 899d8b6686SThomas Quinot #define SHA_Update _libmd_SHA_Update 9055b13095SThomas Quinot #endif 9155b13095SThomas Quinot #ifndef SHA_Final 929d8b6686SThomas Quinot #define SHA_Final _libmd_SHA_Final 9355b13095SThomas Quinot #endif 9455b13095SThomas Quinot #ifndef SHA_End 959d8b6686SThomas Quinot #define SHA_End _libmd_SHA_End 9655b13095SThomas Quinot #endif 97*de13c242SEd Maste #ifndef SHA_Fd 98*de13c242SEd Maste #define SHA_Fd _libmd_SHA_Fd 99*de13c242SEd Maste #endif 100*de13c242SEd Maste #ifndef SHA_FdChunk 101*de13c242SEd Maste #define SHA_FdChunk _libmd_SHA_FdChunk 102*de13c242SEd Maste #endif 10355b13095SThomas Quinot #ifndef SHA_File 1049d8b6686SThomas Quinot #define SHA_File _libmd_SHA_File 10555b13095SThomas Quinot #endif 10655b13095SThomas Quinot #ifndef SHA_FileChunk 1079d8b6686SThomas Quinot #define SHA_FileChunk _libmd_SHA_FileChunk 10855b13095SThomas Quinot #endif 10955b13095SThomas Quinot #ifndef SHA_Data 1109d8b6686SThomas Quinot #define SHA_Data _libmd_SHA_Data 11155b13095SThomas Quinot #endif 1129d8b6686SThomas Quinot 11355b13095SThomas Quinot #ifndef SHA_Transform 1149d8b6686SThomas Quinot #define SHA_Transform _libmd_SHA_Transform 11555b13095SThomas Quinot #endif 11655b13095SThomas Quinot #ifndef SHA_version 1179d8b6686SThomas Quinot #define SHA_version _libmd_SHA_version 11855b13095SThomas Quinot #endif 11955b13095SThomas Quinot #ifndef sha_block 1209d8b6686SThomas Quinot #define sha_block _libmd_sha_block 12155b13095SThomas Quinot #endif 1229d8b6686SThomas Quinot 12355b13095SThomas Quinot #ifndef SHA1_Init 1249d8b6686SThomas Quinot #define SHA1_Init _libmd_SHA1_Init 12555b13095SThomas Quinot #endif 12655b13095SThomas Quinot #ifndef SHA1_Update 1279d8b6686SThomas Quinot #define SHA1_Update _libmd_SHA1_Update 12855b13095SThomas Quinot #endif 12955b13095SThomas Quinot #ifndef SHA1_Final 1309d8b6686SThomas Quinot #define SHA1_Final _libmd_SHA1_Final 13155b13095SThomas Quinot #endif 13255b13095SThomas Quinot #ifndef SHA1_End 1339d8b6686SThomas Quinot #define SHA1_End _libmd_SHA1_End 13455b13095SThomas Quinot #endif 135*de13c242SEd Maste #ifndef SHA1_Fd 136*de13c242SEd Maste #define SHA1_Fd _libmd_SHA1_Fd 137*de13c242SEd Maste #endif 138*de13c242SEd Maste #ifndef SHA1_FdChunk 139*de13c242SEd Maste #define SHA1_FdChunk _libmd_SHA1_FdChunk 140*de13c242SEd Maste #endif 14155b13095SThomas Quinot #ifndef SHA1_File 1429d8b6686SThomas Quinot #define SHA1_File _libmd_SHA1_File 14355b13095SThomas Quinot #endif 14455b13095SThomas Quinot #ifndef SHA1_FileChunk 1459d8b6686SThomas Quinot #define SHA1_FileChunk _libmd_SHA1_FileChunk 14655b13095SThomas Quinot #endif 14755b13095SThomas Quinot #ifndef SHA1_Data 1489d8b6686SThomas Quinot #define SHA1_Data _libmd_SHA1_Data 14955b13095SThomas Quinot #endif 1509d8b6686SThomas Quinot 15155b13095SThomas Quinot #ifndef SHA1_Transform 1529d8b6686SThomas Quinot #define SHA1_Transform _libmd_SHA1_Transform 15355b13095SThomas Quinot #endif 15455b13095SThomas Quinot #ifndef SHA1_version 1559d8b6686SThomas Quinot #define SHA1_version _libmd_SHA1_version 15655b13095SThomas Quinot #endif 15755b13095SThomas Quinot #ifndef sha1_block 1589d8b6686SThomas Quinot #define sha1_block _libmd_sha1_block 15955b13095SThomas Quinot #endif 1609d8b6686SThomas Quinot 161c177a86bSGarrett Wollman void SHA_Init(SHA_CTX *c); 16225a14196SPoul-Henning Kamp void SHA_Update(SHA_CTX *c, const void *data, size_t len); 163c177a86bSGarrett Wollman void SHA_Final(unsigned char *md, SHA_CTX *c); 164c177a86bSGarrett Wollman char *SHA_End(SHA_CTX *, char *); 165*de13c242SEd Maste char *SHA_Fd(int, char *); 166*de13c242SEd Maste char *SHA_FdChunk(int, char *, off_t, off_t); 167c177a86bSGarrett Wollman char *SHA_File(const char *, char *); 1688a24546cSPoul-Henning Kamp char *SHA_FileChunk(const char *, char *, off_t, off_t); 16925a14196SPoul-Henning Kamp char *SHA_Data(const void *, unsigned int, char *); 1709d8b6686SThomas Quinot 171c177a86bSGarrett Wollman void SHA1_Init(SHA_CTX *c); 17225a14196SPoul-Henning Kamp void SHA1_Update(SHA_CTX *c, const void *data, size_t len); 173c177a86bSGarrett Wollman void SHA1_Final(unsigned char *md, SHA_CTX *c); 174c177a86bSGarrett Wollman char *SHA1_End(SHA_CTX *, char *); 175*de13c242SEd Maste char *SHA1_Fd(int, char *); 176*de13c242SEd Maste char *SHA1_FdChunk(int, char *, off_t, off_t); 177c177a86bSGarrett Wollman char *SHA1_File(const char *, char *); 1788a24546cSPoul-Henning Kamp char *SHA1_FileChunk(const char *, char *, off_t, off_t); 17925a14196SPoul-Henning Kamp char *SHA1_Data(const void *, unsigned int, char *); 180c177a86bSGarrett Wollman __END_DECLS 181c177a86bSGarrett Wollman 182c177a86bSGarrett Wollman #endif /* !_SHA_H_ */ 183