pic32mz_crypto_pkc.h
Go to the documentation of this file.
1 /**
2  * @file pic32mz_crypto_pkc.h
3  * @brief PIC32MZ W1 public-key hardware accelerator (BA414E)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 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.5.0
29  **/
30 
31 #ifndef _PIC32MZ_CRYPTO_PKC_H
32 #define _PIC32MZ_CRYPTO_PKC_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //Public-key hardware accelerator
38 #ifndef PIC32MZ_CRYPTO_PKC_SUPPORT
39  #define PIC32MZ_CRYPTO_PKC_SUPPORT DISABLED
40 #elif (PIC32MZ_CRYPTO_PKC_SUPPORT != ENABLED && PIC32MZ_CRYPTO_PKC_SUPPORT != DISABLED)
41  #error PIC32MZ_CRYPTO_PKC_SUPPORT parameter is not valid
42 #endif
43 
44 //Point to the specified SCM memory slot
45 #define BA414E_GET_SCM_SLOT(n) ((uint32_t *) __CRYPTO1SCM_BASE + ((n) * 16))
46 
47 //Modular arithmetic operands
48 #define BA414E_MOD_SLOT_P 0
49 #define BA414E_MOD_SLOT_A 1
50 #define BA414E_MOD_SLOT_B 2
51 #define BA414E_MOD_SLOT_C 3
52 
53 //RSA modular exponentiation operands
54 #define BA414E_RSA_MOD_EXP_SLOT_P 0
55 #define BA414E_RSA_MOD_EXP_SLOT_A 1
56 #define BA414E_RSA_MOD_EXP_SLOT_E 2
57 #define BA414E_RSA_MOD_EXP_SLOT_C 3
58 
59 //ECC operands
60 #define BA414E_ECC_SLOT_P 0
61 #define BA414E_ECC_SLOT_N 1
62 #define BA414E_ECC_SLOT_GX 2
63 #define BA414E_ECC_SLOT_GY 3
64 #define BA414E_ECC_SLOT_A 4
65 #define BA414E_ECC_SLOT_B 5
66 #define BA414E_ECC_SLOT_P1X 6
67 #define BA414E_ECC_SLOT_P1Y 7
68 #define BA414E_ECC_SLOT_P2X 8
69 #define BA414E_ECC_SLOT_P2Y 9
70 #define BA414E_ECC_SLOT_P3X 10
71 #define BA414E_ECC_SLOT_P3Y 11
72 #define BA414E_ECC_SLOT_K 12
73 
74 //ECDSA operands
75 #define BA414E_ECDSA_SLOT_P 0
76 #define BA414E_ECDSA_SLOT_N 1
77 #define BA414E_ECDSA_SLOT_GX 2
78 #define BA414E_ECDSA_SLOT_GY 3
79 #define BA414E_ECDSA_SLOT_A 4
80 #define BA414E_ECDSA_SLOT_B 5
81 #define BA414E_ECDSA_SLOT_D 6
82 #define BA414E_ECDSA_SLOT_K 7
83 #define BA414E_ECDSA_SLOT_QX 8
84 #define BA414E_ECDSA_SLOT_QY 9
85 #define BA414E_ECDSA_SLOT_R 10
86 #define BA414E_ECDSA_SLOT_S 11
87 #define BA414E_ECDSA_SLOT_H 12
88 #define BA414E_ECDSA_SLOT_W 13
89 #define BA414E_ECDSA_SLOT_P1X 14
90 #define BA414E_ECDSA_SLOT_P1Y 15
91 
92 //Curve25519 operands
93 #define BA414E_CURVE25519_SLOT_P 0
94 #define BA414E_CURVE25519_SLOT_X1 2
95 #define BA414E_CURVE25519_SLOT_A24 3
96 #define BA414E_CURVE25519_SLOT_K 4
97 #define BA414E_CURVE25519_SLOT_X3 6
98 
99 //Ed25519 operands
100 #define BA414E_ED25519_SLOT_P 0
101 #define BA414E_ED25519_SLOT_D2 1
102 #define BA414E_ED25519_SLOT_PX 2
103 #define BA414E_ED25519_SLOT_PY 3
104 #define BA414E_ED25519_SLOT_E 4
105 #define BA414E_ED25519_SLOT_CX 6
106 #define BA414E_ED25519_SLOT_CY 7
107 
108 //OPSIZE bitfield
109 #define PKCOMMAND_OPSIZE_128B 0x00000200
110 #define PKCOMMAND_OPSIZE_256B 0x00000400
111 #define PKCOMMAND_OPSIZE_512B 0x00000800
112 
113 //OPERATION bitfield
114 #define PKCOMMAND_OP_MOD_ADD 0x00000001
115 #define PKCOMMAND_OP_MOD_SUB 0x00000002
116 #define PKCOMMAND_OP_MOD_MUL_ODD 0x00000003
117 #define PKCOMMAND_OP_MOD_RED_ODD 0x00000004
118 #define PKCOMMAND_OP_MOD_DIV_ODD 0x00000005
119 #define PKCOMMAND_OP_MOD_INV_ODD 0x00000006
120 #define PKCOMMAND_OP_MUL 0x00000008
121 #define PKCOMMAND_OP_MOD_INV_EVEN 0x00000009
122 #define PKCOMMAND_OP_RSA_MOD_EXP 0x00000010
123 #define PKCOMMAND_OP_RSA_PRIV_KEY_GEN 0x00000011
124 #define PKCOMMAND_OP_ECC_POINT_DBL 0x00000020
125 #define PKCOMMAND_OP_ECC_POINT_ADD 0x00000021
126 #define PKCOMMAND_OP_ECC_POINT_MUL 0x00000022
127 #define PKCOMMAND_OP_ECC_CHECK_AB 0x00000023
128 #define PKCOMMAND_OP_ECC_POINT_N 0x00000024
129 #define PKCOMMAND_OP_ECC_CHECK_RS 0x00000025
130 #define PKCOMMAND_OP_ECC_CHECK_POINT 0x00000026
131 #define PKCOMMAND_OP_CURVE25519_POINT_MUL 0x00000028
132 #define PKCOMMAND_OP_ED25519_XRECOVER 0x00000029
133 #define PKCOMMAND_OP_ED25519_SCALAR_MUL 0x0000002A
134 #define PKCOMMAND_OP_ED25519_CHECK_VALID 0x0000002B
135 #define PKCOMMAND_OP_ED25519_CHECK_POINT 0x0000002C
136 #define PKCOMMAND_OP_ECDSA_SIGN_GEN 0x00000030
137 #define PKCOMMAND_OP_ECDSA_SIGN_VERIFY 0x00000031
138 #define PKCOMMAND_OP_ECDSA_PARAMS_VALID 0x00000032
139 
140 //C++ guard
141 #ifdef __cplusplus
142 extern "C" {
143 #endif
144 
145 //BA414E related functions
147 void ba414eClearScm(void);
148 
149 //C++ guard
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif
error_t ba414eInit(void)
error_t
Error codes.
Definition: error.h:43
General definitions for cryptographic algorithms.
void ba414eClearScm(void)