sama5d4_crypto_pkc.c File Reference

SAMA5D4 public-key hardware accelerator (CPKCC) More...

#include "chip.h"
#include "cpkcc/CryptoLib_cf.h"
#include "cpkcc/CryptoLib_JumpTable_Addr_pb.h"
#include "core/crypto.h"
#include "hardware/sama5d4/sama5d4_crypto.h"
#include "hardware/sama5d4/sama5d4_crypto_pkc.h"
#include "pkc/rsa.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 * 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...
 

Variables

PCPKCL_PARAM pvCPKCLParam
 
CPKCL_PARAM CPKCLParam
 

Detailed Description

SAMA5D4 public-key hardware accelerator (CPKCC)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2026 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.6.0

Definition in file sama5d4_crypto_pkc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file sama5d4_crypto_pkc.c.

Function Documentation

◆ cpkccImportMpi()

uint8_t* cpkccImportMpi ( uint8_t **  dest,
const Mpi src,
size_t  totalLen 
)

Import multiple-precision integer.

Parameters
[in,out]destPointer to the crypto memory
[in]srcPointer to the multiple-precision integer
[in]totalLenDesired length of the area, in bytes
Returns
Pointer to the initialized area

Definition at line 104 of file sama5d4_crypto_pkc.c.

◆ cpkccInit()

error_t cpkccInit ( void  )

Initialize CPKCC module.

Definition at line 57 of file sama5d4_crypto_pkc.c.

◆ cpkccWorkspace()

uint8_t* cpkccWorkspace ( uint8_t **  dest,
size_t  totalLen 
)

Initialize workspace area.

Parameters
[in,out]destPointer to the crypto memory
[in]totalLenDesired length of the area, in bytes
Returns
Pointer to the initialized area

Definition at line 129 of file sama5d4_crypto_pkc.c.

◆ mpiCheckProbablePrime()

error_t mpiCheckProbablePrime ( const Mpi a)

Test whether a number is probable prime.

Parameters
[in]aPointer to a multiple precision integer
Returns
Error code

Definition at line 549 of file sama5d4_crypto_pkc.c.

◆ mpiExpMod()

error_t mpiExpMod ( Mpi r,
const Mpi a,
const Mpi e,
const Mpi p 
)

Modular exponentiation.

Parameters
[out]rResulting integer R = A ^ E mod P
[in]aPointer to a multiple precision integer
[in]eExponent
[in]pModulus
Returns
Error code

Definition at line 399 of file sama5d4_crypto_pkc.c.

◆ mpiInvMod()

error_t mpiInvMod ( Mpi r,
const Mpi a,
const Mpi p 
)

Modular inverse.

Parameters
[out]rResulting integer R = A^-1 mod P
[in]aThe multiple precision integer A
[in]pThe modulus P
Returns
Error code

Definition at line 324 of file sama5d4_crypto_pkc.c.

◆ mpiMod2()

error_t mpiMod2 ( Mpi r,
const Mpi a,
const Mpi p 
)

Modulo operation.

Parameters
[out]rResulting integer R = A mod P
[in]aThe multiple precision integer to be reduced
[in]pThe modulus P
Returns
Error code

Definition at line 249 of file sama5d4_crypto_pkc.c.

◆ mpiMul()

error_t mpiMul ( Mpi r,
const Mpi a,
const Mpi b 
)

Multiple precision multiplication.

Parameters
[out]rResulting integer R = A * B
[in]aFirst operand A
[in]bSecond operand B
Returns
Error code

Definition at line 161 of file sama5d4_crypto_pkc.c.

◆ rsadp()

error_t rsadp ( const RsaPrivateKey key,
const Mpi c,
Mpi m 
)

RSA decryption primitive.

Parameters
[in]keyRSA private key
[in]cCiphertext representative
[out]mMessage representative
Returns
Error code

Definition at line 695 of file sama5d4_crypto_pkc.c.

Variable Documentation

◆ CPKCLParam

CPKCL_PARAM CPKCLParam

Definition at line 50 of file sama5d4_crypto_pkc.c.

◆ pvCPKCLParam

PCPKCL_PARAM pvCPKCLParam

Definition at line 49 of file sama5d4_crypto_pkc.c.