Datasheet

ENC424J600/624J600
DS39935C-page 126 2010 Microchip Technology Inc.
To perform a modular exponentiation:
1. Copy the values for
X, E and M into the 24-Kbyte
SRAM.
2. Set CRYPTEN (EIR<15>) to turn on the Modular
Exponentiation module.
3. Use the DMA to transfer
E to addresses, 7800h
through 783Fh (512-bit), 785F (768-bit) or
787Fh (1024-bit). If the value is shorter than the
chosen operand length, left-pad the value with
zeros.
4. Use the DMA to transfer the value of
X to
addresses, 7880h through 78BFh (512-bit),
78DF (768-bit) or 78FFh (1024-bit). If the value
is shorter than the chosen operand length,
left-pad the value with zeros.
5. Use the DMA to transfer
M to addresses, 7900h
through 793Fh (512-bit), 795F (768-bit) or
797Fh (1024-bit). The value must not be shorter
than the chosen operand length.
6. Set the value of the MODLEN<1:0>
(ECON2<3:2>) bits to indicate the size of the
operation to be completed.
7. Set MODEXST (ECON1<15> =
1) to initiate the
calculation.
8. Wait for the hardware to clear MODEXST to
indicate that the operation has completed. The
hardware will also set MODEXIF (EIR<14>) and
generate an interrupt, if enabled.
9. Use the DMA to transfer the result
Y from
addresses, 7880h through 78BFh (512-bit), 78DF
(768-bit) or 78FFh (1024-bit). Note that this result
will be in big-endian format, and if necessary, the
result will be left-padded with zeros.
10. If the AES module is not in use, save power by
clearing CRYPTEN. Use a Bit Field Clear SPI
instruction or write to the EIRCLR register to
clear this bit without corrupting any interrupt
flags.
Assuming the operating length remains constant, the
exponent
E and modulus M are retained within the
Modular Exponentiation engine and can be reused for
future operations without being reloaded.
15.1.1 MODULAR EXPONENTIATION
PERFORMANCE
The time required to compute the Modular
Exponentiation result depends on three factors:
the “active” length of the exponent
E.
the density of ‘
1’ bits in the exponent E.
the length of the operands
The time required for typical operations is summarized
in Table 15-1.
TABLE 15-1: TYPICAL MODULAR
EXPONENTIATION
PERFORMANCE
15.2 MD5 and SHA-1 Hashing
The MD5 and SHA-1 hash engines implement one-way
message digest functions. These functions take an
unlimited amount of data and produce a digest of either
128 or 160 bits (for MD5 and SHA-1, respectively). They
are frequently used for verification and integrity
purposes.
Both hashing engines share the same resources, so
only one operation may be active at a time. The current
operation is selected by the SHA1MD5 (ECON2<12>)
bit. This bit should be configured before using the
module. Context switching is supported by the engine
for applications that require the capability to switch
between two or more hashing operations.
The HASHOP (ECON1<13>) bit configures the initial-
ization values. When starting a new hash calculation,
clear this bit to reset the initialization values. Using this
bit to load a previously saved context is described in
Section 15.2.3 “Context Switching”. The value of the
HASHOP bit may not be changed once the HASHEN
bit is set, so it must be configured first.
Usage
Operands
(M/E)
Time
DH 768/180 50.2 ms
DH 1024/180 89.0 ms
RSA 512/512 63.7 ms
RSA 768/768 214.0 ms
RSA 1024/1024 506.2 ms