Adjust for symbol name changes.
[dragonfly.git] / sys / netinet / sctp_sha1.h
1 /*      $KAME: sctp_sha1.h,v 1.4 2002/10/09 18:01:22 itojun Exp $       */
2 /*      $DragonFly: src/sys/netinet/sctp_sha1.h,v 1.2 2006/05/20 02:42:12 dillon Exp $  */
3
4 #ifndef _NETINET_SCTP_SHA1_H_
5 #define _NETINET_SCTP_SHA1_H_
6
7 /*
8  * Copyright (c) 2001, 2002, 2004 Cisco Systems, Inc.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *      This product includes software developed by Cisco Systems, Inc.
22  * 4. Neither the name of the project nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  */
38 #include <sys/types.h>
39
40 struct sha1_context {
41         unsigned int A;
42         unsigned int B;
43         unsigned int C;
44         unsigned int D;
45         unsigned int E;
46         unsigned int H0;
47         unsigned int H1;
48         unsigned int H2;
49         unsigned int H3;
50         unsigned int H4;
51         unsigned int words[80];
52         unsigned int TEMP;
53         /* block I am collecting to process */
54         char sha_block[64];
55         /* collected so far */
56         int how_many_in_block;
57         unsigned int running_total;
58 };
59
60
61 #define F1(B,C,D) (((B & C) | ((~B) & D)))      /*  0  <= t <= 19 */
62 #define F2(B,C,D) (B ^ C ^ D)                   /*  20 <= t <= 39 */
63 #define F3(B,C,D) ((B & C) | (B & D) | (C & D)) /*  40 <= t <= 59 */
64 #define F4(B,C,D) (B ^ C ^ D)                   /* 600 <= t <= 79 */
65
66 /* circular shift */
67 #define CSHIFT(A,B) ((B << A) | (B >> (32-A)))
68
69 #define K1 0x5a827999       /* 0  <= t <= 19 */
70 #define K2 0x6ed9eba1       /* 20 <= t <= 39 */
71 #define K3 0x8f1bbcdc       /* 40 <= t <= 59 */
72 #define K4 0xca62c1d6       /* 60 <= t <= 79 */
73
74 #define H0INIT 0x67452301
75 #define H1INIT 0xefcdab89
76 #define H2INIT 0x98badcfe
77 #define H3INIT 0x10325476
78 #define H4INIT 0xc3d2e1f0
79
80 #if defined(_KERNEL) || (defined(__APPLE__) && defined(KERNEL))
81
82 void SHA1_Init(struct sha1_context *);
83 void SHA1_Process(struct sha1_context *, unsigned char *, int);
84 void SHA1_Final(struct sha1_context *, unsigned char *);
85
86 #endif /* _KERNEL */
87 #endif