source code documentationsha1.hGo to the documentation of this file.00001 /* 00002 * embedded IPsec 00003 * Copyright (c) 2003 Niklaus Schild and Christian Scheurer, HTI Biel/Bienne 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without modification, 00007 * are permitted provided that the following conditions are met: 00008 * 00009 * 1. Redistributions of source code must retain the above copyright notice, 00010 * this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright notice, 00012 * this list of conditions and the following disclaimer in the documentation 00013 * and/or other materials provided with the distribution. 00014 * 3. The name of the author may not be used to endorse or promote products 00015 * derived from this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00018 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00019 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00020 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00021 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00022 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00023 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00024 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00025 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00026 * OF SUCH DAMAGE. 00027 * 00028 */ 00029 00042 #ifndef __SHA_H__ 00043 #define __SHA_H__ 00044 00045 #include "ipsec/types.h" 00046 00047 /* 00048 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 00049 * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then ! 00050 * ! SHA_LONG_LOG2 has to be defined along. ! 00051 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 00052 */ 00053 00054 #define SHA_LONG __u32 00055 00056 #define SHA_LBLOCK 16 00057 #define SHA_DIGEST_LENGTH 20 00058 00059 typedef struct SHAstate_st 00060 { 00061 SHA_LONG h0,h1,h2,h3,h4; 00062 SHA_LONG Nl,Nh; 00063 SHA_LONG data[SHA_LBLOCK]; 00064 int num; 00065 } SHA_CTX; 00066 00067 void SHA1_Init(SHA_CTX *c); 00068 void SHA1_Update(SHA_CTX *c, const void *data, unsigned long len); 00069 void SHA1_Final(unsigned char *md, SHA_CTX *c); 00070 unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md); 00071 void SHA1_Transform(SHA_CTX *c, const unsigned char *data); 00072 00073 void hmac_sha1(unsigned char*, int, unsigned char*, int, unsigned char*); 00074 00075 00076 #endif |