MCUX CLNS
MCUX Crypto Library Normal Secure
 
Loading...
Searching...
No Matches
mcuxClMath_Functions.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 2020-2024 NXP */
3/* */
4/* NXP Confidential. This software is owned or controlled by NXP and may */
5/* only be used strictly in accordance with the applicable license terms. */
6/* By expressly accepting such terms or by downloading, installing, */
7/* activating and/or otherwise using the software, you are agreeing that */
8/* you have read, and that you agree to comply with and are bound by, such */
9/* license terms. If you do not agree to be bound by the applicable license */
10/* terms, then you may not retain, install, activate or otherwise use the */
11/* software. */
12/*--------------------------------------------------------------------------*/
13
20#ifndef MCUXCLMATH_FUNCTIONS_H_
21#define MCUXCLMATH_FUNCTIONS_H_
22
23
24#include <mcuxClCore_Platform.h>
27
28#include <mcuxClPkc.h>
29#include <mcuxClSession.h>
30
31#include <mcuxClMath_Types.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
94 uint32_t i3_i2_i1_i0,
95 uint32_t i7_i6_i5_i4,
96 uint16_t *localPtrUptrt,
97 uint8_t noOfIndices,
98 const uint16_t **oldPtrUptrt
99 );
100
101
134 uint8_t iX
135 );
136
137
172 uint8_t iX
173 );
174
175
211 uint16_t iNShifted_iN
212 );
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))
219
220
258 uint16_t iN_iT
259 );
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))
266
267
310 uint32_t iQDash_iNShifted_iN_iT,
311 uint16_t length
312 );
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))
319
320
360 uint32_t iQSqr_iNShifted_iN_iT
361 );
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))
368
369
412 uint32_t iR_iX_iN_iT
413 );
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))
420
421
473 uint32_t iR_iX_iN_iT0,
474 uint32_t iT1_iT2_iT3
475 );
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))
482
483
525 const uint8_t *pExp,
526 uint32_t expByteLength,
527 uint32_t iR_iX_iN_iT
528 );
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))
535
536
613 const uint8_t *pExp,
614 uint32_t *pExpTemp,
615 uint32_t expByteLength,
616 uint32_t iT3_iX_iT2_iT1,
617 uint32_t iN_iTE_iT0_iR
618 );
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))
622
674MCUX_CSSL_FP_PROTECTED_TYPE(void) mcuxClMath_ExactDivideOdd(uint32_t iR_iX_iY_iT, uint32_t xPkcByteLength, uint32_t yPkcByteLength);
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))
681
682
743MCUX_CSSL_FP_PROTECTED_TYPE(void) mcuxClMath_ExactDivide(uint32_t iR_iX_iY_iT, uint32_t xPkcByteLength, uint32_t yPkcByteLength);
745#define MCUXCLMATH_EXACTDIVIDE(iR, iX, iN, iT, xPkcByteLen, yPkcByteLen) \
746 mcuxClMath_ExactDivide(MCUXCLPKC_PACKARGS4(iR, iX, iN, iT), xPkcByteLen, yPkcByteLen)
747
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))
751
752
753 /* mcuxClMath_Functions */
757
758#ifdef __cplusplus
759} /* extern "C" */
760#endif
761
762#endif /* MCUXCLMATH_FUNCTIONS_H_ */
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