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)" 343e5a11d5SGordon Bergling * The word 'cryptographic' can be left out if the routines 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 */ 57c177a86bSGarrett Wollman 58c177a86bSGarrett Wollman #ifndef _SHA_H_ 59c177a86bSGarrett Wollman #define _SHA_H_ 1 60c177a86bSGarrett Wollman 61c177a86bSGarrett Wollman #include <sys/types.h> /* XXX switch to machine/ansi.h and __ types */ 62c177a86bSGarrett Wollman 63c177a86bSGarrett Wollman #define SHA_CBLOCK 64 64c177a86bSGarrett Wollman #define SHA_LBLOCK 16 65c177a86bSGarrett Wollman #define SHA_BLOCK 16 66c177a86bSGarrett Wollman #define SHA_LAST_BLOCK 56 67c177a86bSGarrett Wollman #define SHA_LENGTH_BLOCK 8 68c177a86bSGarrett Wollman #define SHA_DIGEST_LENGTH 20 69c177a86bSGarrett Wollman 70c177a86bSGarrett Wollman typedef struct SHAstate_st { 71c177a86bSGarrett Wollman u_int32_t h0, h1, h2, h3, h4; 72c177a86bSGarrett Wollman u_int32_t Nl, Nh; 73c177a86bSGarrett Wollman u_int32_t data[SHA_LBLOCK]; 74c177a86bSGarrett Wollman int num; 75c177a86bSGarrett Wollman } SHA_CTX; 76c177a86bSGarrett Wollman #define SHA1_CTX SHA_CTX 77c177a86bSGarrett Wollman 78c177a86bSGarrett Wollman __BEGIN_DECLS 799d8b6686SThomas Quinot 809d8b6686SThomas Quinot /* Ensure libmd symbols do not clash with libcrypto */ 819d8b6686SThomas Quinot 8255b13095SThomas Quinot #ifndef SHA_Init 839d8b6686SThomas Quinot #define SHA_Init _libmd_SHA_Init 8455b13095SThomas Quinot #endif 8555b13095SThomas Quinot #ifndef SHA_Update 869d8b6686SThomas Quinot #define SHA_Update _libmd_SHA_Update 8755b13095SThomas Quinot #endif 8855b13095SThomas Quinot #ifndef SHA_Final 899d8b6686SThomas Quinot #define SHA_Final _libmd_SHA_Final 9055b13095SThomas Quinot #endif 9155b13095SThomas Quinot #ifndef SHA_End 929d8b6686SThomas Quinot #define SHA_End _libmd_SHA_End 9355b13095SThomas Quinot #endif 94de13c242SEd Maste #ifndef SHA_Fd 95de13c242SEd Maste #define SHA_Fd _libmd_SHA_Fd 96de13c242SEd Maste #endif 97de13c242SEd Maste #ifndef SHA_FdChunk 98de13c242SEd Maste #define SHA_FdChunk _libmd_SHA_FdChunk 99de13c242SEd Maste #endif 10055b13095SThomas Quinot #ifndef SHA_File 1019d8b6686SThomas Quinot #define SHA_File _libmd_SHA_File 10255b13095SThomas Quinot #endif 10355b13095SThomas Quinot #ifndef SHA_FileChunk 1049d8b6686SThomas Quinot #define SHA_FileChunk _libmd_SHA_FileChunk 10555b13095SThomas Quinot #endif 10655b13095SThomas Quinot #ifndef SHA_Data 1079d8b6686SThomas Quinot #define SHA_Data _libmd_SHA_Data 10855b13095SThomas Quinot #endif 1099d8b6686SThomas Quinot 11055b13095SThomas Quinot #ifndef sha_block 1119d8b6686SThomas Quinot #define sha_block _libmd_sha_block 11255b13095SThomas Quinot #endif 1139d8b6686SThomas Quinot 11455b13095SThomas Quinot #ifndef SHA1_Init 1159d8b6686SThomas Quinot #define SHA1_Init _libmd_SHA1_Init 11655b13095SThomas Quinot #endif 11755b13095SThomas Quinot #ifndef SHA1_Update 1189d8b6686SThomas Quinot #define SHA1_Update _libmd_SHA1_Update 11955b13095SThomas Quinot #endif 12055b13095SThomas Quinot #ifndef SHA1_Final 1219d8b6686SThomas Quinot #define SHA1_Final _libmd_SHA1_Final 12255b13095SThomas Quinot #endif 12355b13095SThomas Quinot #ifndef SHA1_End 1249d8b6686SThomas Quinot #define SHA1_End _libmd_SHA1_End 12555b13095SThomas Quinot #endif 126de13c242SEd Maste #ifndef SHA1_Fd 127de13c242SEd Maste #define SHA1_Fd _libmd_SHA1_Fd 128de13c242SEd Maste #endif 129de13c242SEd Maste #ifndef SHA1_FdChunk 130de13c242SEd Maste #define SHA1_FdChunk _libmd_SHA1_FdChunk 131de13c242SEd Maste #endif 13255b13095SThomas Quinot #ifndef SHA1_File 1339d8b6686SThomas Quinot #define SHA1_File _libmd_SHA1_File 13455b13095SThomas Quinot #endif 13555b13095SThomas Quinot #ifndef SHA1_FileChunk 1369d8b6686SThomas Quinot #define SHA1_FileChunk _libmd_SHA1_FileChunk 13755b13095SThomas Quinot #endif 13855b13095SThomas Quinot #ifndef SHA1_Data 1399d8b6686SThomas Quinot #define SHA1_Data _libmd_SHA1_Data 14055b13095SThomas Quinot #endif 141*c02bc0aaSKyle Evans #ifndef SHA1_Transform 142*c02bc0aaSKyle Evans #define SHA1_Transform _libmd_SHA1_Transform 143*c02bc0aaSKyle Evans #endif 1449d8b6686SThomas Quinot 14555b13095SThomas Quinot #ifndef sha1_block 1469d8b6686SThomas Quinot #define sha1_block _libmd_sha1_block 14755b13095SThomas Quinot #endif 1489d8b6686SThomas Quinot 149c177a86bSGarrett Wollman void SHA_Init(SHA_CTX *c); 15025a14196SPoul-Henning Kamp void SHA_Update(SHA_CTX *c, const void *data, size_t len); 151c177a86bSGarrett Wollman void SHA_Final(unsigned char *md, SHA_CTX *c); 152c177a86bSGarrett Wollman char *SHA_End(SHA_CTX *, char *); 153de13c242SEd Maste char *SHA_Fd(int, char *); 154de13c242SEd Maste char *SHA_FdChunk(int, char *, off_t, off_t); 155c177a86bSGarrett Wollman char *SHA_File(const char *, char *); 1568a24546cSPoul-Henning Kamp char *SHA_FileChunk(const char *, char *, off_t, off_t); 15725a14196SPoul-Henning Kamp char *SHA_Data(const void *, unsigned int, char *); 1589d8b6686SThomas Quinot 159c177a86bSGarrett Wollman void SHA1_Init(SHA_CTX *c); 16025a14196SPoul-Henning Kamp void SHA1_Update(SHA_CTX *c, const void *data, size_t len); 161c177a86bSGarrett Wollman void SHA1_Final(unsigned char *md, SHA_CTX *c); 162c177a86bSGarrett Wollman char *SHA1_End(SHA_CTX *, char *); 163de13c242SEd Maste char *SHA1_Fd(int, char *); 164de13c242SEd Maste char *SHA1_FdChunk(int, char *, off_t, off_t); 165c177a86bSGarrett Wollman char *SHA1_File(const char *, char *); 1668a24546cSPoul-Henning Kamp char *SHA1_FileChunk(const char *, char *, off_t, off_t); 16725a14196SPoul-Henning Kamp char *SHA1_Data(const void *, unsigned int, char *); 168c177a86bSGarrett Wollman __END_DECLS 169c177a86bSGarrett Wollman 170c177a86bSGarrett Wollman #endif /* !_SHA_H_ */ 171