Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / pci / n8 / common / api / commands / n8_cb_rsa.h
blob6726ff99f54e34993bd3a530b085207db28ca56e
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_cb_rsa.h 1.31@(#)
37 *****************************************************************************/
39 /*****************************************************************************/
40 /** @file n8_cb_rsa.h
41 * @brief RSA Command Blocks
43 * Command Block Generation for RSA
45 *****************************************************************************/
47 /*****************************************************************************
48 * Revision history:
49 * 12/17/03 bac Added cb_rsaPublicDecrypt
50 * 09/10/02 brr Set command complete bit on last command block.
51 * 05/07/02 bac Moved cb_exponentiate to the public interface.
52 * 05/09/02 brr Changed prototype for allocateBNCConstants.
53 * 02/21/01 brr Perform BNC constant initialization once upon startup.
54 * 12/12/01 bac Fixed Bug #371 by adding new define
55 * N8_CB_EXPONENTIATE_WITH_PRECOMPUTES_NUMCMDS.
56 * 10/19/01 bac Added support for SKS operations and RSA Decrypt for non-CRT.
57 * 10/08/01 bac Changes for the case where len(p) != len(q) (BUG #180).
58 * Everywhere a data length was assumed to half the key length,
59 * it has been replaced with the specific dependency on the
60 * length of p or q.
61 * 09/14/01 bac Changed some formal parameters to be 'const'.
62 * 09/05/01 bac Changed formal parameter name in cb_computeCX.
63 * 08/24/01 bac Added *_NUMCMDS macros for all command generators.
64 * 08/21/01 bac Fixes to allow the use of odd key lengths (Bug #174).
65 * 06/25/01 bac Added static allocation of BNC constants, more conversion to
66 * physical addresses.
67 * 06/19/01 bac Corrected signatures for use of physical addresses.
68 * 04/24/01 bac Removed dead prototypes for functions moved to n8_util
69 * 04/11/01 bac Standarization -- mainly _t suffix additions
70 * 04/05/01 bac Added prototype for cb_computeU.
71 * 03/05/01 bac Initial Version
72 ****************************************************************************/
74 #ifndef N8_CB_RSA_H
75 #define N8_CB_RSA_H
77 #include "n8_rsa.h"
78 #include "n8_enqueue_common.h"
80 /* defines indicating the number of command blocks for each computation */
81 #define N8_CB_COMPUTE_U_NUMCMDS 4
82 #define N8_CB_COMPUTE_DX_NUMCMDS 6
83 #define N8_CB_COMPUTE_CX_NUMCMDS 5
84 #define N8_CB_COMPUTE_RMODX_NUMCMDS 3
85 #define N8_CB_EXPONENTIATE_NUMCMDS 10
86 #define N8_CB_EXPONENTIATE_WITH_PRECOMPUTES_NUMCMDS 8
87 #define N8_CB_RSA_PUBLICDECRYPT_NUMCMDS 10
88 #define N8_CB_RSA_ENCRYPT_NUMCMDS \
89 N8_CB_EXPONENTIATE_WITH_PRECOMPUTES_NUMCMDS
91 #define N8_CB_RSA_DECRYPT_NUMCMDS(__KP) cb_RSADecryptOperations((__KP))
93 /* function prototypes */
94 N8_Status_t cb_computeU(API_Request_t *req_p,
95 const uint32_t p,
96 const uint32_t q,
97 uint32_t result_a,
98 const int p_length_bytes,
99 const int q_length_bytes,
100 PK_CMD_BLOCK_t *cmdBuf_p,
101 PK_CMD_BLOCK_t **next_cmdBuf_p);
102 N8_Status_t cb_computeDX(API_Request_t *req_p,
103 const uint32_t X,
104 const uint32_t d,
105 uint32_t result,
106 const int key_length_bytes,
107 const int X_length_bytes,
108 PK_CMD_BLOCK_t *cmdBuf_p,
109 PK_CMD_BLOCK_t **next_cmdBuf_p,
110 const int chip);
111 N8_Status_t cb_computeCX(const API_Request_t *req_p,
112 const uint32_t X,
113 const uint32_t result,
114 const int X_length_bytes,
115 PK_CMD_BLOCK_t *cmdBuf_p,
116 PK_CMD_BLOCK_t **next_cmdBuf_p,
117 const N8_Unit_t unitID,
118 int lastCmdBlock);
119 N8_Status_t cb_computeRmodX(const API_Request_t *req_p,
120 const uint32_t X,
121 const uint32_t result,
122 const unsigned int key_length_bytes,
123 PK_CMD_BLOCK_t *cmdBuf_p,
124 PK_CMD_BLOCK_t **next_cmdBuf_p,
125 int lastCmdBlock);
126 N8_Status_t cb_rsaEncrypt(API_Request_t *req_p,
127 const N8_RSAKeyObject_t *key_p,
128 const uint32_t origMsg_a,
129 const uint32_t result_a,
130 PK_CMD_BLOCK_t *cmdBuf_p,
131 const N8_Unit_t unitID);
132 N8_Status_t cb_rsaDecrypt(API_Request_t *req_p,
133 const N8_RSAKeyObject_t *key,
134 const uint32_t origMsg_a,
135 const uint32_t result_a,
136 PK_CMD_BLOCK_t *cmdBuf_p,
137 const N8_Unit_t unitID);
138 N8_Status_t cb_exponentiate(API_Request_t *req_p,
139 const uint32_t origMsg_a,
140 const uint32_t modulus_a,
141 const unsigned int modulus_length_bytes,
142 const uint32_t exponent_a,
143 const unsigned int exp_length_bytes,
144 const uint32_t result_a,
145 PK_CMD_BLOCK_t *cb_p,
146 const N8_Unit_t unitID);
147 N8_Status_t cb_rsaPublicDecrypt(const API_Request_t *req_p,
148 const uint32_t modulus,
149 const unsigned int modulus_length_bytes,
150 const uint32_t origMsg_a,
151 const uint32_t result_a,
152 const uint32_t exponent_a,
153 const unsigned int exp_length_bytes,
154 PK_CMD_BLOCK_t *cb_p,
155 const N8_Unit_t unitID);
156 unsigned int cb_RSADecryptOperations(const N8_RSAKeyObject_t *key_p);
158 N8_Status_t allocateBNCConstants(unsigned long bcnAddress);
160 #endif /* N8_CB_RSA_H */