MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxClMath_Functions

Defines all functions of mcuxClMath. More...

Macros

#define MCUXCLMATH_FP_INITLOCALUPTRT(i3_i2_i1_i0, i7_i6_i5_i4, localPtrUptrt, noOfIndices)
 Helper macro to call mcuxClMath_InitLocalUptrt with flow protection. More...
 
#define MCUXCLMATH_FP_LEADINGZEROS(iX)
 Helper macro to call mcuxClMath_LeadingZeros with flow protection. More...
 
#define MCUXCLMATH_FP_TRAILINGZEROS(iX)
 Helper macro to call mcuxClMath_TrailingZeros with flow protection. More...
 
#define MCUXCLMATH_SHIFTMODULUS(iNShifted, iN)
 Helper macro for mcuxClMath_ShiftModulus. More...
 
#define MCUXCLMATH_FP_SHIFTMODULUS(iNShifted, iN)
 Helper macro for mcuxClMath_ShiftModulus with flow protection. More...
 
#define MCUXCLMATH_NDASH(iN, iT)
 Helper macro for mcuxClMath_NDash. More...
 
#define MCUXCLMATH_FP_NDASH(iN, iT)
 Helper macro for mcuxClMath_NDash with flow protection. More...
 
#define MCUXCLMATH_QDASH(iQDash, iNShifted, iN, iT, len)
 Helper macro for mcuxClMath_QDash. More...
 
#define MCUXCLMATH_FP_QDASH(iQDash, iNShifted, iN, iT, len)
 Helper macro for mcuxClMath_QDash with flow protection. More...
 
#define MCUXCLMATH_QSQUARED(iQSqr, iNShifted, iN, iT)
 Helper macro for mcuxClMath_QSquared. More...
 
#define MCUXCLMATH_FP_QSQUARED(iQSqr, iNShifted, iN, iT)
 Helper macro for mcuxClMath_QSquared with flow protection. More...
 
#define MCUXCLMATH_MODINV(iR, iX, iN, iT)
 Helper macro for mcuxClMath_ModInv. More...
 
#define MCUXCLMATH_FP_MODINV(iR, iX, iN, iT)
 Helper macro for mcuxClMath_ModInv with flow protection. More...
 
#define MCUXCLMATH_REDUCEMODEVEN(iR, iX, iN, iT0, iT1, iT2, iT3)
 Helper macro for mcuxClMath_ReduceModEven. More...
 
#define MCUXCLMATH_FP_REDUCEMODEVEN(iR, iX, iN, iT0, iT1, iT2, iT3)
 Helper macro for mcuxClMath_ReduceModEven with flow protection. More...
 
#define MCUXCLMATH_MODEXP_SQRMULTL2R(pExp, byteLenExp, iR, iX, iN, iT)
 Helper macro for mcuxClMath_ModExp_SqrMultL2R. More...
 
#define MCUXCLMATH_FP_MODEXP_SQRMULTL2R(pExp, byteLenExp, iR, iX, iN, iT)
 Helper macro for mcuxClMath_ModExp_SqrMultL2R with flow protection. More...
 
#define MCUXCLMATH_SECMODEXP(pExp, pExpTemp, byteLenExp, iR, iX, iN, iTE, iT0, iT1, iT2, iT3)
 Helper macro for mcuxClMath_SecModExp. More...
 
#define MCUXCLMATH_FP_SECMODEXP(pExp, pExpTemp, byteLenExp, iR, iX, iN, iTE, iT0, iT1, iT2, iT3)
 Helper macro for mcuxClMath_SecModExp with flow protection. More...
 
#define MCUXCLMATH_EXACTDIVIDEODD(iR, iX, iN, iT, pkcByteLenX, pkcByteLenY)
 Helper macro for mcuxClMath_ExactDivideOdd. More...
 
#define MCUXCLMATH_FP_EXACTDIVIDEODD(iR, iX, iN, iT, pkcByteLenX, pkcByteLenY)
 Helper macro for mcuxClMath_ExactDivideOdd with flow protection. More...
 
