ESP32-C3 public-key hardware accelerator. More...
#include "esp_crypto_lock.h"#include "soc/system_reg.h"#include "soc/hwcrypto_reg.h"#include "esp_private/periph_ctrl.h"#include "hardware/esp32_c3/esp32_c3_crypto.h"#include "hardware/esp32_c3/esp32_c3_crypto_pkc.h"#include "pkc/rsa.h"#include "ecc/ec.h"#include "ecc/ec_misc.h"#include "debug.h"Go to the source code of this file.
Macros | |
| #define | TRACE_LEVEL CRYPTO_TRACE_LEVEL |
| #define | SECP224R1_PRIME_M 0xFFFFFFFF |
| #define | SECP256K1_PRIME_M 0xD2253531 |
| #define | SECP256R1_PRIME_M 0x00000001 |
| #define | SECP384R1_PRIME_M 0x00000001 |
| #define | SECP521R1_PRIME_M 0x00000001 |
| #define | BRAINPOOLP256R1_PRIME_M 0xCEFD89B9 |
| #define | BRAINPOOLP384R1_PRIME_M 0xEA9EC825 |
| #define | BRAINPOOLP512R1_PRIME_M 0x7D89EFC5 |
| #define | FRP256V1_PRIME_M 0x164E1155 |
| #define | SM2_PRIME_M 0x00000001 |
| #define | CURVE25519_PRIME_M 0x286BCA1B |
| #define | CURVE448_PRIME_M 0x00000001 |
| #define | SECP224R1_ORDER_M 0x6A1FC2EB |
| #define | SECP256K1_ORDER_M 0x5588B13F |
| #define | SECP256R1_ORDER_M 0xEE00BC4F |
| #define | SECP384R1_ORDER_M 0xE88FDC45 |
| #define | SECP521R1_ORDER_M 0x79A995C7 |
| #define | BRAINPOOLP256R1_ORDER_M 0xCBB40EE9 |
| #define | BRAINPOOLP384R1_ORDER_M 0x5CB5BB93 |
| #define | BRAINPOOLP512R1_ORDER_M 0x0F1B7027 |
| #define | FRP256V1_ORDER_M 0x4FFF51DF |
| #define | SM2_ORDER_M 0x72350975 |
Functions | |
| void | esp32c3RsaInit (void) |
| RSA module initialization. More... | |
| error_t | mpiMul (Mpi *r, const Mpi *a, const Mpi *b) |
| Multiple precision multiplication. More... | |
| error_t | mpiExpMod (Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p) |
| Modular exponentiation. More... | |
| void | ecScalarMul (uint32_t *rl, uint32_t *rh, const uint32_t *a, const uint32_t *b, uint_t n) |
| Multiplication of two integers. More... | |
| void | ecScalarSqr (uint32_t *r, const uint32_t *a, uint_t n) |
| Squaring operation. More... | |
| void | ecFieldMulMod (const EcCurve *curve, uint32_t *r, const uint32_t *a, const uint32_t *b) |
| Modular multiplication. More... | |
| void | ecFieldSqrMod (const EcCurve *curve, uint32_t *r, const uint32_t *a) |
| Modular squaring. More... | |
| void | ecScalarMulMod (const EcCurve *curve, uint32_t *r, const uint32_t *a, const uint32_t *b) |
| Modular multiplication. More... | |
| void | ecScalarSqrMod (const EcCurve *curve, uint32_t *r, const uint32_t *a) |
| Modular squaring. More... | |
Detailed Description
ESP32-C3 public-key hardware accelerator.
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneCRYPTO Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- Version
- 2.5.4
Definition in file esp32_c3_crypto_pkc.c.
Macro Definition Documentation
◆ BRAINPOOLP256R1_ORDER_M
| #define BRAINPOOLP256R1_ORDER_M 0xCBB40EE9 |
Definition at line 69 of file esp32_c3_crypto_pkc.c.
◆ BRAINPOOLP256R1_PRIME_M
| #define BRAINPOOLP256R1_PRIME_M 0xCEFD89B9 |
Definition at line 55 of file esp32_c3_crypto_pkc.c.
◆ BRAINPOOLP384R1_ORDER_M
| #define BRAINPOOLP384R1_ORDER_M 0x5CB5BB93 |
Definition at line 70 of file esp32_c3_crypto_pkc.c.
◆ BRAINPOOLP384R1_PRIME_M
| #define BRAINPOOLP384R1_PRIME_M 0xEA9EC825 |
Definition at line 56 of file esp32_c3_crypto_pkc.c.
◆ BRAINPOOLP512R1_ORDER_M
| #define BRAINPOOLP512R1_ORDER_M 0x0F1B7027 |
Definition at line 71 of file esp32_c3_crypto_pkc.c.
◆ BRAINPOOLP512R1_PRIME_M
| #define BRAINPOOLP512R1_PRIME_M 0x7D89EFC5 |
Definition at line 57 of file esp32_c3_crypto_pkc.c.
◆ CURVE25519_PRIME_M
| #define CURVE25519_PRIME_M 0x286BCA1B |
Definition at line 60 of file esp32_c3_crypto_pkc.c.
◆ CURVE448_PRIME_M
| #define CURVE448_PRIME_M 0x00000001 |
Definition at line 61 of file esp32_c3_crypto_pkc.c.
◆ FRP256V1_ORDER_M
| #define FRP256V1_ORDER_M 0x4FFF51DF |
Definition at line 72 of file esp32_c3_crypto_pkc.c.
◆ FRP256V1_PRIME_M
| #define FRP256V1_PRIME_M 0x164E1155 |
Definition at line 58 of file esp32_c3_crypto_pkc.c.
◆ SECP224R1_ORDER_M
| #define SECP224R1_ORDER_M 0x6A1FC2EB |
Definition at line 64 of file esp32_c3_crypto_pkc.c.
◆ SECP224R1_PRIME_M
| #define SECP224R1_PRIME_M 0xFFFFFFFF |
Definition at line 50 of file esp32_c3_crypto_pkc.c.
◆ SECP256K1_ORDER_M
| #define SECP256K1_ORDER_M 0x5588B13F |
Definition at line 65 of file esp32_c3_crypto_pkc.c.
◆ SECP256K1_PRIME_M
| #define SECP256K1_PRIME_M 0xD2253531 |
Definition at line 51 of file esp32_c3_crypto_pkc.c.
◆ SECP256R1_ORDER_M
| #define SECP256R1_ORDER_M 0xEE00BC4F |
Definition at line 66 of file esp32_c3_crypto_pkc.c.
◆ SECP256R1_PRIME_M
| #define SECP256R1_PRIME_M 0x00000001 |
Definition at line 52 of file esp32_c3_crypto_pkc.c.
◆ SECP384R1_ORDER_M
| #define SECP384R1_ORDER_M 0xE88FDC45 |
Definition at line 67 of file esp32_c3_crypto_pkc.c.
◆ SECP384R1_PRIME_M
| #define SECP384R1_PRIME_M 0x00000001 |
Definition at line 53 of file esp32_c3_crypto_pkc.c.
◆ SECP521R1_ORDER_M
| #define SECP521R1_ORDER_M 0x79A995C7 |
Definition at line 68 of file esp32_c3_crypto_pkc.c.
◆ SECP521R1_PRIME_M
| #define SECP521R1_PRIME_M 0x00000001 |
Definition at line 54 of file esp32_c3_crypto_pkc.c.
◆ SM2_ORDER_M
| #define SM2_ORDER_M 0x72350975 |
Definition at line 73 of file esp32_c3_crypto_pkc.c.
◆ SM2_PRIME_M
| #define SM2_PRIME_M 0x00000001 |
Definition at line 59 of file esp32_c3_crypto_pkc.c.
◆ TRACE_LEVEL
| #define TRACE_LEVEL CRYPTO_TRACE_LEVEL |
Definition at line 32 of file esp32_c3_crypto_pkc.c.
Function Documentation
◆ ecFieldMulMod()
| void ecFieldMulMod | ( | const EcCurve * | curve, |
| uint32_t * | r, | ||
| const uint32_t * | a, | ||
| const uint32_t * | b | ||
| ) |
Modular multiplication.
- Parameters
-
[in] curve Elliptic curve parameters [out] r Resulting integer R = (A * B) mod p [in] a An integer such as 0 <= A < p [in] b An integer such as 0 <= B < p
Definition at line 634 of file esp32_c3_crypto_pkc.c.
◆ ecFieldSqrMod()
| void ecFieldSqrMod | ( | const EcCurve * | curve, |
| uint32_t * | r, | ||
| const uint32_t * | a | ||
| ) |
Modular squaring.
- Parameters
-
[in] curve Elliptic curve parameters [out] r Resulting integer R = A^2 mod p [in] a An integer such as 0 <= A < p
Definition at line 777 of file esp32_c3_crypto_pkc.c.
◆ ecScalarMul()
| void ecScalarMul | ( | uint32_t * | rl, |
| uint32_t * | rh, | ||
| const uint32_t * | a, | ||
| const uint32_t * | b, | ||
| uint_t | n | ||
| ) |
Multiplication of two integers.
- Parameters
-
[out] rl Low part of the result R = (A * B) mod (2^32)^n [out] rh High part of the result R = (A * B) / (2^32)^n [in] a An integer such as 0 <= A < (2^32)^n [in] b An integer such as 0 <= B < (2^32)^n [in] n Size of the operands, in words
Definition at line 543 of file esp32_c3_crypto_pkc.c.
◆ ecScalarMulMod()
| void ecScalarMulMod | ( | const EcCurve * | curve, |
| uint32_t * | r, | ||
| const uint32_t * | a, | ||
| const uint32_t * | b | ||
| ) |
Modular multiplication.
- Parameters
-
[in] curve Elliptic curve parameters [out] r Resulting integer R = (A * B) mod q [in] a An integer such as 0 <= A < q [in] b An integer such as 0 <= B < q
Definition at line 792 of file esp32_c3_crypto_pkc.c.
◆ ecScalarSqr()
| void ecScalarSqr | ( | uint32_t * | r, |
| const uint32_t * | a, | ||
| uint_t | n | ||
| ) |
Squaring operation.
- Parameters
-
[out] r Result R = A ^ 2 [in] a An integer such as 0 <= A < (2^32)^n [in] n Size of the integer A, in words
Definition at line 619 of file esp32_c3_crypto_pkc.c.
◆ ecScalarSqrMod()
| void ecScalarSqrMod | ( | const EcCurve * | curve, |
| uint32_t * | r, | ||
| const uint32_t * | a | ||
| ) |
Modular squaring.
- Parameters
-
[in] curve Elliptic curve parameters [out] r Resulting integer R = A^2 mod q [in] a An integer such as 0 <= A < q
Definition at line 935 of file esp32_c3_crypto_pkc.c.
◆ esp32c3RsaInit()
| void esp32c3RsaInit | ( | void | ) |
RSA module initialization.
Definition at line 210 of file esp32_c3_crypto_pkc.c.
◆ mpiExpMod()
Modular exponentiation.
- Parameters
-
[out] r Resulting integer R = A ^ E mod P [in] a Pointer to a multiple precision integer [in] e Exponent [in] p Modulus
- Returns
- Error code
Definition at line 357 of file esp32_c3_crypto_pkc.c.
