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
135 uint32_t *pNumLeadingZeros
212 uint16_t iNShifted_iN
215 #define MCUXCLMATH_SHIFTMODULUS(iNShifted, iN) \ 216 mcuxClMath_ShiftModulus(MCUXCLPKC_PACKARGS2(iNShifted, iN)) 218 #define MCUXCLMATH_FP_SHIFTMODULUS(iNShifted, iN) \ 219 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_SHIFTMODULUS(iNShifted, iN)) 262 #define MCUXCLMATH_NDASH(iN, iT) \ 263 mcuxClMath_NDash(MCUXCLPKC_PACKARGS2(iN, iT)) 265 #define MCUXCLMATH_FP_NDASH(iN, iT) \ 266 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_NDASH(iN, iT)) 311 uint32_t iQDash_iNShifted_iN_iT,
315 #define MCUXCLMATH_QDASH(iQDash, iNShifted, iN, iT, len) \ 316 mcuxClMath_QDash(MCUXCLPKC_PACKARGS4(iQDash, iNShifted, iN, iT), len) 318 #define MCUXCLMATH_FP_QDASH(iQDash, iNShifted, iN, iT, len) \ 319 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_QDASH(iQDash, iNShifted, iN, iT, len)) 361 uint32_t iQSqr_iNShifted_iN_iT
364 #define MCUXCLMATH_QSQUARED(iQSqr, iNShifted, iN, iT) \ 365 mcuxClMath_QSquared(MCUXCLPKC_PACKARGS4(iQSqr, iNShifted, iN, iT)) 367 #define MCUXCLMATH_FP_QSQUARED(iQSqr, iNShifted, iN, iT) \ 368 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_QSQUARED(iQSqr, iNShifted, iN, iT)) 416 #define MCUXCLMATH_MODINV(iR, iX, iN, iT) \ 417 mcuxClMath_ModInv(MCUXCLPKC_PACKARGS4(iR, iX, iN, iT)) 419 #define MCUXCLMATH_FP_MODINV(iR, iX, iN, iT) \ 420 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)) 616 uint32_t expByteLength,
617 uint32_t iT3_iX_iT2_iT1,
618 uint32_t iN_iTE_iT0_iR,
622 #define MCUXCLMATH_SECMODEXP(session, pExp, pExpTemp, byteLenExp, iR, iX, iN, iTE, iT0, iT1, iT2, iT3) \ 623 mcuxClMath_SecModExp(session, pExp, pExpTemp, byteLenExp, MCUXCLPKC_PACKARGS4(iT3, iX, iT2, iT1), MCUXCLPKC_PACKARGS4(iN, iTE, iT0, iR), 0u) 626 #define MCUXCLMATH_SECMODEXP_WITHOUT_RERANDOMIZATION(session, pExp, pExpTemp, byteLenExp, iR, iX, iN, iTE, iT0, iT1, iT2, iT3) \ 627 mcuxClMath_SecModExp(session, pExp, pExpTemp, byteLenExp, MCUXCLPKC_PACKARGS4(iT3, iX, iT2, iT1), MCUXCLPKC_PACKARGS4(iN, iTE, iT0, iR), MCUXCLMATH_SECMODEXP_OPTION_DIS_RERAND) 683 #define MCUXCLMATH_EXACTDIVIDEODD(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen) \ 684 mcuxClMath_ExactDivideOdd(MCUXCLPKC_PACKARGS4(iR, iX, iN, iT), xPkcByteLen, yPkcByteLen) 686 #define MCUXCLMATH_FP_EXACTDIVIDEODD(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen) \ 687 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_EXACTDIVIDEODD(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen)) 752 #define MCUXCLMATH_EXACTDIVIDE(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen) \ 753 mcuxClMath_ExactDivide(MCUXCLPKC_PACKARGS4(iR, iX, iN, iT), xPkcByteLen, yPkcByteLen) 756 #define MCUXCLMATH_FP_EXACTDIVIDE(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen) \ 757 MCUX_CSSL_FP_FUNCTION_CALL_VOID(MCUXCLMATH_EXACTDIVIDE(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen)) 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_ExactDivide(uint32_t iR_iX_iY_iT, uint32_t xPkcByteLength, uint32_t yPkcByteLength)
Calculates exact division (supporting even divisor).
void mcuxClMath_QSquared(uint32_t iQSqr_iNShifted_iN_iT)
Calculates QSquared = Q^2 mod n, where Q = 256^(operandSize) mod n.
void mcuxClMath_NDash(uint16_t iN_iT)
Prepares modulus (calculates NDash) for PKC modular multiplication.
void mcuxClMath_ExactDivideOdd(uint32_t iR_iX_iY_iT, uint32_t xPkcByteLength, uint32_t yPkcByteLength)
Calculates exact division with odd divisor.
void mcuxClMath_ModInv(uint32_t iR_iX_iN_iT)
Calculates modular inversion, with odd modulus.
Top level header of mcuxClPkc component (PKC hardware driver)
void mcuxClMath_ReduceModEven(uint32_t iR_iX_iN_iT0, uint32_t iT1_iT2_iT3)
Calculates modular reduction with even modulus.
Provides the API for the CSSL flow protection mechanism.
void mcuxClMath_ShiftModulus(uint16_t iNShifted_iN)
Prepares shifted modulus.
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.
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:125
void mcuxClMath_ModExp_SqrMultL2R(const uint8_t *pExp, uint32_t expByteLength, uint32_t iR_iX_iN_iT)
Calculates modular exponentiation.
Top-level include file for the mcuxClSession component.
uint32_t mcuxClMath_TrailingZeros(uint8_t iX)
Counts number of trailing zero bits of a PKC operand.
mcuxClSession_Descriptor_t *const mcuxClSession_Handle_t
Type for mcuxClSession Handle.
Definition: mcuxClSession_Types.h:133
void mcuxClMath_LeadingZeros(uint8_t iX, uint32_t *pNumLeadingZeros)
Counts number of leading zero bits of a PKC operand.
Definition of function identifiers for the flow protection mechanism.
uint32_t mcuxClMath_Status_t
Type for error codes used by Math component functions.
Definition: mcuxClMath_Types.h:46
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition: mcuxCsslFlowProtection.h:81
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, uint32_t secOption)
Securely calculates modular exponentiation.