Header And Logo

PostgreSQL
| The world's most advanced open source database.

sha1.h

Go to the documentation of this file.
00001 /*  contrib/pgcrypto/sha1.h */
00002 /*     $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $    */
00003 
00004 /*
00005  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the project nor the names of its contributors
00017  *    may be used to endorse or promote products derived from this software
00018  *    without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
00024  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00025  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00026  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00027  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00029  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  */
00032 /*
00033  * FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
00034  * based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm
00035  * implemented by Jun-ichiro itojun Itoh <[email protected]>
00036  */
00037 
00038 #ifndef _NETINET6_SHA1_H_
00039 #define _NETINET6_SHA1_H_
00040 
00041 struct sha1_ctxt
00042 {
00043     union
00044     {
00045         uint8       b8[20];
00046         uint32      b32[5];
00047     }           h;
00048     union
00049     {
00050         uint8       b8[8];
00051         uint64      b64[1];
00052     }           c;
00053     union
00054     {
00055         uint8       b8[64];
00056         uint32      b32[16];
00057     }           m;
00058     uint8       count;
00059 };
00060 
00061 extern void sha1_init(struct sha1_ctxt *);
00062 extern void sha1_pad(struct sha1_ctxt *);
00063 extern void sha1_loop(struct sha1_ctxt *, const uint8 *, size_t);
00064 extern void sha1_result(struct sha1_ctxt *, uint8 *);
00065 
00066 /* compatibilty with other SHA1 source codes */
00067 typedef struct sha1_ctxt SHA1_CTX;
00068 
00069 #define SHA1Init(x)     sha1_init((x))
00070 #define SHA1Update(x, y, z) sha1_loop((x), (y), (z))
00071 #define SHA1Final(x, y)     sha1_result((y), (x))
00072 
00073 #define SHA1_RESULTLEN  (160/8)
00074 
00075 #endif   /* _NETINET6_SHA1_H_ */