Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / n8 / common / api / n8_hash.h
blob1f38115fb1fa10809c37401ecc235345edb493e9
1 /*-
2 * Copyright (C) 2001-2003 by NBMK Encryption Technologies.
3 * All rights reserved.
5 * NBMK Encryption Technologies provides no support of any kind for
6 * this software. Questions or concerns about it may be addressed to
7 * the members of the relevant open-source community at
8 * <tech-crypto@netbsd.org>.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided
20 * with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /*****************************************************************************
36 * @(#) n8_hash.h 1.45@(#)
37 *****************************************************************************/
39 /*****************************************************************************
40 * n8_hash.h
42 * Implementation of all public functions dealing with management of
43 * hashs.
45 * References:
46 * MD5: RFC1321 "The MD5 Message-Digest Algorithm", R. Rivest, 4/92
47 * SHA-1: FIPS Pub 180-1,"Secure Hash Standard", US Dept. of Commerce,
48 * 4/17/95
50 *****************************************************************************
51 * Revision history:
52 * 05/19/03 brr Clean up include files.
53 * 04/17/03 brr Moved hash size constants to public include file. (Bug 866)
54 * 01/12/02 bac Added a prototype for the new methods n8_setInitialIVs and
55 * n8_initializeHMAC, corrected the signatures for initMD5 and
56 * initSHA1. All of these are to support removal of blocking
57 * calls (BUG #313).
58 * 11/12/01 hml Added unitID to initSHA1 and initMD5 protos.
59 * 10/24/01 dkm Moved public portion to n8_pub_hash.h.
60 * 10/16/01 spm Added N8_64BYTE_IKE_KEY_LIMIT because IKE APIs currently
61 * only work for 64 byte keys.
62 * 10/12/01 dkm Moved public portion to n8_pub_common.h and n8_pub_hash.h.
63 * 10/11/01 hml Added prototype for N8_HashCompleteMessage and
64 * several defines used in N8_HandshakeHashEnd.
65 * 09/26/01 hml Updated to support multiple chips. The N8_HashInitialize,
66 * N8_TLSKeyMaterialHash and N8_SSLKeyMaterialHash were changed.
67 * 09/08/01 spm IKE APIs: Swapped order of alg and hashInfo args.
68 * 09/07/01 spm Added IKE API Extensions, hash info struct,
69 * N8_MAX_IKE_ITERATIONS
70 * 09/06/01 bac Renumbered enums to start with non-zero (BUG #190).
71 * 06/25/01 bac More changes for QMgr v.1.0.1
72 * 06/25/01 mel Fixed N8_MAX_KEY_LENGTH.
73 * 06/05/01 mel Added prototype for N8_TLSKeyMaterialHash.
74 * 05/18/01 bac Fixed spelling of N8_HMAC_KEY_LENGTH_ZERO.
75 * 05/14/01 dws Changed the byte order of the MD5 initialization values.
76 * 05/10/01 bac Changed N8_MAX_HASH_LENGTH to be 18Kbytes
77 * 04/26/01 bac Changed N8_HashAlgorithm_t to be zero-based and
78 * contiguous for use as an index.
79 * Added N8_HashProtocol_t.
80 * Added N8_HashRole_t.
81 * Specified 'const' where appropriate in prototypes.
82 * Added prototype for N8_HashClone.
83 * 04/24/01 bac Support for MD5 and SHA-1.
84 * 03/29/01 bac Original version.
86 ***************************************************************************/
87 #ifndef N8_HASH_H
88 #define N8_HASH_H
90 #include "n8_pub_common.h"
91 #include "n8_enqueue_common.h"
92 #include "n8_pub_hash.h"
93 #include "n8_pub_packet.h"
94 #include "n8_pub_errors.h"
96 typedef enum
98 N8_IV = 0, /* take the IV from the normal iv area */
99 N8_IPAD = 1, /* take the IV from the ipadHMAC_iv */
100 N8_OPAD = 2 /* take the IV from the opadHMAC_iv */
101 } n8_IVSrc_t;
104 * Initialization values for MD5 per RFC1321 Section 3.3
105 * these values may need to be adjusted vis a vis endianness. These
106 * assume a Big Endian host representation of the MD5 little endian
107 * values.
109 #define MD5_INIT_A 0x01234567
110 #define MD5_INIT_B 0x89abcdef
111 #define MD5_INIT_C 0xfedcba98
112 #define MD5_INIT_D 0x76543210
115 * Initialization values for SHA-1 per "Secure Hash Standard", Section 7.
116 * These values may need to be adjusted vis a vis endianness.
118 #define SHA1_INIT_H0 0x67452301
119 #define SHA1_INIT_H1 0xefcdab89
120 #define SHA1_INIT_H2 0x98badcfe
121 #define SHA1_INIT_H3 0x10325476
122 #define SHA1_INIT_H4 0xc3d2e1f0
124 #define PAD1 0x36
125 #define PAD2 0x5C
126 #define TLS_FINISH_RESULT_LENGTH 12
127 #define NUM_WORDS_TLS_RESULT 4
129 /* TODO: handle the >64 byte key case:
130 * key must be hashed and truncated
131 * to 64 bytes
133 #define N8_64BYTE_IKE_KEY_LIMIT
135 /* prototypes */
136 N8_Status_t n8_setInitialIVs(N8_HashObject_t *hashObj_p,
137 const N8_HashAlgorithm_t alg,
138 const N8_Unit_t unit);
139 N8_Status_t initMD5(N8_HashObject_t *obj_p,
140 const N8_HashAlgorithm_t alg,
141 int unitID);
142 N8_Status_t initSHA1(N8_HashObject_t *obj_p,
143 const N8_HashAlgorithm_t alg,
144 int unitID);
145 N8_Status_t n8_HashPartial_req(N8_HashObject_t *obj_p,
146 const N8_Buffer_t *msg_p,
147 const unsigned int msgLength,
148 const n8_IVSrc_t ivSrc,
149 API_Request_t **req_pp);
150 N8_Status_t n8_HashEnd_req(N8_HashObject_t *obj_p,
151 N8_Buffer_t *result_p,
152 API_Request_t **req_pp);
153 N8_Status_t n8_HashCompleteMessage_req(N8_HashObject_t *obj_p,
154 const N8_Buffer_t *msg_p,
155 const unsigned int msgLength,
156 N8_Buffer_t *result_p,
157 const void *resultHandler,
158 API_Request_t **req_pp);
159 N8_Status_t n8_HashCompleteMessage_req_uio(N8_HashObject_t *obj_p,
160 struct uio *msg_p,
161 const unsigned int msgLength,
162 N8_Buffer_t *result_p,
163 const void *resultHandler,
164 API_Request_t **req_pp);
165 N8_Status_t n8_initializeHMAC_req(N8_Buffer_t *HMACKey,
166 uint32_t HMACKeyLength,
167 N8_HashObject_t *hashObj_p,
168 void *result_p,
169 N8_Buffer_t **ctx_pp,
170 uint32_t *ctxa_p,
171 API_Request_t **req_pp);
172 #endif /* N8_HASH_H */