#define MCUXCLMATH_EXACTDIVIDE(iR, iX, iN, iT, pkcByteLenX, pkcByteLenY)
 Helper macro for mcuxClMath_ExactDivide. More...
 
#define MCUXCLMATH_FP_EXACTDIVIDE(iR, iX, iN, iT, pkcByteLenX, pkcByteLenY)
 Helper macro for mcuxClMath_ExactDivide with flow protection. More...
 

Functions

mcuxClMath_Status_Protected_t 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 the new UPTRT and returns the address of existing UPTRT. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_LeadingZeros (uint8_t iX, uint32_t *nLeadingZeros)
 Counts number of leading zeros of operand in the given buffer (length = ps1 OPLEN). More...
 
mcuxClMath_Status_Protected_t mcuxClMath_TrailingZeros (uint8_t iX, uint32_t *nTrailingZeros)
 Counts number of trailing zeros of operand in the given buffer (length = ps1 OPLEN). More...
 
mcuxClMath_Status_Protected_t mcuxClMath_ShiftModulus (uint16_t iNShifted_iN)
 Left shifts modulus until most significant bit of the buffer (length = ps1 OPLEN) is 1, and stores the result in the buffer specified. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_NDash (uint16_t iN_iT)
 Prepares modulus buffer (initializes NDash) to be used in modular multiplication (inversion, ...) with odd modulus. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_QDash (uint32_t iQDash_iNShifted_iN_iT, uint16_t len)
 Calculates Q * Q' mod n, where Q = 256^(ps1 OPLEN) mod n, and Q' = 256^len mod n. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_QSquared (uint32_t iQSqr_iNShifted_iN_iT)
 Calculates Q^2 mod n, where Q = 256^(ps1 OPLEN) mod n. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_ModInv (uint32_t iR_iX_iN_iT)
 Calculates modular inversion, X^(-1) mod n. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_ReduceModEven (uint32_t iR_iX_iN_iT0, uint32_t iT1_iT2_iT3)
 Calculates modular reduction with even modulus, x mod n, where n is even. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_ModExp_SqrMultL2R (const uint8_t *pExp, uint32_t byteLenExp, uint32_t iR_iX_iN_iT)
 Calculates modular exponentiation with left-to-right binary square and multiply algorithm. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_SecModExp (const uint8_t *pExp, uint32_t *pExpTemp, uint32_t byteLenExp, uint32_t iT3_iX_iT2_iT1, uint32_t iN_iTE_iT0_iR)
 Securely calculates modular exponentiation. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_ExactDivideOdd (uint32_t iR_iX_iY_iT, uint32_t pkcByteLenX, uint32_t pkcByteLenY)
 TODO 1.pkcByteLenX and pkcByteLenY shall be a multiple of pkc wordsize. More...
 
mcuxClMath_Status_Protected_t mcuxClMath_ExactDivide (uint32_t iR_iX_iY_iT, uint32_t pkcByteLenX, uint32_t pkcByteLenY)
 Exact division. More...
 

Detailed Description

Defines all functions of mcuxClMath.

Macro Definition Documentation

◆ MCUXCLMATH_FP_INITLOCALUPTRT

#define MCUXCLMATH_FP_INITLOCALUPTRT (   i3_i2_i1_i0,
  i7_i6_i5_i4,
  localPtrUptrt,
  noOfIndices 
)

Helper macro to call mcuxClMath_InitLocalUptrt with flow protection.

◆ MCUXCLMATH_FP_LEADINGZEROS

#define MCUXCLMATH_FP_LEADINGZEROS (   iX)

Helper macro to call mcuxClMath_LeadingZeros with flow protection.

◆ MCUXCLMATH_FP_TRAILINGZEROS

#define MCUXCLMATH_FP_TRAILINGZEROS (   iX)

Helper macro to call mcuxClMath_TrailingZeros with flow protection.

◆ MCUXCLMATH_SHIFTMODULUS

#define MCUXCLMATH_SHIFTMODULUS (   iNShifted,
  iN 
)

Helper macro for mcuxClMath_ShiftModulus.

