PIC32CX MTC/MTG/MTSH public-key hardware accelerator (CPKCC) More...
#include "pic32c.h"#include "cpkcc/CryptoLib_cf.h"#include "cpkcc/CryptoLib_JumpTable_Addr_pb.h"#include "core/crypto.h"#include "hardware/pic32cx_mt/pic32cx_mt_crypto.h"#include "hardware/pic32cx_mt/pic32cx_mt_crypto_pkc.h"#include "pkc/rsa.h"#include "ecc/ec.h"#include "ecc/ec_misc.h"#include "ecc/ecdsa.h"#include "mpi/mpi.h"#include "debug.h"Go to the source code of this file.
| Macros | |
| #define | TRACE_LEVEL CRYPTO_TRACE_LEVEL | 
| Functions | |
| error_t | cpkccInit (void) | 
| Initialize CPKCC module.  More... | |
| uint8_t * | cpkccImportArray (uint8_t **dest, const uint8_t *src, size_t srcLen, size_t totalLen) | 
| Import byte array.  More... | |
| uint8_t * | cpkccImportScalar (uint8_t **dest, const uint32_t *src, size_t totalLen) | 
| Import scalar.  More... | |
| uint8_t * | cpkccImportMpi (uint8_t **dest, const Mpi *src, size_t totalLen) | 
| Import multiple-precision integer.  More... | |
| uint8_t * | cpkccWorkspace (uint8_t **dest, size_t totalLen) | 
| Initialize workspace area.  More... | |
| error_t | mpiMul (Mpi *r, const Mpi *a, const Mpi *b) | 
| Multiple precision multiplication.  More... | |
| error_t | mpiMod2 (Mpi *r, const Mpi *a, const Mpi *p) | 
| Modulo operation.  More... | |
| error_t | mpiInvMod (Mpi *r, const Mpi *a, const Mpi *p) | 
| Modular inverse.  More... | |
| error_t | mpiExpMod (Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p) | 
| Modular exponentiation.  More... | |
| error_t | mpiCheckProbablePrime (const Mpi *a) | 
| Test whether a number is probable prime.  More... | |
| error_t | rsadp (const RsaPrivateKey *key, const Mpi *c, Mpi *m) | 
| RSA decryption primitive.  More... | |
| bool_t | ecIsPointAffine (const EcCurve *curve, const EcPoint *s) | 
| Check whether the affine point S is on the curve.  More... | |
| error_t | ecAffinify (const EcCurve *curve, EcPoint3 *r, const EcPoint3 *s) | 
| Recover affine representation.  More... | |
| error_t | ecMulFast (const EcCurve *curve, EcPoint3 *r, const uint32_t *d, const EcPoint3 *s) | 
| Scalar multiplication (fast calculation)  More... | |
| error_t | ecMulRegular (const EcCurve *curve, EcPoint3 *r, const uint32_t *d, const EcPoint3 *s) | 
| Scalar multiplication (regular calculation)  More... | |
| error_t | ecdsaGenerateSignature (const PrngAlgo *prngAlgo, void *prngContext, const EcPrivateKey *privateKey, const uint8_t *digest, size_t digestLen, EcdsaSignature *signature) | 
| ECDSA signature generation.  More... | |
| error_t | ecdsaVerifySignature (const EcPublicKey *publicKey, const uint8_t *digest, size_t digestLen, const EcdsaSignature *signature) | 
| ECDSA signature verification.  More... | |
| Variables | |
| PCPKCL_PARAM | pvCPKCLParam | 
| CPKCL_PARAM | CPKCLParam | 
Detailed Description
PIC32CX MTC/MTG/MTSH public-key hardware accelerator (CPKCC)
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 pic32cx_mt_crypto_pkc.c.
Macro Definition Documentation
◆ TRACE_LEVEL
| #define TRACE_LEVEL CRYPTO_TRACE_LEVEL | 
Definition at line 32 of file pic32cx_mt_crypto_pkc.c.
Function Documentation
◆ cpkccImportArray()
| uint8_t* cpkccImportArray | ( | uint8_t ** | dest, | 
| const uint8_t * | src, | ||
| size_t | srcLen, | ||
| size_t | totalLen | ||
| ) | 
Import byte array.
- Parameters
- 
  [in,out] dest Pointer to the crypto memory [in] src Pointer to the byte array [in] srcLen Length of the array to be copied [in] totalLen Desired length of the area, in bytes 
- Returns
- Pointer to the initialized area
Definition at line 112 of file pic32cx_mt_crypto_pkc.c.
◆ cpkccImportMpi()
| uint8_t* cpkccImportMpi | ( | uint8_t ** | dest, | 
| const Mpi * | src, | ||
| size_t | totalLen | ||
| ) | 
Import multiple-precision integer.
- Parameters
- 
  [in,out] dest Pointer to the crypto memory [in] src Pointer to the multiple-precision integer [in] totalLen Desired length of the area, in bytes 
- Returns
- Pointer to the initialized area
Definition at line 175 of file pic32cx_mt_crypto_pkc.c.
◆ cpkccImportScalar()
| uint8_t* cpkccImportScalar | ( | uint8_t ** | dest, | 
| const uint32_t * | src, | ||
| size_t | totalLen | ||
| ) | 
Import scalar.
- Parameters
- 
  [in,out] dest Pointer to the crypto memory [in] src Pointer to the scalar [in] totalLen Desired length of the area, in bytes 
