Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / n8 / nspvar.h
blob640de75e470ac38331edf10010fc2a2e0a6afd7b
1 /*-
2 * Copyright (c) 2008 The NetBSD Foundation, Inc.
3 * All rights reserved.
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Coyote Point Systems, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
30 #ifndef _NSPVAR_H_
31 #define _NSPVAR_H_
33 #define NSP_MAX_KEYLEN 512
34 #define NSP_MAX_INSTANCES 1
37 * crypto key operation request
38 * holds the input and output parameter memory and
39 * keying information for the asymmetric operations
41 typedef struct {
42 uint32_t magic;
43 struct cryptkop *krp;
44 N8_Status_t error;
45 N8_SizedBuffer_t parm[CRK_MAXPARAM];
46 N8_Buffer_t value[CRK_MAXPARAM][NSP_MAX_KEYLEN]; /* BN values, 4KB */
47 union {
48 struct {
49 N8_DSAKeyObject_t key;
50 N8_DSAKeyMaterial_t keymaterial;
51 N8_Boolean_t verifyok; /* DSAVerify result */
52 } dsa;
53 struct {
54 N8_RSAKeyObject_t key;
55 N8_RSAKeyMaterial_t keymaterial;
56 } rsa;
57 struct {
58 N8_DH_KeyObject_t key;
59 N8_DH_KeyMaterial_t keymaterial;
60 } dh;
61 } op;
62 } n8_kreq_t;
66 * Parameter checks for crypto key operations
67 * indexed by crypyto key id (CRK_*)
69 #define BN_ARG(n) (1<<(n))
71 /* inputs: dgst dsa->p dsa->q dsa->g dsa->priv_key */
72 #define NSP_DSA_SIGN_DIGEST 0
73 #define NSP_DSA_SIGN_P 1
74 #define NSP_DSA_SIGN_Q 2
75 #define NSP_DSA_SIGN_G 3
76 #define NSP_DSA_SIGN_X 4 /* Private Key */
77 #define NSP_DSA_SIGN_RVALUE 5 /* Result */
78 #define NSP_DSA_SIGN_SVALUE 6 /* Result */
79 #define NSP_DSA_SIGN_BIGNUMS \
80 (BN_ARG(NSP_DSA_SIGN_P) | \
81 BN_ARG(NSP_DSA_SIGN_Q) | \
82 BN_ARG(NSP_DSA_SIGN_G) | \
83 BN_ARG(NSP_DSA_SIGN_X) | \
84 BN_ARG(NSP_DSA_SIGN_RVALUE) | \
85 BN_ARG(NSP_DSA_SIGN_SVALUE))
87 /* inputs: dgst dsa->p dsa->q dsa->g dsa->pub_key sig->r sig->s */
88 #define NSP_DSA_VERIFY_DIGEST 0
89 #define NSP_DSA_VERIFY_P 1
90 #define NSP_DSA_VERIFY_Q 2
91 #define NSP_DSA_VERIFY_G 3
92 #define NSP_DSA_VERIFY_Y 4 /* Public Key */
93 #define NSP_DSA_VERIFY_RVALUE 5
94 #define NSP_DSA_VERIFY_SVALUE 6
95 #define NSP_DSA_VERIFY_BIGNUMS \
96 (BN_ARG(NSP_DSA_VERIFY_P) | \
97 BN_ARG(NSP_DSA_VERIFY_Q) | \
98 BN_ARG(NSP_DSA_VERIFY_G) | \
99 BN_ARG(NSP_DSA_VERIFY_P) | \
100 BN_ARG(NSP_DSA_VERIFY_Y) | \
101 BN_ARG(NSP_DSA_VERIFY_RVALUE) | \
102 BN_ARG(NSP_DSA_VERIFY_SVALUE))
104 /* inputs: dh->priv_key (x) pub_key (g^x) dh->p (prime) key output g^x */
105 #define NSP_DH_COMPUTE_KEY_PRIV 0 /* priv_key */
106 #define NSP_DH_COMPUTE_KEY_PUB 1 /* pub_key (g^b % p) */
107 #define NSP_DH_COMPUTE_KEY_P 2 /* Prime (modulus) */
108 #define NSP_DH_COMPUTE_KEY_K 3 /* Result: key = B^g % p */
109 #define NSP_DH_COMPUTE_KEY_BIGNUMS \
110 (BN_ARG(NSP_DH_COMPUTE_KEY_PRIV) | \
111 BN_ARG(NSP_DH_COMPUTE_KEY_PUB) | \
112 BN_ARG(NSP_DH_COMPUTE_KEY_P))
114 /* R0 = (A^B) % M */
115 #define NSP_MOD_EXP_A 0
116 #define NSP_MOD_EXP_B 1
117 #define NSP_MOD_EXP_M 2 /* modulus */
118 #define NSP_MOD_EXP_R0 3 /* Result */
119 #define NSP_MOD_EXP_BIGNUMS \
120 (BN_ARG(NSP_MOD_EXP_A) | \
121 BN_ARG(NSP_MOD_EXP_B) | \
122 BN_ARG(NSP_MOD_EXP_M) | \
123 BN_ARG(NSP_MOD_EXP_R0))
126 /* R0 = (A+B) % M */
127 #define NSP_MOD_ADD_A 0
128 #define NSP_MOD_ADD_B 1
129 #define NSP_MOD_ADD_M 2
130 #define NSP_MOD_ADD_R0 3
131 #define NSP_MOD_ADD_BIGNUMS \
132 (BN_ARG(NSP_MOD_ADD_A) | \
133 BN_ARG(NSP_MOD_ADD_B) | \
134 BN_ARG(NSP_MOD_ADD_M) | \
135 BN_ARG(NSP_MOD_ADD_R0))
137 /* R0 = -A % M */
138 #define NSP_MOD_ADDINV_A 0
139 #define NSP_MOD_ADDINV_M 1
140 #define NSP_MOD_ADDINV_R0 2
141 #define NSP_MOD_ADDINV_BIGNUMS \
142 (BN_ARG(NSP_MOD_ADDINV_A) | \
143 BN_ARG(NSP_MOD_ADDINV_M) | \
144 BN_ARG(NSP_MOD_ADDINV_R0))
146 /* R0 = (A-B) % M */
147 #define NSP_MOD_SUB_A 0
148 #define NSP_MOD_SUB_B 1
149 #define NSP_MOD_SUB_M 2
150 #define NSP_MOD_SUB_R0 3
151 #define NSP_MOD_SUB_BIGNUMS \
152 (BN_ARG(NSP_MOD_SUB_A) | \
153 BN_ARG(NSP_MOD_SUB_B) | \
154 BN_ARG(NSP_MOD_SUB_M) | \
155 BN_ARG(NSP_MOD_SUB_R0))
157 /* R0 = (A*B) % M */
158 #define NSP_MOD_MULT_A 0
159 #define NSP_MOD_MULT_B 1
160 #define NSP_MOD_MULT_M 2
161 #define NSP_MOD_MULT_R0 3
162 #define NSP_MOD_MULT_BIGNUMS \
163 (BN_ARG(NSP_MOD_MULT_A) | \
164 BN_ARG(NSP_MOD_MULT_B) | \
165 BN_ARG(NSP_MOD_MULT_M) | \
166 BN_ARG(NSP_MOD_MULT_R0))
168 /* R0 = (A^-1) % M */
169 #define NSP_MOD_MULTINV_A 0
170 #define NSP_MOD_MULTINV_M 1
171 #define NSP_MOD_MULTINV_R0 2
172 #define NSP_MOD_MULTINV_BIGNUMS \
173 (BN_ARG(NSP_MOD_MULTINV_A) | \
174 BN_ARG(NSP_MOD_MULTINV_M) | \
175 BN_ARG(NSP_MOD_MULTINV_R0))
177 /* R0 = A % M */
178 #define NSP_MODULUS_A 0
179 #define NSP_MODULUS_M 1
180 #define NSP_MODULUS_R0 2
181 #define NSP_MODULUS_BIGNUMS \
182 (BN_ARG(NSP_MODULUS_A) | \
183 BN_ARG(NSP_MODULUS_M) | \
184 BN_ARG(NSP_MODULUS_R0))
186 /* inputs: rsa->p rsa->q I rsa->dmp1 rsa->dmq1 rsa->iqmp */
187 #define NSP_MOD_EXP_CRT_P 0
188 #define NSP_MOD_EXP_CRT_Q 1
189 #define NSP_MOD_EXP_CRT_I 2
190 #define NSP_MOD_EXP_CRT_DP 3
191 #define NSP_MOD_EXP_CRT_DQ 4
192 #define NSP_MOD_EXP_CRT_QINV 5
193 #define NSP_MOD_EXP_CRT_R0 6 /* Result */
194 #define NSP_MOD_EXP_CRT_BIGNUMS \
195 (BN_ARG(NSP_MOD_EXP_CRT_P) | \
196 BN_ARG(NSP_MOD_EXP_CRT_Q) | \
197 BN_ARG(NSP_MOD_EXP_CRT_I) | \
198 BN_ARG(NSP_MOD_EXP_CRT_DP) | \
199 BN_ARG(NSP_MOD_EXP_CRT_DQ) | \
200 BN_ARG(NSP_MOD_EXP_CRT_QINV) | \
201 BN_ARG(NSP_MOD_EXP_CRT_R0))
203 #endif /* _NSPVAR_H_ */