◆ MCUXCLMATH_FP_SHIFTMODULUS

#define MCUXCLMATH_FP_SHIFTMODULUS (   iNShifted,
  iN 
)

Helper macro for mcuxClMath_ShiftModulus with flow protection.

◆ MCUXCLMATH_NDASH

#define MCUXCLMATH_NDASH (   iN,
  iT 
)

Helper macro for mcuxClMath_NDash.

◆ MCUXCLMATH_FP_NDASH

#define MCUXCLMATH_FP_NDASH (   iN,
  iT 
)

Helper macro for mcuxClMath_NDash with flow protection.

◆ MCUXCLMATH_QDASH

#define MCUXCLMATH_QDASH (   iQDash,
  iNShifted,
  iN,
  iT,
  len 
)

Helper macro for mcuxClMath_QDash.

◆ MCUXCLMATH_FP_QDASH

#define MCUXCLMATH_FP_QDASH (   iQDash,
  iNShifted,
  iN,
  iT,
  len 
)

Helper macro for mcuxClMath_QDash with flow protection.

◆ MCUXCLMATH_QSQUARED

#define MCUXCLMATH_QSQUARED (   iQSqr,
  iNShifted,
  iN,
  iT 
)

Helper macro for mcuxClMath_QSquared.

◆ MCUXCLMATH_FP_QSQUARED

#define MCUXCLMATH_FP_QSQUARED (   iQSqr,
  iNShifted,
  iN,
  iT 
)

Helper macro for mcuxClMath_QSquared with flow protection.

◆ MCUXCLMATH_MODINV

#define MCUXCLMATH_MODINV (   iR,
  iX,
  iN,
  iT 
)

Helper macro for mcuxClMath_ModInv.

◆ MCUXCLMATH_FP_MODINV

#define MCUXCLMATH_FP_MODINV (   iR,
  iX,
  iN,
  iT 
)

Helper macro for mcuxClMath_ModInv with flow protection.

◆ MCUXCLMATH_REDUCEMODEVEN

#define MCUXCLMATH_REDUCEMODEVEN (   iR,
  iX,
  iN,
  iT0,
  iT1,
  iT2,
  iT3 
)

Helper macro for mcuxClMath_ReduceModEven.

◆ MCUXCLMATH_FP_REDUCEMODEVEN

#define MCUXCLMATH_FP_REDUCEMODEVEN (   iR,
  iX,
  iN,
  iT0,
  iT1,
  iT2,
  iT3 
)

Helper macro for mcuxClMath_ReduceModEven with flow protection.

◆ MCUXCLMATH_MODEXP_SQRMULTL2R

#define MCUXCLMATH_MODEXP_SQRMULTL2R (   pExp,
  byteLenExp,
  iR,
  iX,
  iN,
  iT 
)

Helper macro for mcuxClMath_ModExp_SqrMultL2R.

◆ MCUXCLMATH_FP_MODEXP_SQRMULTL2R

#define MCUXCLMATH_FP_MODEXP_SQRMULTL2R (   pExp,
  byteLenExp,
  iR,
  iX,
  iN,
  iT 
)

Helper macro for mcuxClMath_ModExp_SqrMultL2R with flow protection.

◆ MCUXCLMATH_SECMODEXP

#define MCUXCLMATH_SECMODEXP (   pExp,
  pExpTemp,
  byteLenExp,
  iR,
  iX,
  iN,
  iTE,
  iT0,
  iT1,
  iT2,
  iT3 
)

Helper macro for mcuxClMath_SecModExp.

◆ MCUXCLMATH_FP_SECMODEXP

#define MCUXCLMATH_FP_SECMODEXP (   pExp,
  pExpTemp,
  byteLenExp,
  iR,
  iX,
  iN,
  iTE,
  iT0,
  iT1,
  iT2,
  iT3 
)

Helper macro for mcuxClMath_SecModExp with flow protection.

◆ MCUXCLMATH_EXACTDIVIDEODD

#define MCUXCLMATH_EXACTDIVIDEODD (   iR,
  iX,
  iN,
  iT,
  pkcByteLenX,
  pkcByteLenY 
)

