pic32cx_bz_crypto_pkc.h
Go to the documentation of this file.
1 /**
2  * @file pic32cx_bz_crypto_pkc.h
3  * @brief PIC32CX BZ2 public-key hardware accelerator (PUKCC)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _PIC32CX_BZ_CRYPTO_PKC_H
32 #define _PIC32CX_BZ_CRYPTO_PKC_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //Public-key hardware accelerator
38 #ifndef PIC32CX_BZ_CRYPTO_PKC_SUPPORT
39  #define PIC32CX_BZ_CRYPTO_PKC_SUPPORT DISABLED
40 #elif (PIC32CX_BZ_CRYPTO_PKC_SUPPORT != ENABLED && PIC32CX_BZ_CRYPTO_PKC_SUPPORT != DISABLED)
41  #error PIC32CX_BZ_CRYPTO_PKC_SUPPORT parameter is not valid
42 #endif
43 
44 //Crypto memory base address
45 #define PUKCC_CRYPTO_RAM_BASE 0x02011000UL
46 
47 //Far to near pointer conversion
48 #define PUKCC_FAR_TO_NEAR(p) ((uint16_t) ((uint32_t) (p)))
49 
50 //C++ guard
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 
56 /**
57  * @brief Elliptic curve point
58  **/
59 
60 typedef struct
61 {
62  uint8_t *x;
63  uint8_t *y;
64  uint8_t *z;
65 } PukccEcPoint;
66 
67 
68 /**
69  * @brief Fmult service parameters
70  **/
71 
72 typedef struct
73 {
74  uint8_t *mod;
75  uint8_t *cns;
76  uint8_t *x;
77  uint8_t *y;
78  uint8_t *z;
79  uint8_t *r;
81 
82 
83 /**
84  * @brief GCD service parameters
85  **/
86 
87 typedef struct
88 {
89  uint8_t *x;
90  uint8_t *y;
91  uint8_t *a;
92  uint8_t *z;
93  uint8_t *w;
95 
96 
97 /**
98  * @brief RedMod service parameters
99  **/
100 
101 typedef struct
102 {
103  uint8_t *mod;
104  uint8_t *cns;
105  uint8_t *exp;
106  uint8_t *r;
107  uint8_t *x;
109 
110 
111 /**
112  * @brief ExpMod service parameters
113  **/
114 
115 typedef struct
116 {
117  uint8_t *mod;
118  uint8_t *cns;
119  uint8_t *exp;
120  uint8_t *r;
121  uint8_t *x;
122  uint8_t *w;
124 
125 
126 /**
127  * @brief PrimeGen service parameters
128  **/
129 
130 typedef struct
131 {
132  uint8_t *n;
133  uint8_t *cns;
134  uint8_t *rnd;
135  uint8_t *w;
136  uint8_t *r;
137  uint8_t *exp;
139 
140 
141 /**
142  * @brief CRT service parameters
143  **/
144 
145 typedef struct
146 {
147  uint8_t *mod;
148  uint8_t *x;
149  uint8_t *exp;
150  uint8_t *p;
151  uint8_t *q;
152  uint8_t *dp;
153  uint8_t *dq;
154  uint8_t *r;
156 
157 
158 /**
159  * @brief ZpEcPointIsOnCurve service parameters
160  **/
161 
162 typedef struct
163 {
164  uint8_t *mod;
165  uint8_t *cns;
167  uint8_t *a;
168  uint8_t *b;
169  uint8_t *r;
170  uint8_t *x;
171  uint8_t *w;
173 
174 
175 /**
176  * @brief ZpEcConvProjToAffine service parameters
177  **/
178 
179 typedef struct
180 {
181  uint8_t *mod;
182  uint8_t *cns;
183  uint8_t *k;
185  uint8_t *r;
186  uint8_t *x;
187  uint8_t *w;
189 
190 
191 /**
192  * @brief ZpEccMul service parameters
193  **/
194 
195 typedef struct
196 {
197  uint8_t *mod;
198  uint8_t *cns;
199  uint8_t *k;
201  uint8_t *a;
202  uint8_t *r;
203  uint8_t *x;
204  uint8_t *w;
206 
207 
208 /**
209  * @brief ZpEcDsaGenerate service parameters
210  **/
211 
212 typedef struct
213 {
214  uint8_t *mod;
215  uint8_t *cns;
217  uint8_t *order;
218  uint8_t *a;
219  uint8_t *privateKey;
220  uint8_t *k;
221  uint8_t *h;
222  uint8_t *r;
223  uint8_t *x;
224  uint8_t *w;
226 
227 
228 /**
229  * @brief ZpEcDsaVerify service parameters
230  **/
231 
232 typedef struct
233 {
234  uint8_t *mod;
235  uint8_t *cns;
237  uint8_t *order;
238  uint8_t *a;
240  uint8_t *h;
241  uint8_t *r;
242  uint8_t *s;
243  uint8_t *x;
244  uint8_t *w;
246 
247 
248 //PUKCC related functions
249 error_t pukccInit(void);
250 
251 //C++ guard
252 #ifdef __cplusplus
253 }
254 #endif
255 
256 #endif
ZpEccMul service parameters.
ZpEcPointIsOnCurve service parameters.
PrimeGen service parameters.
Fmult service parameters.
ExpMod service parameters.
Elliptic curve point.
error_t
Error codes.
Definition: error.h:43
ZpEcConvProjToAffine service parameters.
ZpEcDsaVerify service parameters.
General definitions for cryptographic algorithms.
RedMod service parameters.
GCD service parameters.
CRT service parameters.
error_t pukccInit(void)
Initialize PUKCC module.
ZpEcDsaGenerate service parameters.