Datasheet

ENC424J600/624J600
DS39935C-page 134 2010 Microchip Technology Inc.
To encrypt a block using OFB mode:
1. Load the encryption key as described in
Section 15.3.1 “Key Support”.
2. Set AESOP<1:0> (ECON1<10:9>) to ‘
00’.
3. Copy the Initialization Value (IV) to TEXTA at
7C20h.
4. Set AESST (ECON1<11>) to initiate the
encryption.
5. Copy the plaintext message to TEXTB at
7C30h.
6. Wait for the hardware to clear AESST.
7. Read the ciphertext message from XOROUT at
7C40h.
8. Repeat steps 4 through 7 for subsequent blocks.
The encryption output from the previous block
automatically becomes the IV for the following
block.
To decrypt a block using OFB mode:
1. Load the encryption key as described in
Section 15.3.1 “Key Support”. Note that this
mode does not make use of a decryption key.
2. Set AESOP<1:0> to ‘
00’.
3. Copy the Initialization Value (IV) to TEXTA at
7C20h.
4. Set AESST to initiate the encryption.
5. Copy the ciphertext message to TEXTB at
7C30h.
6. Wait for the hardware to clear AESST.
7. Read the plaintext message from XOROUT at
7C40h.
8. Repeat steps 4 through 7 for subsequent blocks.
The context for OFB mode consists of both the AES
encryption key and the encryption output from the most
recent block. Save the encryption block output from
TEXTA at 7C20h to be used as the IV when resuming
the operation for additional blocks.
15.3.3.5 Counter Mode (CTR)
Counter mode is not directly supported by hardware,
but can be implemented with software assistance. In
CTR mode, a counter is used as the input to the
encryption block. The encrypted output is then XORed
with the plaintext to yield the ciphertext, or vice versa.
The counter does not necessarily need to be a true
counter; any practically non-repeating function will
suffice. When using CTR mode, the application must
load the counter value before each block.
Since each block depends on the counter value, iden-
tical subsequent plaintext blocks will yield different
ciphertext blocks. Whether or not these blocks are
independent will depend on the selected counter
function. Figure 15-5 shows the use of CTR mode for
encryption and decryption.
FIGURE 15-5: CTR ENCRYPTION AND DECRYPTION
ENCRYPTER
DATA KEY
ENCRYPTER
DATA KEY
Key Key
Plaintext
0
Plaintext
1
Ciphertext
0
Ciphertext
1
CTR
0
CTR
1
ENCRYPTER
DATA KEY
ENCRYPTER
DATA KEY
Key
Key
CTR
0
CTR
1
Ciphertext
0
Ciphertext
1
Plaintext
0
Plaintext
1
ENCRYPTION
DECRYPTION