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