Go to the documentation of this file.
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
35 #include "fsl_device_registers.h"
46 #if (MIMXRT1170_CRYPTO_PKC_SUPPORT == ENABLED)
52 #if (MPI_SUPPORT == ENABLED)
71 caam_handle_t caamHandle;
104 caamHandle.jobRing = kCAAM_JobRing0;
117 status = CAAM_PKHA_ModMul(CAAM, &caamHandle,
pkhaArgs.
a, aLen,
119 kCAAM_PKHA_IntegerArith, kCAAM_PKHA_NormalValue,
120 kCAAM_PKHA_NormalValue, kCAAM_PKHA_TimingEqualized);
123 if(status == kStatus_Success)
170 caam_handle_t caamHandle;
178 if(modLen > 0 && modLen <= 512 && expLen > 0 && expLen <= 512)
190 caamHandle.jobRing = kCAAM_JobRing0;
203 status = CAAM_PKHA_ModExp(CAAM, &caamHandle,
pkhaArgs.
a, scalarLen,
205 kCAAM_PKHA_IntegerArith, kCAAM_PKHA_NormalValue,
206 kCAAM_PKHA_TimingEqualized);
209 if(status == kStatus_Success)
248 caam_handle_t caamHandle;
254 if(
n > 0 &&
n <= 4096)
310 caamHandle.jobRing = kCAAM_JobRing0;
319 status = CAAM_RNG_GetRandomData(CAAM, &caamHandle, kCAAM_RngStateHandle0,
323 if(status == kStatus_Success)
329 status = CAAM_PKHA_PrimalityTest(CAAM, &caamHandle,
pkhaArgs.
r,
n,
333 if(status == kStatus_Success)
368 #if (EC_SUPPORT == ENABLED)
403 caam_handle_t caamHandle;
404 caam_pkha_ecc_point_t input;
405 caam_pkha_ecc_point_t output;
408 modLen = (curve->fieldSize + 7) / 8;
410 orderLen = (curve->orderSize + 7) / 8;
413 if(modLen <= 66 && orderLen <= 66)
416 caamHandle.jobRing = kCAAM_JobRing0;
450 status = CAAM_PKHA_ECC_PointMul(CAAM, &caamHandle, &input,
pkhaEccArgs.
d,
452 modLen, kCAAM_PKHA_TimingEqualized, kCAAM_PKHA_IntegerArith, &output);
455 if(status == kStatus_Success)
512 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
518 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
529 state->
curve = curve;
error_t ecScalarImport(uint32_t *r, uint_t n, const uint8_t *input, size_t length, EcScalarFormat format)
Octet string to integer conversion.
error_t ecScalarExport(const uint32_t *a, uint_t n, uint8_t *output, size_t length, EcScalarFormat format)
Integer to octet string conversion.
Arbitrary precision integer.
PKHA ECC primitive arguments.
error_t ecMulRegular(const EcCurve *curve, EcPoint3 *r, const uint32_t *d, const EcPoint3 *s)
Scalar multiplication (regular calculation)
void ecFullAdd(EcState *state, EcPoint3 *r, const EcPoint3 *s, const EcPoint3 *t)
Point addition.
OsMutex mimxrt1170CryptoMutex
#define mpiWriteRaw(a, data, length)
void mpiInit(Mpi *r)
Initialize a multiple precision integer.
#define mpiReadRaw(r, data, length)
error_t mpiMod(Mpi *r, const Mpi *a, const Mpi *p)
Modulo operation.
@ ERROR_FAILURE
Generic error code.
void ecScalarSetInt(uint32_t *a, uint32_t b, uint_t n)
Set integer value.
MPI (Multiple Precision Integer Arithmetic)
General definitions for cryptographic algorithms.
i.MX RT1170 hardware cryptographic accelerator (CAAM)
i.MX RT1170 public-key hardware accelerator
uint_t mpiGetBitLength(const Mpi *a)
Get the actual length in bits.
PKHA primitive arguments.
error_t mpiCheckProbablePrime(const Mpi *a)
Test whether a number is probable prime.
Working state (point addition/subtraction/doubling)
@ EC_SCALAR_FORMAT_BIG_ENDIAN
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
EC point (projective coordinates)
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
error_t mpiMulMod(Mpi *r, const Mpi *a, const Mpi *b, const Mpi *p)
Modular multiplication.
error_t ecMulFast(const EcCurve *curve, EcPoint3 *r, const uint32_t *d, const EcPoint3 *s)
Scalar multiplication (fast calculation)
#define cryptoAllocMem(size)
error_t ecTwinMul(const EcCurve *curve, EcPoint3 *r, const uint32_t *d0, const EcPoint3 *s, const uint32_t *d1, const EcPoint3 *t)
Twin multiplication.
#define osMemset(p, value, length)
ECC (Elliptic Curve Cryptography)
#define EC_MAX_MODULUS_SIZE
error_t mpiExpMod(Mpi *r, const Mpi *a, const Mpi *e, const Mpi *p)
Modular exponentiation.
uint_t mpiGetByteLength(const Mpi *a)
Get the actual length in bytes.
void mpiFree(Mpi *r)
Release a multiple precision integer.