Helper macro for mcuxClMath_ExactDivideOdd.

◆ MCUXCLMATH_FP_EXACTDIVIDEODD

#define MCUXCLMATH_FP_EXACTDIVIDEODD (   iR,
  iX,
  iN,
  iT,
  pkcByteLenX,
  pkcByteLenY 
)

Helper macro for mcuxClMath_ExactDivideOdd with flow protection.

◆ MCUXCLMATH_EXACTDIVIDE

#define MCUXCLMATH_EXACTDIVIDE (   iR,
  iX,
  iN,
  iT,
  pkcByteLenX,
  pkcByteLenY 
)

Helper macro for mcuxClMath_ExactDivide.

◆ MCUXCLMATH_FP_EXACTDIVIDE

#define MCUXCLMATH_FP_EXACTDIVIDE (   iR,
  iX,
  iN,
  iT,
  pkcByteLenX,
  pkcByteLenY 
)

Helper macro for mcuxClMath_ExactDivide with flow protection.

Function Documentation

◆ mcuxClMath_InitLocalUptrt()

mcuxClMath_Status_Protected_t 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 the new UPTRT and returns the address of existing UPTRT.

This function copies up to 8 offsets of PKC operands from existing UPTRT to the new UPTRT, sets PKC to be with the new UPTRT, and returns the address of original UPTRT.

Returns
A code-flow protected error code (see Flow Protection API)
Parameters
[in]i3_i2_i1_i0the first 4 indices of offsets to be copied.
[in]i7_i6_i5_i4the second 4 indices of offsets to be copied.
[out]localPtrUptrtpointer to the new UPTRT to be filled.
[in]noOfIndicesnumber of offsets to be copied from existing UPTRT to new UPTRT.
[out]oldPtrUptrtpointer which receives the pointer to the old UPTRT.

◆ mcuxClMath_LeadingZeros()

mcuxClMath_Status_Protected_t mcuxClMath_LeadingZeros ( uint8_t  iX,
uint32_t *  nLeadingZeros 
)

Counts number of leading zeros of operand in the given buffer (length = ps1 OPLEN).

Attention
The offset (UPTRT[iX]) must be initialized properly (equal to a multiple of PKC wordsize).
The length (ps1 OPLEN) must be initialized properly (equal to a multiple of PKC wordsize).
Returns
A code-flow protected error code (see Flow Protection API)
Parameters
[in]iXindex of operand buffer.
[out]nLeadingZerosthe number of leading zero bits.

◆ mcuxClMath_TrailingZeros()

mcuxClMath_Status_Protected_t mcuxClMath_TrailingZeros ( uint8_t  iX,
uint32_t *  nTrailingZeros 
)

Counts number of trailing zeros of operand in the given buffer (length = ps1 OPLEN).

Attention
The offset (UPTRT[iX]) must be initialized properly (equal to a multiple of PKC wordsize).
The length (ps1 OPLEN) must be initialized properly (equal to a multiple of PKC wordsize).
Returns
A code-flow protected error code (see Flow Protection API)
Parameters
[in]iXindex of operand buffer.
[out]nTrailingZerosthe number of trailing zero bits.

◆ mcuxClMath_ShiftModulus()

mcuxClMath_Status_Protected_t mcuxClMath_ShiftModulus ( uint16_t  iNShifted_iN)

Left shifts modulus until most significant bit of the buffer (length = ps1 OPLEN) is 1, and stores the result in the buffer specified.

Attention
The modulus must be non-zero.
The offset (UPTRT[iN]) must be initialized properly (equal to a multiple of PKC wordsize).
The length (ps1 OPLEN) must be initialized properly (equal to a multiple of PKC wordsize).
The PKC calculation might be still on-going, call mcuxClPkc_WaitForFinish before CPU accesses to the result.
Returns
A code-flow protected error code (see Flow Protection API)
Parameters
[in]iNShifted_iNiNShifted: index of buffer in which the result will be stored.
iN: index of modulus buffer.

