m460_crypto_pkc.c File Reference

M460 public-key hardware accelerator. More...

#include "m460.h"
#include "core/crypto.h"
#include "hardware/m460/m460_crypto.h"
#include "hardware/m460/m460_crypto_pkc.h"
#include "pkc/rsa.h"
#include "ecc/ec.h"
#include "ecc/curve25519.h"
#include "ecc/curve448.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 eccImportMpi (volatile uint32_t *dest, uint_t length, const Mpi *a)
 Import multiple-precision integer. More...
 
error_t eccExportMpi (volatile uint32_t *src, uint_t length, Mpi *r)
 Export multiple-precision integer. More...
 
error_t ecMult (const EcDomainParameters *params, EcPoint *r, const Mpi *d, const EcPoint *s)
 Scalar multiplication. More...
 
error_t ecTwinMult (const EcDomainParameters *params, EcPoint *r, const Mpi *d0, const EcPoint *s, const Mpi *d1, const EcPoint *t)
 Twin multiplication. More...
 
void curve25519Mul (uint32_t *r, const uint32_t *a, const uint32_t *b)
 Modular multiplication. More...
 
void curve448Mul (uint32_t *r, const uint32_t *a, const uint32_t *b)
 Modular multiplication. More...
 

Detailed Description

M460 public-key hardware accelerator.

License

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

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

Definition in file m460_crypto_pkc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file m460_crypto_pkc.c.

Function Documentation

◆ curve25519Mul()

void curve25519Mul ( uint32_t *  r,
const uint32_t *  a,
const uint32_t *  b 
)

Modular multiplication.

Parameters
[out]rResulting integer R = (A * B) mod p
[in]aAn integer such as 0 <= A < p
[in]bAn integer such as 0 <= B < p

Definition at line 643 of file m460_crypto_pkc.c.

◆ curve448Mul()

void curve448Mul ( uint32_t *  r,
const uint32_t *  a,
const uint32_t *  b 
)

Modular multiplication.

Parameters
[out]rResulting integer R = (A * B) mod p
[in]aAn integer such as 0 <= A < p
[in]bAn integer such as 0 <= B < p

Definition at line 721 of file m460_crypto_pkc.c.

◆ eccExportMpi()

error_t eccExportMpi ( volatile uint32_t *  src,
uint_t  length,
Mpi r 
)

Export multiple-precision integer.

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

Definition at line 462 of file m460_crypto_pkc.c.

◆ eccImportMpi()

void eccImportMpi ( volatile 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 bits
[in]aPointer to the multiple-precision integer

Definition at line 429 of file m460_crypto_pkc.c.

◆ ecMult()

error_t ecMult ( const EcDomainParameters params,
EcPoint r,
const Mpi d,
const EcPoint s 
)

Scalar multiplication.

Parameters
[in]paramsEC domain 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 512 of file m460_crypto_pkc.c.

◆ ecTwinMult()

error_t ecTwinMult ( const EcDomainParameters params,
EcPoint r,
const Mpi d0,
const EcPoint s,
const Mpi d1,
const EcPoint t 
)

Twin multiplication.

Parameters
[in]paramsEC domain 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 600 of file m460_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 143 of file m460_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 225 of file m460_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 312 of file m460_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 93 of file m460_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 60 of file m460_crypto_pkc.c.