same54_crypto_pukcc.c File Reference

SAME54 PUKCC public key accelerator. More...

#include "same54.h"
#include "pukcc/CryptoLib_typedef_pb.h"
#include "pukcc/CryptoLib_Headers_pb.h"
#include "core/crypto.h"
#include "hardware/same54_crypto.h"
#include "hardware/same54_crypto_pukcc.h"
#include "pkc/rsa.h"
#include "ecc/ec.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 pukccInit (void)
 Initialize PUKCC public key accelerator. More...
 
uint8_t * pukccImportArray (uint8_t **dest, const uint8_t *array, size_t arrayLen, size_t totalLen)
 Import byte array. More...
 
uint8_t * pukccImportMpi (uint8_t **dest, const Mpi *src, size_t totalLen)
 Import multiple-precision integer. More...
 
uint8_t * pukccWorkspace (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 rsadp (const RsaPrivateKey *key, const Mpi *c, Mpi *m)
 RSA decryption primitive. More...
 
bool_t ecIsPointAffine (const EcDomainParameters *ecParams, const EcPoint *s)
 Check whether the affine point S is on the curve. More...
 
error_t ecAffinify (const EcDomainParameters *ecParams, EcPoint *r, const EcPoint *s)
 Recover affine representation. More...
 
error_t ecMult (const EcDomainParameters *ecParams, EcPoint *r, const Mpi *d, const EcPoint *s)
 Scalar multiplication. More...
 
error_t ecdsaGenerateSignature (const EcDomainParameters *ecParams, const PrngAlgo *prngAlgo, void *prngContext, const Mpi *privateKey, const uint8_t *digest, size_t digestLen, EcdsaSignature *signature)
 ECDSA signature generation. More...
 
error_t ecdsaVerifySignature (const EcDomainParameters *ecParams, const EcPoint *publicKey, const uint8_t *digest, size_t digestLen, const EcdsaSignature *signature)
 ECDSA signature verification. More...
 

Variables

PPUKCL_PARAM pvPUKCLParam
 
PUKCL_PARAM PUKCLParam
 

Detailed Description

SAME54 PUKCC public key accelerator.

License

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

Copyright (C) 2010-2019 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
1.9.4

Definition in file same54_crypto_pukcc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 32 of file same54_crypto_pukcc.c.

Function Documentation

◆ ecAffinify()

error_t ecAffinify ( const EcDomainParameters ecParams,
EcPoint r,
const EcPoint s 
)

Recover affine representation.

Parameters
[in]ecParamsEC domain parameters
[out]rAffine representation of the point
[in]sProjective representation of the point
Returns
Error code

Definition at line 789 of file same54_crypto_pukcc.c.

◆ ecdsaGenerateSignature()

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

ECDSA signature generation.

Parameters
[in]ecParamsEC domain parameters
[in]prngAlgoPRNG algorithm
[in]prngContextPointer to the PRNG context
[in]privateKeySigner's ECDSA 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 1027 of file same54_crypto_pukcc.c.

◆ ecdsaVerifySignature()

error_t ecdsaVerifySignature ( const EcDomainParameters ecParams,
const EcPoint publicKey,
const uint8_t *  digest,
size_t  digestLen,
const EcdsaSignature signature 
)

ECDSA signature verification.

Parameters
[in]ecParamsEC domain parameters
[in]publicKeySigner's ECDSA 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 1201 of file same54_crypto_pukcc.c.

◆ ecIsPointAffine()

bool_t ecIsPointAffine ( const EcDomainParameters ecParams,
const EcPoint s 
)

Check whether the affine point S is on the curve.

Parameters
[in]ecParamsEC domain parameters
[in]sAffine representation of the point
Returns
TRUE if the affine point S is on the curve, else FALSE

Definition at line 690 of file same54_crypto_pukcc.c.

◆ ecMult()

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

Scalar multiplication.

Parameters
[in]ecParamsEC 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 899 of file same54_crypto_pukcc.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 421 of file same54_crypto_pukcc.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 346 of file same54_crypto_pukcc.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 271 of file same54_crypto_pukcc.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 190 of file same54_crypto_pukcc.c.

◆ pukccImportArray()

uint8_t* pukccImportArray ( uint8_t **  dest,
const uint8_t *  array,
size_t  arrayLen,
size_t  totalLen 
)

Import byte array.

Parameters
[in,out]destPointer to the crypto memory
[in]arrayPointer to the byte array
[in]arrayLenLength of the array to be copied
[in]totalLenDesired length of the area, in bytes
Returns
Pointer to the initialized area

Definition at line 98 of file same54_crypto_pukcc.c.

◆ pukccImportMpi()

uint8_t* pukccImportMpi ( 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 135 of file same54_crypto_pukcc.c.

◆ pukccInit()

error_t pukccInit ( void  )

Initialize PUKCC public key accelerator.

Definition at line 56 of file same54_crypto_pukcc.c.

◆ pukccWorkspace()

uint8_t* pukccWorkspace ( 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 160 of file same54_crypto_pukcc.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 573 of file same54_crypto_pukcc.c.

Variable Documentation

◆ PUKCLParam

PUKCL_PARAM PUKCLParam

Definition at line 49 of file same54_crypto_pukcc.c.

◆ pvPUKCLParam

PPUKCL_PARAM pvPUKCLParam

Definition at line 48 of file same54_crypto_pukcc.c.