m2354_crypto_pkc.c File Reference

M2354 public-key hardware accelerator. More...

#include "m2354.h"
#include "core/crypto.h"
#include "hardware/m2354/m2354_crypto.h"
#include "hardware/m2354/m2354_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
 

Functions

void rsaImportMpi (uint32_t *dest, uint_t length, const Mpi *a)
 Import multiple-precision integer. More...
 
error_t rsaExportMpi (uint32_t *src, uint_t length, Mpi *r)
 Export multiple-precision integer. More...
 
error_t mpiExpModFast (Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p)
 Modular exponentiation (fast calculation) More...
 
error_t mpiExpModRegular (Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p)
 Modular exponentiation (regular calculation) More...
 
error_t rsadp (const RsaPrivateKey *key, const Mpi *c, Mpi *m)
 RSA decryption primitive. More...
 
void eccImportScalar (volatile uint32_t *dest, uint_t length, const uint32_t *src)
 Import scalar. More...
 
void eccExportScalar (volatile uint32_t *src, uint_t length, uint32_t *dest)
 Export scalar. 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 ecTwinMul (const EcCurve *curve, EcPoint3 *r, const uint32_t *d0, const EcPoint3 *s, const uint32_t *d1, const EcPoint3 *t)
 Twin multiplication. More...
 

Detailed Description

M2354 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.

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

Definition in file m2354_crypto_pkc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file m2354_crypto_pkc.c.

Function Documentation

◆ eccExportScalar()

void eccExportScalar ( volatile uint32_t *  src,
uint_t  length,
uint32_t *  dest 
)

Export scalar.

Parameters
[in]srcPointer to the operand
[in]lengthLength of the operand, in bits
[out]destPointer to the scalar

Definition at line 450 of file m2354_crypto_pkc.c.

◆ eccImportScalar()

void eccImportScalar ( volatile uint32_t *  dest,
uint_t  length,
const uint32_t *  src 
)

Import scalar.

Parameters
[in]destPointer to the operand
[in]lengthLength of the operand, in bits
[in]srcPointer to the scalar

Definition at line 428 of file m2354_crypto_pkc.c.

◆ ecMulFast()

error_t ecMulFast ( const EcCurve curve,
EcPoint3 r,
const uint32_t *  d,
const EcPoint3 s 
)

Scalar multiplication (fast calculation)

Parameters
[in]curveElliptic curve parameters
[out]rResulting point R = d.S
[in]dAn integer d such as 0 <= d < p
[in]sEC point
Returns
Error code

Definition at line 474 of file m2354_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]curveElliptic curve parameters
[out]rResulting point R = d.S
[in]dAn integer d such as 0 <= d < q
[in]sEC point
Returns
Error code

Definition at line 491 of file m2354_crypto_pkc.c.

◆ ecTwinMul()

error_t ecTwinMul ( const EcCurve curve,
EcPoint3 r,
const uint32_t *  d0,
const EcPoint3 s,
const uint32_t *  d1,
const EcPoint3 t 
)

Twin multiplication.

Parameters
[in]curveElliptic curve parameters
[out]rResulting point R = d0.S + d1.T
[in]d0An integer d such as 0 <= d0 < p
[in]sEC point
[in]d1An integer d such as 0 <= d1 < p
[in]tEC point
Returns
Error code

Definition at line 576 of file m2354_crypto_pkc.c.

◆ mpiExpModFast()

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

Modular exponentiation (fast calculation)

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 142 of file m2354_crypto_pkc.c.

◆ mpiExpModRegular()

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

Modular exponentiation (regular calculation)

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 224 of file m2354_crypto_pkc.c.

◆ rsadp()

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

RSA decryption primitive.

The RSA decryption primitive recovers the message representative from the ciphertext representative under the control of a private key

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

Definition at line 311 of file m2354_crypto_pkc.c.

◆ rsaExportMpi()

error_t rsaExportMpi ( uint32_t *  src,
uint_t  length,
Mpi r 
)

Export multiple-precision integer.

Parameters
[in]srcPointer to the operand
[in]lengthLength of the operand, in bytes
[out]rPointer to the multiple-precision integer
Returns
Error code

Definition at line 92 of file m2354_crypto_pkc.c.

◆ rsaImportMpi()

void rsaImportMpi ( uint32_t *  dest,
uint_t  length,
const Mpi a 
)

Import multiple-precision integer.

Parameters
[in]destPointer to the operand
[in]lengthLength of the operand, in bytes
[in]aPointer to the multiple-precision integer

Definition at line 59 of file m2354_crypto_pkc.c.