◆ mcuxClMath_NDash()

mcuxClMath_Status_Protected_t mcuxClMath_NDash ( uint16_t  iN_iT)

Prepares modulus buffer (initializes NDash) to be used in modular multiplication (inversion, ...) with odd modulus.

This function calculates NDash = (-n)^(-1) mod 256^("PKC wordsize"), and stores the result in the PKC word in front of the modulus (n) buffer.

Attention
The modulus must be an odd number.
The offset (UPTRT[iN]) must be initialized properly (equal to a multiple of PKC wordsize).
The PKC calculation might be still on-going, call mcuxClPkc_WaitForFinish before CPU accesses to the result.
Returns
A code-flow protected error code (see Flow Protection API)
Parameters
[in]iN_iTiN: index of modulus buffer. The result (NDash) will be stored in the PKC word in front of the modulus buffer.
iT: index of temp buffer, of which the size should be at least 2 PKC words.

◆ mcuxClMath_QDash()

mcuxClMath_Status_Protected_t mcuxClMath_QDash ( uint32_t  iQDash_iNShifted_iN_iT,
uint16_t  len 
)

Calculates Q * Q' mod n, where Q = 256^(ps1 OPLEN) mod n, and Q' = 256^len mod n.

Attention
Both ps1 (OP)LEN and MCLEN need to be initialized (MCLEN = OPLEN = operandSize).
The PKC calculation might be still on-going, call mcuxClPkc_WaitForFinish before CPU accesses to the result.
The result might be greater than the modulus.
Returns
A code-flow protected error code (see Flow Protection API)
Parameters
[in]iQDash_iNShifted_iN_iTiQDash: index of QDash buffer, in which the result will be stored.
iNShifted: index of shifted modulus. If the bit length of modulus is equal to the operand size (i.e., most significant bit is 1), it can be the same as iN.
iN: index of modulus buffer. NDash of the modulus should be store in front of it.
iT: index of temp buffer, of which the size should be at least operandSize + PKC wordsize.
[in]lenspecify Q' = 256^len mod n.

◆ mcuxClMath_QSquared()

mcuxClMath_Status_Protected_t mcuxClMath_QSquared ( uint32_t  iQSqr_iNShifted_iN_iT)

Calculates Q^2 mod n, where Q = 256^(ps1 OPLEN) mod n.

Attention
Both ps1 (OP)LEN and MCLEN need to be initialized (MCLEN = OPLEN = operandSize).
The length (ps1 OPLEN) must be initialized properly (equal to a multiple of PKC wordsize).
The PKC calculation might be still on-going, call mcuxClPkc_WaitForFinish before CPU accesses to the result.
The result might be greater than the modulus.
Returns
A code-flow protected error code (see Flow Protection API)
Parameters
[in]iQSqr_iNShifted_iN_iTiQSqr: index of QSqr buffer, in which the result will be stored.
iNShifted: index of shifted modulus. If the bit length of modulus is equal to the operand size (i.e., most significant bit is 1), it can be the same as iN.
iN: index of modulus buffer. NDash of the modulus should be store in front of it.
iT: index of temp buffer, of which the size should be at least operandSize + PKC wordsize.

◆ mcuxClMath_ModInv()

mcuxClMath_Status_Protected_t mcuxClMath_ModInv ( uint32_t  iR_iX_iN_iT)

Calculates modular inversion, X^(-1) mod n.

Attention
Both ps1 (OP)LEN and MCLEN need to be initialized (MCLEN = OPLEN = operandSize).
The offsets (UPTRT[iR] and UPTRT[iT]) must be initialized properly (equal to a multiple of PKC wordsize).
if X and n are not coprime, the result will be incorrect, and the modulus n will be destroyed.
The PKC calculation might be still on-going, call mcuxClPkc_WaitForFinish before CPU accesses to the result.
The result fits in operandSize but might be greater than the modulus.
Returns
A code-flow protected error code (see Flow Protection API)
Parameters
[in]iR_iX_iN_iTiR: index of result buffer, of which the size should be at least operandSize + PKC wordsize.
iX: index of X buffer, of which the content (X) will be destroyed.
iN: index of modulus buffer. NDash of the modulus should be store in front of it.
iT: index of temp buffer, of which the size should be at least operandSize + PKC wordsize.

