Datasheet

Table Of Contents
PUKCL(u2Options) = SET_MULTIPLIEROPTION(PUKCL_SQUARE_ADD) |
SET_CARRYOPTION(ADD_CARRY) | PUKCL_REDMOD_REDUCTION |
PUKCL_REDMOD_USING_FASTRED;
The following table lists all of the necessary parameters for the Square option. When the Addition or
Subtraction option is not chosen it is not necessary to fill in the nu1ZBase parameter.
Table 43-31. Square Service Options
Option Purpose Required Parameters
SET_MULTIPLIEROPTION(PUKCL_
SQUARE_ONLY)
Perform R = X
2
+ CarryOperand nu1RBase, nu1ZBase,
nu1XBase, u2XLength
SET_MULTIPLIEROPTION(PUKCL_
SQUARE_ADD)
Perform R = Z + X
2
+
CarryOperand
nu1RBase, nu1ZBase,
nu1XBase, u2XLength
SET_MULTIPLIEROPTION(PUKCL_
SQUARE_SUB)
Perform R = Z - (X
2
+
CarryOperand)
nu1RBase, nu1ZBase,
nu1Xlength, u2XLength
43.3.4.10.6 Code Example
PUKCL_PARAM PUKCLParam;
PPUKCL_PARAM pvPUKCLParam = &PUKCLParam;
// Gf2n and CarryIn shall be beforehand filled (with zero or one)
PUKCL(Specific).Gf2n = ...;
PUKCL(Specific).CarryIn = ...;
PUKCL(u2Option) =...;
// Depending on the option specified, not all fields should be filled
PUKCL_Fmult(nu1XBase) = <Base of the ram location of X>;
PUKCL_Fmult(u2XLength) = <Length of X>;
PUKCL_Fmult(nu1ZBase) = <Base of the ram location of Z>;
// vPUKCL_Process() is a macro command, which populates the service name
// and then calls the library...
vPUKCL_Process(Square,pvPUKCLParam);
if (PUKCL(u2Status) == PUKCL_OK)
{
// The Squaring has been executed correctly
...
}
else // Manage the error
43.3.4.10.7 Important Considerations for Modular Reduction of a Square Computation
Note: 
Additional options are available through the use of a modular reduction to be executed at the end of this
operation. Some important considerations have to be taken into account concerning the length of
resulting operands to get a mathematically correct result.
The output of this operation is not obviously compatible with the modular reduction as it may be either
smaller or bigger. In the case (most of the time) the result (pointed by nu1RBase) is smaller in size than
“twice the modulus plus one word” by one word, a padding word must be added to zero. Otherwise, the
reduced value will be taken considering the high order words (potentially uninitialized) as part of the
number, thus resulting in getting a mathematically correct but unexpected result.
In the case that the result is greater than twice the modulus plus one word, the modular reduction feature
has to be executed as a separate operation, using an Euclidean division.
SAM D5x/E5x Family Data Sheet
Public Key Cryptography Controller (PUKCC)
© 2019 Microchip Technology Inc.
Datasheet
DS60001507E-page 1472