-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaes.txt
54 lines (41 loc) · 2.33 KB
/
aes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
To perform Rijndael encryption or decryption, first set up a buffer for encryption or decryption:
nrounds = rijndaelSetupEncrypt(rk, key, keybits); for encryption
nrounds = rijndaelSetupDecrypt(rk, key, keybits); for decryption
unsigned long *rk; pointer to encryption/decryption buffer,
required space:
keybits 32-bit words required
128 44
192 52
256 60
const unsigned char *key; key, where length in bytes is:
keybits number of bytes
128 16
192 24
256 32
int keybits; number of bits in key, must be 128, 192 or
256
int nrounds; number of rounds:
keybits nrounds
128 10
192 12
256 14
The package provides three macros to convert the keybits value to closely related values:
KEYLENGTH(keybits) number of bytes in key[] array
RKLENGTH(keybits) number of 32-bit words in rk[] array
NROUNDS(keybits) number of rounds
Encryption and decryption are performed, a block at a time, with the following two functions:
rijndaelEncrypt(rk, nrounds, plaintext, ciphertext);
rijndaelDecrypt(rk, nrounds, ciphertext, plaintext);
const unsigned long *rk;
pointer to encryption/decryption buffer which
was filled by rijndaelSetupEncrypt() or
rijndaelSetupDecrypt()
int nrounds; number of rounds, as computed by
rijndaelSetupEncrypt(),
rijndaelSetupDecrypt() or NROUNDS
[const] unsigned char plaintext[16];
[const] unsigned char ciphertext[16];
pointers to 16-byte buffers to be encrypted
or decrypted; the source buffer has a const
qualifier
To satisfy the truly paranoid user, it is probably advisable to clear and delete the buffers after the process is finished.