Datasheet

Table Of Contents
43.3.4.11.7 Status Returned Values
Table 43-36. Div Service Return Codes
Returned Status Importance Meaning
PUKCL_OK Service functioned correctly.
PUKCL_DIVISION_BY_ZERO Severe The operation was not performed because the
Denominator value is zero.
43.3.4.12 GCD, Modular Inverse
43.3.4.12.1 Purpose
The purpose of this command is to compute the Greatest Common Divisor (GCD) and the Modular
Inverse. The algorithm used is the Extended Euclidean Algorithm for the GCD.
This command accepts as input two multiple precision numbers in GF(p) or two polynomials in GF(2
n
) X
and Y and computes their GCD (D), if D equals one, the command also supplies the inverse of X modulo
Y.
The available options are as follows:
Work in the GF(2
n
) field or in the standard integer arithmetic field GF(p)
43.3.4.12.2 How to Use the Service
43.3.4.12.3 Description
This command calculates:
D = GCD(X,Y).
and parameter A in the Bezout equation:
A × X + B × Y = D.
The first input, or input to inverse is X.
The second input, or modulus is Y.
The GCD is output in D.
The modular inverse if X and Y are co-primes is output A:
A = X
–1
mod(Y)
The command calculates the GCD and the value A. The value A is the multiplicative inverse of X, only if
X and Y are co-prime. As a supplemental result, Z is given back, being the quotient of Y divided by D only
if D is different from zero:
=
At the end of the command: X is overwritten by D.
Y is cleared.
The value of A is calculated and stored.
The value of Z is calculated and stored if D is different from zero.
The service name for this operation is GCD.
In this computation, the following areas have to be provided:
SAM D5x/E5x Family Data Sheet
Public Key Cryptography Controller (PUKCC)
© 2019 Microchip Technology Inc.
Datasheet
DS60001507E-page 1477