20#ifndef MCUXCLMATH_FUNCTIONS_H_
21#define MCUXCLMATH_FUNCTIONS_H_
24#include <mcuxClCore_Platform.h>
31#include <mcuxClMath_Types.h>
96 uint16_t *localPtrUptrt,
98 const uint16_t **oldPtrUptrt
211 uint16_t iNShifted_iN
214#define MCUXCLMATH_SHIFTMODULUS(iNShifted, iN) \
215 mcuxClMath_ShiftModulus(MCUXCLPKC_PACKARGS2(iNShifted, iN))
217#define MCUXCLMATH_FP_SHIFTMODULUS(iNShifted, iN) \
218 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_SHIFTMODULUS(iNShifted, iN))
261#define MCUXCLMATH_NDASH(iN, iT) \
262 mcuxClMath_NDash(MCUXCLPKC_PACKARGS2(iN, iT))
264#define MCUXCLMATH_FP_NDASH(iN, iT) \
265 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_NDASH(iN, iT))
310 uint32_t iQDash_iNShifted_iN_iT,
314#define MCUXCLMATH_QDASH(iQDash, iNShifted, iN, iT, len) \
315 mcuxClMath_QDash(MCUXCLPKC_PACKARGS4(iQDash, iNShifted, iN, iT), len)
317#define MCUXCLMATH_FP_QDASH(iQDash, iNShifted, iN, iT, len) \
318 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_QDASH(iQDash, iNShifted, iN, iT, len))
360 uint32_t iQSqr_iNShifted_iN_iT
363#define MCUXCLMATH_QSQUARED(iQSqr, iNShifted, iN, iT) \
364 mcuxClMath_QSquared(MCUXCLPKC_PACKARGS4(iQSqr, iNShifted, iN, iT))
366#define MCUXCLMATH_FP_QSQUARED(iQSqr, iNShifted, iN, iT) \
367 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_QSQUARED(iQSqr, iNShifted, iN, iT))
415#define MCUXCLMATH_MODINV(iR, iX, iN, iT) \
416 mcuxClMath_ModInv(MCUXCLPKC_PACKARGS4(iR, iX, iN, iT))
418#define MCUXCLMATH_FP_MODINV(iR, iX, iN, iT) \
419 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_MODINV(iR, iX, iN, iT))
473 uint32_t iR_iX_iN_iT0,
477#define MCUXCLMATH_REDUCEMODEVEN(iR, iX, iN, iT0, iT1, iT2, iT3) \
478 mcuxClMath_ReduceModEven(MCUXCLPKC_PACKARGS4(iR, iX, iN, iT0), MCUXCLPKC_PACKARGS4(0u, iT1, iT2, iT3))
480#define MCUXCLMATH_FP_REDUCEMODEVEN(iR, iX, iN, iT0, iT1, iT2, iT3) \
481 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_REDUCEMODEVEN(iR, iX, iN, iT0, iT1, iT2, iT3))
526 uint32_t expByteLength,
530#define MCUXCLMATH_MODEXP_SQRMULTL2R(pExp, byteLenExp, iR, iX, iN, iT) \
531 mcuxClMath_ModExp_SqrMultL2R(pExp, byteLenExp, MCUXCLPKC_PACKARGS4(iR, iX, iN, iT))
533#define MCUXCLMATH_FP_MODEXP_SQRMULTL2R(pExp, byteLenExp, iR, iX, iN, iT) \
534 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_MODEXP_SQRMULTL2R(pExp, byteLenExp, iR, iX, iN, iT))
615 uint32_t expByteLength,
616 uint32_t iT3_iX_iT2_iT1,
617 uint32_t iN_iTE_iT0_iR
620#define MCUXCLMATH_SECMODEXP(session, pExp, pExpTemp, byteLenExp, iR, iX, iN, iTE, iT0, iT1, iT2, iT3) \
621 mcuxClMath_SecModExp(session, pExp, pExpTemp, byteLenExp, MCUXCLPKC_PACKARGS4(iT3, iX, iT2, iT1), MCUXCLPKC_PACKARGS4(iN, iTE, iT0, iR))
676#define MCUXCLMATH_EXACTDIVIDEODD(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen) \
677 mcuxClMath_ExactDivideOdd(MCUXCLPKC_PACKARGS4(iR, iX, iN, iT), xPkcByteLen, yPkcByteLen)
679#define MCUXCLMATH_FP_EXACTDIVIDEODD(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen) \
680 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_EXACTDIVIDEODD(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen))
745#define MCUXCLMATH_EXACTDIVIDE(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen) \
746 mcuxClMath_ExactDivide(MCUXCLPKC_PACKARGS4(iR, iX, iN, iT), xPkcByteLen, yPkcByteLen)
749#define MCUXCLMATH_FP_EXACTDIVIDE(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen) \
750 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_EXACTDIVIDE(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen))
Definition of function identifiers for the flow protection mechanism.
Top level header of mcuxClPkc component (PKC hardware driver)
Top-level include file for the mcuxClSession component.
Provides the API for the CSSL flow protection mechanism.
uint32_t mcuxClMath_TrailingZeros(uint8_t iX)
Counts number of trailing zero bits of a PKC operand.
uint32_t mcuxClMath_LeadingZeros(uint8_t iX)
Counts number of leading zero bits of a PKC operand.
void mcuxClMath_NDash(uint16_t iN_iT)
Prepares modulus (calculates NDash) for PKC modular multiplication.
mcuxClMath_Status_t mcuxClMath_SecModExp(mcuxClSession_Handle_t session, const uint8_t *pExp, uint32_t *pExpTemp, uint32_t expByteLength, uint32_t iT3_iX_iT2_iT1, uint32_t iN_iTE_iT0_iR)
Securely calculates modular exponentiation.
void mcuxClMath_QDash(uint32_t iQDash_iNShifted_iN_iT, uint16_t length)
Calculates QDash = Q * Q' mod n, where Q = 256^(operandSize) mod n, and Q' = 256^length mod n.
void mcuxClMath_ShiftModulus(uint16_t iNShifted_iN)
Prepares shifted modulus.
void mcuxClMath_InitLocalUptrt(uint32_t i3_i2_i1_i0, uint32_t i7_i6_i5_i4, uint16_t *localPtrUptrt, uint8_t noOfIndices, const uint16_t **oldPtrUptrt)
Initializes and uses the new UPTRT and returns the address of original UPTRT.
void mcuxClMath_ExactDivideOdd(uint32_t iR_iX_iY_iT, uint32_t xPkcByteLength, uint32_t yPkcByteLength)
Calculates exact division with odd divisor.
void mcuxClMath_ExactDivide(uint32_t iR_iX_iY_iT, uint32_t xPkcByteLength, uint32_t yPkcByteLength)
Calculates exact division (supporting even divisor).
void mcuxClMath_ModInv(uint32_t iR_iX_iN_iT)
Calculates modular inversion, with odd modulus.
void mcuxClMath_ModExp_SqrMultL2R(const uint8_t *pExp, uint32_t expByteLength, uint32_t iR_iX_iN_iT)
Calculates modular exponentiation.
void mcuxClMath_ReduceModEven(uint32_t iR_iX_iN_iT0, uint32_t iT1_iT2_iT3)
Calculates modular reduction with even modulus.
void mcuxClMath_QSquared(uint32_t iQSqr_iNShifted_iN_iT)
Calculates QSquared = Q^2 mod n, where Q = 256^(operandSize) mod n.
uint32_t mcuxClMath_Status_t
Type for error codes used by Math component functions.
Definition mcuxClMath_Types.h:46
mcuxClSession_Descriptor_t *const mcuxClSession_Handle_t
Type for mcuxClSession Handle.
Definition mcuxClSession_Types.h:113
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition mcuxCsslFlowProtection.h:125
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition mcuxCsslFlowProtection.h:81