Datasheet

2010 Microchip Technology Inc. DS39935C-page 131
ENC424J600/624J600
To encrypt a block using ECB 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 plaintext message to TEXTA at 7C20h.
4. Set AESST (ECON1<11>) to initiate the
encryption.
5. Wait for the hardware to clear AESST.
6. Read the ciphertext message from TEXTA at
7C20h.
7. Repeat steps 3 through 6 for subsequent blocks.
To decrypt a block using ECB mode:
1. Initialize the decryption key as described in
Section 15.3.1 “Key Support”.
2. Set AESOP<1:0> to ‘
10’.
3. Copy the ciphertext message to TEXTA at
7C20h.
4. Set AESST to initiate the decryption.
5. Wait for the hardware to clear AESST.
6. Read the plaintext message from TEXTA at
7C20h.
7. Repeat steps 3 through 6 for subsequent blocks.
The context for ECB mode includes only the encryption
key. No additional context data needs to be saved.
15.3.3.2 Cipher Block Chaining Mode (CBC)
The Cipher Block Chaining mode uses feedback from
the encryption output to further obscure the ciphertext
data. During encryption, the first block uses an Initial-
ization Vector (IV) which is XORed with the plaintext
data. The output of this XOR function is then encrypted
using the AES key and this ciphertext becomes the IV
for the next block. Under CBC mode, each subsequent
block depends on the previous block. Therefore,
identical subsequent plaintext blocks use a different IV,
and therefore, yield different ciphertext blocks.
Figure 15-2 shows the use of CBC mode for encryption
and decryption.
FIGURE 15-2: CBC ENCRYPTION AND DECRYPTION
ENCRYPTER
DATA KEY
Plaintext
0
Key
ENCRYPTER
Ciphertext
0
Ciphertext
1
IV
Ciphertext
0
Ciphertext
1
DECRYPTER
DATAKEY
DECRYPTER
DATAKEY
Key
Key
Plaintext
1
Plaintext
0
IV
ENCRYPTION
DECRYPTION
DATA KEY
Plaintext
0
Key