◆ mcuxClMath_ReduceModEven()

mcuxClMath_Status_Protected_t mcuxClMath_ReduceModEven ( uint32_t  iR_iX_iN_iT0,
uint32_t  iT1_iT2_iT3 
)

Calculates modular reduction with even modulus, x mod n, where n is even.

Attention
Both ps1 (OP)LEN and MCLEN need to be initialized (MCLEN = lenX = length of x, OPLEN = lenN = length of n).
The lengths (ps1 OPLEN and MCLEN) must be initialized properly (equal to a multiple of PKC wordsize).
The offset (UPTRT[iN]) must be initialized properly (equal to a multiple of PKC wordsize).
The PKC calculation might be still on-going, call mcuxClPkc_WaitForFinish before CPU accesses to the result.
Parameters
[in]iR_iX_iN_iT0(bits 31~24) iR: index of result buffer, of which the size shall be at least (lenN + PKC wordsize).
(bits 23~16) iX: index of input buffer, of which the size shall be at least (lenX + PKC wordsize).
(bits 15~8) iN: index of modulus buffer, of which the size is lenN.
(bits 7~0) iT0: index of temp buffer, of which the size shall be at least (lenN + PKC wordsize). Buffer N can be used as T0.
[in]iT1_iT2_iT3(bits 23~16) iT1: index of temp buffer, of which the size shall be at least lenN. Buffer R can be used as T1. TODO: use R (any reason not using R?)
(bits 15~8) iT2: index of temp buffer, of which the size shall be at least lenN.
(bits 7~0) iT3: index of temp buffer, of which the size shall be at least (lenN + PKC wordsize).

◆ mcuxClMath_ModExp_SqrMultL2R()

mcuxClMath_Status_Protected_t mcuxClMath_ModExp_SqrMultL2R ( const uint8_t *  pExp,
uint32_t  byteLenExp,
uint32_t  iR_iX_iN_iT 
)

Calculates modular exponentiation with left-to-right binary square and multiply algorithm.

Parameters
[in]pExppointer to exponent, which is stored as a big-endian octet string.
[in]byteLenExpbyte length of exponent.
[in]iR_iX_iN_iTindices of operands in PKC workarea.
Parameter properties
pExp
the exponent is a big-endian octet string and must be non-zero.
iR_iX_iN_iT
iR (bits 31~24): index of result. The size shall be at least (lenN + PKC wordsize).
iX (bits 23~16): index of base number.
iN (bits 15~8): index of modulus. NDash of the modulus should be stored in front of it.
iT (bits 7~0): index of temp operand. The size shall be at least (lenN + PKC wordsize).
Attention
Both ps1 (OP)LEN and MCLEN need to be initialized (OPLEN = MCLEN = lenX (= length of x) = lenN (= length of n)).
The PKC calculation might be still on-going, call mcuxClPkc_WaitForFinish before CPU accesses to the result.
Returns
A code-flow protected error code (see Flow Protection API)

◆ mcuxClMath_SecModExp()

mcuxClMath_Status_Protected_t mcuxClMath_SecModExp ( const uint8_t *  pExp,
uint32_t *  pExpTemp,
uint32_t  byteLenExp,
uint32_t  iT3_iX_iT2_iT1,
uint32_t  iN_iTE_iT0_iR 
)

Securely calculates modular exponentiation.

