Datasheet

Table Of Contents
43.3.4.7.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(u2Options) =...;
// Depending on the option specified, not all fields should be filled
PUKCL_Smult(nu1XBase) = <Base of the X number>;
PUKCL_Smult(u2XLength) = <Length of the X number>;
PUKCL_Smult(nu1RBase) = <Base of the R number>;
PUKCL_Smult(u2RLength) = <Length of the R number>;
PUKCL_Smult(nu1ZBase) = <Base of the Z number>;
PUKCL_Smult(u4MulValue) = <Value to be multiplied with>;
// vPUKCL_Process() is a macro command, which populates the service name
// and then calls the library...
vPUKCL_Process(Smult,pvPUKCLParam);
if (PUKCL(u2Status) == PUKCL_OK)
{
// The Small multiplication has been executed correctly
...
}
else // Manage the error
Note: 
The length of R must be greater or equal to the length of X. 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) where the result (pointed by nu1RBase) is smaller in size
than twice the modulus plus one word, it is mandatory to add padding bytes to zero. Otherwise, the
reduced value will be taken considering the high order words (potentially uninitialized) as part of the
number, thus resulting in a mathematically correct but unexpected result.
In the case that the result is bigger than twice the modulus plus one word, the modular reduction feature
has to be executed as a separate operation, using an Euclidean division.
43.3.4.7.7 Constraints
For the case of a small multiplication with an option indicating either subtraction or accumulation, the
following conditions must be avoided to ensure the service works correctly:
nu1XBase, nu1RBase or nu1ZBase are not aligned on 32-bit boundaries
{nu1XBase, u2XLength}, {nu1ZLength, u2RLength} or {nu1RBase, u2RLength} do not entirely lie in
Crypto RAM
u2XLength or u2RLength is either: < 4, > 0xffc or not a 32-bit length or u2XLength >u2RLength
{nu1RBase, u2RLength} overlaps {nu1XBase, u2XLength} or nu1R < nu1Z and
{nu1RBase,u2RLength} overlaps {nu1ZBase, u2RLength}
If the nu1R value is greater or equals to the nu1Z one, the overlapping between R and Z is allowed.
If a modular reduction is specified, the relevant parameters must be defined according to the chosen
reduction and follow the description in 43.3.5.1 Modular Reduction. Additional constraints to be
respected and error codes are described in this section and in Table 43-22.
Multiplication with Accumulation or Subtraction
When the options bits specify that either an Accumulation or a Subtraction should be performed, this
service performs the following operation:
SAM D5x/E5x Family Data Sheet
Public Key Cryptography Controller (PUKCC)
© 2019 Microchip Technology Inc.
Datasheet
DS60001507E-page 1461