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/11/lib/libmd/sha.h 310372 2016-12-21 18:42:04Z emaste $ 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 82282726Sthomas 83282726Sthomas/* Ensure libmd symbols do not clash with libcrypto */ 84282726Sthomas 85282736Sthomas#ifndef SHA_Init 86282726Sthomas#define SHA_Init _libmd_SHA_Init 87282736Sthomas#endif 88282736Sthomas#ifndef SHA_Update 89282726Sthomas#define SHA_Update _libmd_SHA_Update 90282736Sthomas#endif 91282736Sthomas#ifndef SHA_Final 92282726Sthomas#define SHA_Final _libmd_SHA_Final 93282736Sthomas#endif 94282736Sthomas#ifndef SHA_End 95282726Sthomas#define SHA_End _libmd_SHA_End 96282736Sthomas#endif 97310372Semaste#ifndef SHA_Fd 98310372Semaste#define SHA_Fd _libmd_SHA_Fd 99310372Semaste#endif 100310372Semaste#ifndef SHA_FdChunk 101310372Semaste#define SHA_FdChunk _libmd_SHA_FdChunk 102310372Semaste#endif 103282736Sthomas#ifndef SHA_File 104282726Sthomas#define SHA_File _libmd_SHA_File 105282736Sthomas#endif 106282736Sthomas#ifndef SHA_FileChunk 107282726Sthomas#define SHA_FileChunk _libmd_SHA_FileChunk 108282736Sthomas#endif 109282736Sthomas#ifndef SHA_Data 110282726Sthomas#define SHA_Data _libmd_SHA_Data 111282736Sthomas#endif 112282726Sthomas 113282736Sthomas#ifndef SHA_Transform 114282726Sthomas#define SHA_Transform _libmd_SHA_Transform 115282736Sthomas#endif 116282736Sthomas#ifndef SHA_version 117282726Sthomas#define SHA_version _libmd_SHA_version 118282736Sthomas#endif 119282736Sthomas#ifndef sha_block 120282726Sthomas#define sha_block _libmd_sha_block 121282736Sthomas#endif 122282726Sthomas 123282736Sthomas#ifndef SHA1_Init 124282726Sthomas#define SHA1_Init _libmd_SHA1_Init 125282736Sthomas#endif 126282736Sthomas#ifndef SHA1_Update 127282726Sthomas#define SHA1_Update _libmd_SHA1_Update 128282736Sthomas#endif 129282736Sthomas#ifndef SHA1_Final 130282726Sthomas#define SHA1_Final _libmd_SHA1_Final 131282736Sthomas#endif 132282736Sthomas#ifndef SHA1_End 133282726Sthomas#define SHA1_End _libmd_SHA1_End 134282736Sthomas#endif 135310372Semaste#ifndef SHA1_Fd 136310372Semaste#define SHA1_Fd _libmd_SHA1_Fd 137310372Semaste#endif 138310372Semaste#ifndef SHA1_FdChunk 139310372Semaste#define SHA1_FdChunk _libmd_SHA1_FdChunk 140310372Semaste#endif 141282736Sthomas#ifndef SHA1_File 142282726Sthomas#define SHA1_File _libmd_SHA1_File 143282736Sthomas#endif 144282736Sthomas#ifndef SHA1_FileChunk 145282726Sthomas#define SHA1_FileChunk _libmd_SHA1_FileChunk 146282736Sthomas#endif 147282736Sthomas#ifndef SHA1_Data 148282726Sthomas#define SHA1_Data _libmd_SHA1_Data 149282736Sthomas#endif 150282726Sthomas 151282736Sthomas#ifndef SHA1_Transform 152282726Sthomas#define SHA1_Transform _libmd_SHA1_Transform 153282736Sthomas#endif 154282736Sthomas#ifndef SHA1_version 155282726Sthomas#define SHA1_version _libmd_SHA1_version 156282736Sthomas#endif 157282736Sthomas#ifndef sha1_block 158282726Sthomas#define sha1_block _libmd_sha1_block 159282736Sthomas#endif 160282726Sthomas 16144290Swollmanvoid SHA_Init(SHA_CTX *c); 162154479Sphkvoid SHA_Update(SHA_CTX *c, const void *data, size_t len); 16344290Swollmanvoid SHA_Final(unsigned char *md, SHA_CTX *c); 16444290Swollmanchar *SHA_End(SHA_CTX *, char *); 165310372Semastechar *SHA_Fd(int, char *); 166310372Semastechar *SHA_FdChunk(int, char *, off_t, off_t); 16744290Swollmanchar *SHA_File(const char *, char *); 16874385Sphkchar *SHA_FileChunk(const char *, char *, off_t, off_t); 169154479Sphkchar *SHA_Data(const void *, unsigned int, char *); 170282726Sthomas 17144290Swollmanvoid SHA1_Init(SHA_CTX *c); 172154479Sphkvoid SHA1_Update(SHA_CTX *c, const void *data, size_t len); 17344290Swollmanvoid SHA1_Final(unsigned char *md, SHA_CTX *c); 17444290Swollmanchar *SHA1_End(SHA_CTX *, char *); 175310372Semastechar *SHA1_Fd(int, char *); 176310372Semastechar *SHA1_FdChunk(int, char *, off_t, off_t); 17744290Swollmanchar *SHA1_File(const char *, char *); 17874385Sphkchar *SHA1_FileChunk(const char *, char *, off_t, off_t); 179154479Sphkchar *SHA1_Data(const void *, unsigned int, char *); 18044290Swollman__END_DECLS 18144290Swollman 18244290Swollman#endif /* !_SHA_H_ */ 183