forked from UMD-CS-STICs/389Rfall2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrypto.h
32 lines (28 loc) · 1.05 KB
/
crypto.h
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
#include <stdlib.h>
struct cipher_params {
char key[16];
char key_hash[16];
char iv[16];
char *msg;
size_t len;
};
/**
* Dynamically allocates and returns an md5 hash of the provided plaintext with
* size message_len. Size of return buffer will always be 128 bits (output
* size of md5sum).
*/
unsigned char *md5_hash(const unsigned char *plaintext, size_t message_len);
/**
* Dynamically allocates and returns the result of aes128cbc encryption on a
* plaintext with provided key and iv. Size of ciphertext is returned since it
* will be dependent on the size of the plaintext. Resultant ciphertext is not
* null-terminated.
*/
int aes128_encrypt(struct cipher_params *params, unsigned char **ciphertext);
/**
* Dynamically allocates and returns the result of aes128cbc decryption on a
* ciphertext with provided key and iv. Size of plaintext is returned since it
* will be dependent on the size of the ciphertext. Resultant plaintext is not
* null-terminated.
*/
int aes128_decrypt(struct cipher_params *params, unsigned char **plaintext);