-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrypto.h
More file actions
29 lines (24 loc) · 882 Bytes
/
crypto.h
File metadata and controls
29 lines (24 loc) · 882 Bytes
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
#ifndef CRYPTO_H
#define CRYPTO_H
#include <stddef.h>
#include <stdint.h>
#define SALT_LEN 16
#define NONCE_LEN 12
#define KEY_LEN 32
#define GCM_TAG_LEN 16
#define HEADER_SIZE 48 /* 16 + 12 + 4 + 8 + 8 */
#define DEFAULT_CHUNK_SIZE (1024 * 1024)
/*
* Encrypt src → dst using AES-256-GCM / Argon2id.
* File format: [salt:16][base_nonce:12][chunk_size:4 BE][file_size:8 BE][num_chunks:8 BE]
* followed by chunks, each: [ciphertext_len:4 BE][ciphertext+tag]
*/
int encrypt_file(const char *src, const char *dst,
const uint8_t *password, size_t pass_len, int chunk_size);
/*
* Decrypt src → dst.
* Wrong-password: silently produces a deterministic decoy output.
*/
int decrypt_file(const char *src, const char *dst,
const uint8_t *password, size_t pass_len);
#endif /* CRYPTO_H */