EpiRootkit
By STDBOOL
Loading...
Searching...
No Matches
crypto.h
Go to the documentation of this file.
1#ifndef CRYPTO_H
2#define CRYPTO_H
3
4// AES encryption parameters
5// Key must be 16 bytes (128 bits) for AES-128
6// IV is used to initialize the cipher and must be 16 bytes as well
7#define AES_BLOCK_SIZE 16
8
9#define SHA256_DIGEST_SIZE 32
10
11int encrypt_buffer(const char *in, size_t in_len, // Encrypt a buffer using AES
12 char **out, size_t *out_len);
13int decrypt_buffer(const char *in, size_t in_len, // Decrypt a buffer using AES
14 char **out, size_t *out_len);
15
16int hash_string(const char *input, u8 *digest); // Hash a string using SHA-256
17bool are_hash_equals(const u8 *h1, const u8 *h2); // Compare two hashes
18void hash_to_str(const u8 *digest, char *output); // Convert a hash to a string representation
19
20
21#endif /* CRYPTO_H */
bool are_hash_equals(const u8 *h1, const u8 *h2)
Compares two SHA-256 hashes for equality.
Definition hash.c:60
int hash_string(const char *input, u8 *digest)
Hashes a string using SHA-256.
Definition hash.c:17
int encrypt_buffer(const char *in, size_t in_len, char **out, size_t *out_len)
Encrypts a buffer using AES-128 in CBC mode.
Definition aes.c:322
int decrypt_buffer(const char *in, size_t in_len, char **out, size_t *out_len)
Decrypts a buffer using AES-128 in CBC mode.
Definition aes.c:335
void hash_to_str(const u8 *digest, char *output)
Converts a SHA-256 hash to a hexadecimal string.
Definition hash.c:74