Parameters
[in]pExppointer to exponent, which is stored as a big-endian octet string.
[in]pExpTemppointer to temporary buffer, in either CPU or PKC workarea.
[in]byteLenExpbyte length of exponent.
[in]iT3_iX_iT2_iT1indices of operands in PKC workarea.
[in]iN_iTE_iT0_iRindices of operands in PKC workarea.
Parameter properties
pExp
the exponent is a big-endian octet string and must be non-zero.
pExpTemp
the temporary buffer shall be aligned to CPU word, and it's length shall be a multiple of CPU word and greater than byteLenExp.
iT3_iX_iT2_iT1
iT3 (bits 31~24): index of temp3. The size shall be a multiple of PKC word and at least max(lenN, 2 * PKC wordsize).
iX (bits 23~16): index of base number. The size shall be a multiple of PKC word and at least lenN.
iT2 (bits 15~8): index of temp2. The size shall be a multiple of PKC word and at least max(lenN, 2 * PKC wordsize)
iT1 (bits 7~0): index of temp1. The size shall be a multiple of PKC word and at least max(lenN, byteLenExp + 1, 2 * PKC wordsize).
iN_iTE_iT0_iR
iN (bits 31~24): index of modulus. NDash of the modulus should be stored in front of it.
iTE (bits 23~16): index of temp4. The size shall be a multiple of PKC word and at least (5 * PKC wordsize).
iT0 (bits 15~8): index of temp0. The size shall be a multiple of PKC word and at least max(byteLenExp + 1, lenN + PKC wordsize).
iR (bits 7~0): index of result. The size shall be a multiple of PKC word and at least max(byteLenExp + 1, lenN + PKC wordsize).
Attention
Both ps1 (OP)LEN and MCLEN need to be initialized (OPLEN = MCLEN = lenX (= length of x) = lenN (= length of n)).
The lengths (ps1 OPLEN and MCLEN) must be initialized properly (equal to a multiple of PKC wordsize).
The PKC calculation might be still on-going, call mcuxClPkc_WaitForFinish before CPU accesses to the result.
Returns
A code-flow protected error code (see Flow Protection API)

◆ mcuxClMath_ExactDivideOdd()

mcuxClMath_Status_Protected_t mcuxClMath_ExactDivideOdd ( uint32_t  iR_iX_iY_iT,
uint32_t  pkcByteLenX,
uint32_t  pkcByteLenY 
)

TODO 1.pkcByteLenX and pkcByteLenY shall be a multiple of pkc wordsize.

2.the most significant PKC word of Y shall be nonzero. 3.size of temp (iT) is 3 pkc wordsizes. 4.if lenX = lenY = pkc wordsize, this function will access to one extra pkc word on top of X. (i.e., read/write to X[pkc word 0], read X[pkc word 1]).

◆ mcuxClMath_ExactDivide()

mcuxClMath_Status_Protected_t mcuxClMath_ExactDivide ( uint32_t  iR_iX_iY_iT,
uint32_t  pkcByteLenX,
uint32_t  pkcByteLenY 
)

Exact division.

This function computes the exact division r = x / y.

This function relies on mcuxClMath_ExactDivideOdd to compute the exact division of x / y. Suppose X is a multiple of Y, this function finds R such that (-X) + Y * R = 0. If there is a remainder to this division, this function will fail. The function destroys the content of buffer x. If this content is needed after the function call, it has to be backed up by the caller of this function.

Parameters
iR_iX_iY_iTPointer table indices of parameters
pkcByteLenXBytelength of parameter X
pkcByteLenYBytelength of parameter Y
Parameter properties
iR_iX_iY_iT:
iR - index of result buffer r; the caller has to reserve a buffer of size bytelen(x) - bytelen(y) + 2 * MCUXCLPKC_WORDSIZE iX - index of input buffer x; the content of buffer x is modified during processing of mcuxClMath_ExactDivide; if it is still needed after the function call, the buffer should be backed up iY - index of input buffer y; the most significant PKC word of Y shall be nonzero iT - index of temporary buffer; the size of the temporary buffer is 3 * pkc wordsize
pkcByteLenX:
Must be a multiple of the pkc wordsize. If pkcByteLenX = pkcByteLenY = pkc wordsize, this function accesses one extra pkc word on top of X.
pkcByteLenY:
Must be a multiple of the pkc wordsize.
Returns
A code-flow protected error code (see Flow Protection API)
Return values
MCUXCLMATH_ERRORCODE_OKDivision successful
MCUXCLMATH_ERRORCODE_ERRORError occured during divide operation