stm32h5xx_crypto_pkc.h
Go to the documentation of this file.
1 /**
2  * @file stm32h5xx_crypto_pkc.h
3  * @brief STM32H5 public-key hardware accelerator (PKA)
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 _STM32H5XX_CRYPTO_PKC_H
32 #define _STM32H5XX_CRYPTO_PKC_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //Public-key hardware accelerator
38 #ifndef STM32H5XX_CRYPTO_PKC_SUPPORT
39  #define STM32H5XX_CRYPTO_PKC_SUPPORT DISABLED
40 #elif (STM32H5XX_CRYPTO_PKC_SUPPORT != ENABLED && STM32H5XX_CRYPTO_PKC_SUPPORT != DISABLED)
41  #error STM32H5XX_CRYPTO_PKC_SUPPORT parameter is not valid
42 #endif
43 
44 //Maximum RSA operand size, in bits
45 #define PKA_MAX_ROS 4160
46 //Maximum ECC operand size, in bits
47 #define PKA_MAX_EOS 640
48 
49 //PKA operation modes
50 #if defined(STM32H523xx) || defined(STM32H562xx) || defined(STM32H563xx)
51  #define PKA_CR_MODE_ECDSA_VERIFY 0x26
52 #else
53  #define PKA_CR_MODE_MODULAR_EXP 0x00
54  #define PKA_CR_MODE_MONTGOMERY_PARAM 0x01
55  #define PKA_CR_MODE_MODULAR_EXP_FAST 0x02
56  #define PKA_CR_MODE_MODULAR_EXP_PROTECTED 0x03
57  #define PKA_CR_MODE_RSA_CRT_EXP 0x07
58  #define PKA_CR_MODE_MODULAR_INV 0x08
59  #define PKA_CR_MODE_ARITHMETIC_ADD 0x09
60  #define PKA_CR_MODE_ARITHMETIC_SUB 0x0A
61  #define PKA_CR_MODE_ARITHMETIC_MUL 0x0B
62  #define PKA_CR_MODE_COMPARISON 0x0C
63  #define PKA_CR_MODE_MODULAR_RED 0x0D
64  #define PKA_CR_MODE_MODULAR_ADD 0x0E
65  #define PKA_CR_MODE_MODULAR_SUB 0x0F
66  #define PKA_CR_MODE_MONTGOMERY_MUL 0x10
67  #define PKA_CR_MODE_ECC_MUL 0x20
68  #define PKA_CR_MODE_ECC_COMPLETE_ADD 0x23
69  #define PKA_CR_MODE_ECDSA_SIGN 0x24
70  #define PKA_CR_MODE_ECDSA_VERIFY 0x26
71  #define PKA_CR_MODE_DOUBLE_BASE_LADDER 0x27
72  #define PKA_CR_MODE_POINT_CHECK 0x28
73  #define PKA_CR_MODE_ECC_PROJECTIVE_AFF 0x2F
74 #endif
75 
76 //PKA status codes
77 #define PKA_STATUS_SUCCESS 0xD60D
78 #define PKA_STATUS_INVALID 0x0000
79 
80 //C++ guard
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 //PKA related functions
86 error_t pkaInit(void);
87 
88 //C++ guard
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif
error_t
Error codes.
Definition: error.h:43
General definitions for cryptographic algorithms.
error_t pkaInit(void)
PKA module initialization.