- Returns
- Pointer to the initialized area
Definition at line 149 of file pic32cx_mt_crypto_pkc.c.
◆ cpkccInit()
| error_t cpkccInit | ( | void | ) | 
Initialize CPKCC module.
Definition at line 60 of file pic32cx_mt_crypto_pkc.c.
◆ cpkccWorkspace()
| uint8_t* cpkccWorkspace | ( | uint8_t ** | dest, | 
| size_t | totalLen | ||
| ) | 
Initialize workspace area.
- Parameters
- 
  [in,out] dest Pointer to the crypto memory [in] totalLen Desired length of the area, in bytes 
- Returns
- Pointer to the initialized area
Definition at line 200 of file pic32cx_mt_crypto_pkc.c.
◆ ecAffinify()
Recover affine representation.
- Parameters
- 
  [in] curve Elliptic curve parameters [out] r Affine representation of the point [in] s Projective representation of the point 
- Returns
- Error code
Definition at line 997 of file pic32cx_mt_crypto_pkc.c.
◆ ecdsaGenerateSignature()
| error_t ecdsaGenerateSignature | ( | const PrngAlgo * | prngAlgo, | 
| void * | prngContext, | ||
| const EcPrivateKey * | privateKey, | ||
| const uint8_t * | digest, | ||
| size_t | digestLen, | ||
| EcdsaSignature * | signature | ||
| ) | 
ECDSA signature generation.
- Parameters
- 
  [in] prngAlgo PRNG algorithm [in] prngContext Pointer to the PRNG context [in] privateKey Signer's EC private key [in] digest Digest of the message to be signed [in] digestLen Length in octets of the digest [out] signature (R, S) integer pair 
- Returns
- Error code
Definition at line 1252 of file pic32cx_mt_crypto_pkc.c.
◆ ecdsaVerifySignature()
| error_t ecdsaVerifySignature | ( | const EcPublicKey * | publicKey, | 
| const uint8_t * | digest, | ||
| size_t | digestLen, | ||
| const EcdsaSignature * | signature | ||
| ) | 
ECDSA signature verification.
- Parameters
- 
  [in] publicKey Signer's EC public key [in] digest Digest of the message whose signature is to be verified [in] digestLen Length in octets of the digest [in] signature (R, S) integer pair 
- Returns
- Error code
Definition at line 1407 of file pic32cx_mt_crypto_pkc.c.
◆ ecIsPointAffine()
Check whether the affine point S is on the curve.
- Parameters
- 
  [in] curve Elliptic curve parameters [in] s Affine representation of the point 
- Returns
- TRUE if the affine point S is on the curve, else FALSE
Definition at line 898 of file pic32cx_mt_crypto_pkc.c.
◆ ecMulFast()
Scalar multiplication (fast calculation)
- Parameters
- 
  [in] curve Elliptic curve parameters [out] r Resulting point R = d.S [in] d An integer d such as 0 <= d < p [in] s EC point 
- Returns
- Error code
Definition at line 1106 of file pic32cx_mt_crypto_pkc.c.
◆ ecMulRegular()
| error_t ecMulRegular | ( | const EcCurve * | curve, | 
| EcPoint3 * | r, | ||
| const uint32_t * | d, | ||
| const EcPoint3 * | s | ||
| ) | 
Scalar multiplication (regular calculation)
- Parameters
- 
  [in] curve Elliptic curve parameters [out] r Resulting point R = d.S [in] d An integer d such as 0 <= d < q [in] s EC point 
- Returns
- Error code
Definition at line 1123 of file pic32cx_mt_crypto_pkc.c.
◆ mpiCheckProbablePrime()
Test whether a number is probable prime.
- Parameters
- 
  [in] a Pointer to a multiple precision integer 
- Returns
- Error code
Definition at line 620 of file pic32cx_mt_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 470 of file pic32cx_mt_crypto_pkc.c.
◆ mpiInvMod()
Modular inverse.
- Parameters
- 
  [out] r Resulting integer R = A^-1 mod P [in] a The multiple precision integer A [in] p The modulus P 
- Returns
- Error code
Definition at line 395 of file pic32cx_mt_crypto_pkc.c.
◆ mpiMod2()
Modulo operation.
- Parameters
- 
  [out] r Resulting integer R = A mod P [in] a The multiple precision integer to be reduced [in] p The modulus P 
- Returns
- Error code
Definition at line 320 of file pic32cx_mt_crypto_pkc.c.
◆ mpiMul()
Multiple precision multiplication.
- Parameters
- 
  [out] r Resulting integer R = A * B [in] a First operand A [in] b Second operand B 
- Returns
- Error code
Definition at line 232 of file pic32cx_mt_crypto_pkc.c.
◆ rsadp()
| error_t rsadp | ( | const RsaPrivateKey * | key, | 
| const Mpi * | c, | ||
| Mpi * | m | ||
| ) | 
RSA decryption primitive.
- Parameters
- 
  [in] key RSA private key [in] c Ciphertext representative [out] m Message representative 
- Returns
- Error code
Definition at line 766 of file pic32cx_mt_crypto_pkc.c.
Variable Documentation
◆ CPKCLParam
| CPKCL_PARAM CPKCLParam | 
Definition at line 53 of file pic32cx_mt_crypto_pkc.c.
◆ pvCPKCLParam
| PCPKCL_PARAM pvCPKCLParam | 
Definition at line 52 of file pic32cx_mt_crypto_pkc.c.
