-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblobpak.h
More file actions
58 lines (50 loc) · 1.88 KB
/
blobpak.h
File metadata and controls
58 lines (50 loc) · 1.88 KB
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
55
56
57
58
/*
* Copyright (C) 2022-2024 skgleba
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#ifndef __BLOBPAK_H__
#define __BLOBPAK_H__
#define ENC_ENTRY_ID_SIZE 20 // SHA-1 hash size
#define DEC_ENTRY_ID_SIZE 128 // Truncated name size
#define STDIN_BUF_INCR 0x200 // Block size for reading from stdin
#define RANDOM_BLOCK_MAX_SIZE 2048 // Maximum size of a random padding block
#define VER_STRING "blobpak v1.3 by skgleba"
/**
* @brief Structure representing an entry in the blobpak.
*/
typedef struct entry_t {
uint8_t entryID[ENC_ENTRY_ID_SIZE]; /**< The (hashed) ID of the entry. */
uint32_t enc_size; /**< The (hashed) size of the entry. */
uint64_t noise64; /**< The noise value used for hashing. */
} __attribute__((packed)) entry_t;
/**
* @brief Encrypted structure representing an entry in the blobpak.
*
* @note The enc_size and noise64 fields must be at the same offset as in the entry_t structure.
* @note The size of this structure must be the same as the entry_t structure.
*/
typedef struct enc_entry_t {
uint8_t iv[16]; /**< The IV used for encryption. */
union {
uint8_t toc_enc[16];
struct {
uint32_t hash_partial; /**< partial of the hashed name, used for validation. */
uint32_t enc_size; /**< The (hashed) size of the entry. */
uint64_t noise64; /**< The noise value used for hashing. */
} toc_dec;
};
} __attribute__((packed)) enc_entry_t;
/**
* @brief Structure for multithreaded find_entry.
*/
typedef struct find_entry_args_t {
char *name;
char *name_salt;
void *blobpak;
uint32_t pak_size;
uint32_t ret;
} __attribute__((packed)) find_entry_args_t;
enum OP_MODES { OUPUT_FILE, OUPUT_STDOUT, OUPUT_NICE, IPUT_FILE, IPUT_STDIN };
#endif