s5d9_crypto_pkc.c File Reference

Synergy S5D9 public-key hardware accelerator. More...

#include "hw_sce_private.h"
#include "hw_sce_rsa_private.h"
#include "hw_sce_ecc_private.h"
#include "core/crypto.h"
#include "hardware/s5d9/s5d9_crypto.h"
#include "hardware/s5d9/s5d9_crypto_pkc.h"
#include "pkc/rsa.h"
#include "ecc/ec.h"
#include "ecc/ecdsa.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

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 rsaGeneratePrivateKey (const PrngAlgo *prngAlgo, void *prngContext, size_t k, uint_t e, RsaPrivateKey *privateKey)
 RSA private key generation. More...
 
error_t rsadp (const RsaPrivateKey *key, const Mpi *c, Mpi *m)
 RSA decryption primitive. More...
 
error_t ecMult (const EcDomainParameters *params, EcPoint *r, const Mpi *d, const EcPoint *s)
 Scalar multiplication. More...
 
error_t ecGenerateKeyPair (const PrngAlgo *prngAlgo, void *prngContext, const EcDomainParameters *params, EcPrivateKey *privateKey, EcPublicKey *publicKey)
 EC key pair generation. More...
 
error_t ecdsaGenerateSignature (const PrngAlgo *prngAlgo, void *prngContext, const EcDomainParameters *params, const EcPrivateKey *privateKey, const uint8_t *digest, size_t digestLen, EcdsaSignature *signature)
 ECDSA signature generation. More...
 
error_t ecdsaVerifySignature (const EcDomainParameters *params, const EcPublicKey *publicKey, const uint8_t *digest, size_t digestLen, const EcdsaSignature *signature)
 ECDSA signature verification. More...
 

Detailed Description

Synergy S5D9 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.0

Definition in file s5d9_crypto_pkc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file s5d9_crypto_pkc.c.

Function Documentation

◆ ecdsaGenerateSignature()

error_t ecdsaGenerateSignature ( const PrngAlgo prngAlgo,
void *  prngContext,
const EcDomainParameters params,
const EcPrivateKey privateKey,
const uint8_t *  digest,
size_t  digestLen,
EcdsaSignature signature 
)

ECDSA signature generation.

Parameters
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
[in]paramsEC domain parameters
[in]privateKeySigner's EC private key
[in]digestDigest of the message to be signed
[in]digestLenLength in octets of the digest
[out]signature(R, S) integer pair
Returns
Error code

Definition at line 711 of file s5d9_crypto_pkc.c.

◆ ecdsaVerifySignature()

error_t ecdsaVerifySignature ( const EcDomainParameters params,
const EcPublicKey publicKey,
const uint8_t *  digest,
size_t  digestLen,
const EcdsaSignature signature 
)

ECDSA signature verification.

Parameters
[in]paramsEC domain parameters
[in]publicKeySigner's EC public key
[in]digestDigest of the message whose signature is to be verified
[in]digestLenLength in octets of the digest
[in]signature(R, S) integer pair
Returns
Error code

Definition at line 838 of file s5d9_crypto_pkc.c.

◆ ecGenerateKeyPair()

error_t ecGenerateKeyPair ( const PrngAlgo prngAlgo,
void *  prngContext,
const EcDomainParameters params,
EcPrivateKey privateKey,
EcPublicKey publicKey 
)

EC key pair generation.

Parameters
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
[in]paramsEC domain parameters
[out]privateKeyEC private key
[out]publicKeyEC public key
Returns
Error code

Definition at line 592 of file s5d9_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 473 of file s5d9_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 63 of file s5d9_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 147 of file s5d9_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 356 of file s5d9_crypto_pkc.c.

◆ rsaGeneratePrivateKey()

error_t rsaGeneratePrivateKey ( const PrngAlgo prngAlgo,
void *  prngContext,
size_t  k,
uint_t  e,
RsaPrivateKey privateKey 
)

RSA private key generation.

Parameters
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
[in]kRequired bit length of the modulus n (must be 1024 or 2048)
[in]ePublic exponent (must be 65537)
[out]privateKeyRSA private key
Returns
Error code

Definition at line 232 of file s5d9_crypto_pkc.c.