Cryptography Reference
In-Depth Information
without internal auxiliary objects and thus save unnecessary assignments and
calls to constructors.
For the cases in which a free assignment of the results of calculations is
unavoidable, or in which the automatic overwriting of the implicit argument
of the member functions with the result is not desired, the member functions
were extended by means of like-named analogous friend functions together with
additional friend functions. These are not discussed further here, but are recorded
in Appendix B. The treatment of possible error situations in LINT functions that
can arise from the use of CLINT functions will be discussed in full in Chapter 16.
Before we list the public member functions, we consider first as an example
of their implementation the functions
LINT& LINT::mexp (const LINT& e, const LINT& m );
and
LINT& LINT::mexp (USHORT e, const LINT& m);
for exponentiation, an operation for which C++, alas, offers no operator. The
functions mexp() were constructed in such a way that the functions used are,
according to the type of the operands, the C functions mexpk_l() , mexpkm_l() ,
umexp_l() ,and umexpm_l() , optimized for this purpose (with the corresponding
arithmetic friend functions we are likewise dealing with the exponentiation
functions wmexp_l() and wmexpm_l() with USHORT base).
Function:
Modular exponentiation with automatic use of
Montgomery exponentiation if the modulus is odd.
const LINT&
LINT::mexp (const LINT& e, const LINT& m);
Syntax:
Input:
implicit argument (base)
e (exponent)
m (modulus)
Return:
pointer to the remainder
Example:
a.mexp (e, m);
const LINT& LINT::mexp (const LINT& e, const LINT& m)
{
int error;
if (status == E_LINT_INV) panic (E_LINT_VAL, "mexp", 0, __LINE__);
 
Search WWH ::




Custom Search