Skip to content

Commit 2a3f2e8

Browse files
committed
Add opmode.h description.
1 parent 29c75c0 commit 2a3f2e8

1 file changed

Lines changed: 34 additions & 7 deletions

File tree

README.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
# AES-Lib
22

3-
This repository contains a C library for the Advanced Encryption Standard (AES) algorithm. It supports key sizes of 128, 192, and 256 bits.
3+
This repository contains a C library for the Advanced Encryption Standard (AES) algorithm with several operation modes of block ciphers. Supports key sizes of 128, 192, and 256 bits.
44

55
The primary purpose of this library is educational. The computation has been verified to be correct, but **no security measures have been implemented**. Therefore, it is advised **not to use this library directly for sensitive applications**.
66

77
## Features
88

99
- Supports AES-128, AES-192, and AES-256.
10-
- Programmed according to the NIST-197 standard process. No special tricks are used, keeping the code intuitively readable.
10+
- Programmed and tested according to the NIST-197 and NIST Special Publication 800-38A standard documents.
1111
- Includes two implementations: S-Box and lookup-table (T-Table/T-Box). The lookup tables are generated on-the-fly.
12+
- Operation modes of the block cipher, such as ECB, CBC. Other modes to be implemented later on.
1213

1314
## Usage
1415

15-
A test case is programmed in "test.c".
16+
### test.h
17+
18+
Test cases with test vectors from NIST documents are programmed in "test.c".
19+
20+
### aes.h
1621

1722
The encrypting and decrypting functions of the two implementations use the same parameters:
1823

1924
```c
20-
void SetKey(uint8_t key[], uint8_t size); //Assign cipher key and its size
21-
void SetLUTMode(void); //Enter LUT cipher mode
25+
void SetKey(uint8_t key[], uint8_t size); //Assign cipher key and its size (Must be called before en/decryptions)
26+
void SetLUTMode(void); //Enter LUT cipher mode (S-Box mode in default when not calling this function)
2227
void QuitLUTMode(void); //Quit LUT cipher mode
2328
```
2429
```c
@@ -29,7 +34,7 @@ void EncryptLUT(uint8_t plaintext[16], uint8_t ciphertext[16]);
2934
void DecryptLUT(uint8_t ciphertext[16], uint8_t plaintext[16]);
3035
```
3136

32-
Modify **the size of key[]** and **Nr** to use different key lengths in AES. This library does not perform any input validation. Please ensure that the input data and key sizes are appropriate for the selected AES variant (128, 192, or 256 bits).
37+
Assign the **key[]** and its proper **size (byte)** to use different key lengths in AES. This library does not perform any input validation. Please ensure that the input data and key sizes are appropriate for the selected AES variant (128, 192, or 256 bits).
3338

3439
| Variant | Key Length | Rounds (Nr) |
3540
| :-----: | :-----------------: | :---------: |
@@ -44,6 +49,28 @@ void PrintState(uint8_t state[4][4]);
4449
void PrintKeyList(uint8_t **keyarray);
4550
void PrintLUT(uint8_t ***table);
4651
```
52+
### opmode.h
53+
54+
Supports operation modes of block ciphers such as ECB, CBC for binary file I/O. Tested with NIST Special Publication 800-38A example vectors. Other modes will be implemented later on.
55+
56+
```c
57+
void EncryptECB(char *infilename, char *outfilename);
58+
void DecryptECB(char *infilename, char *outfilename);
59+
60+
void SetIV(uint8_t *iv); //Must be called before en/decryptions
61+
void EncryptCBC(char *infilename, char *outfilename);
62+
void DecryptCBC(char *infilename, char *outfilename);
63+
64+
//To be done
65+
void EncryptCFB(char *infilename, char *outfilename);
66+
void DecryptCFB(char *infilename, char *outfilename);
67+
```
68+
69+
S-Box/LUT are also supported when calling these functions above. You can call SetLUTMode() or QuitLUTMode() before en/decryptions.
70+
71+
Padding pattern is implemented with **PKCS#7** standard.
72+
4773
## To-do
48-
- Implement modes of operation for block ciphers such as ECB, CBC, CFB, etc.
74+
75+
- Implement other modes of operation for block ciphers such as CFB, OFB, etc.
4976
- Implement AES-CMAC.

0 commit comments

Comments
 (0)