any suggestions.
;TODO: run spell check
Code:
class cArchiveSystem
Objective:
develop a system to combine multible files into a single file and give the user verious options including
compression and encryption.
Overview:
First started this project to provide a storage system type api. truefully i was board.
This class is that system. I'm re-writing most of the code to make it more manageable and 64bit compatable
also trying to figure a writing style which is easy to understand.
ARCHIVE FILES - Each archive contains 2 files. "*.idx" and "*.arc"
*.idx - archive index. this file contains a list of IDX_ENTRYs. including but not limited
to the file name, file length, and offset in the *.arc file.
a checksum of itself and its matching arc file.
*.arc - archive file. this file contains the raw data of all files contained in the archive
For max security one file is worthless without the other. Only when both files are avaible can the archive
be opened.
The system run in 1 of 3 modes.
Note: when i talk about pad/padded i mean a random number of random bytes.
SECURITY MODS
mod 1: no security.
The idx file can be opened in notepad and plaintext, such as file names, read.
Files are stored on the *.arc file one after another.
mod 2: minimum security.
1. The idx file is encripted with a user provided key.
2. The idx file is padded at the start.
3. The arc file is encripted with the same user key as above.
4. The arc file is padded at both the start and end of file.
5. Each file stored in the arc file is seperated using a pad.
mod 3: maximum security.
1-4 of mod 2.
5. Each file stored in the arc file is encrypted with a random key stored in the idx file.
A different key per file.
6. Each --encrypted file-- is broken into user defined size blocks. the last 4 bytes of each
block contain the offset to the next block. The blocks from different files are mixed at
random.
7. Each block is sepreated by a pad of random bytes.
Specifics:
IDX file format.
[1pad][2"\nidx"][3length][4IDX_ENTRYs][5checksum_this][6checksum_arc][7extra data][8pad]
1. a random number of random bits not containing "\nidx".
This pad my not exist in a given archive. see security mods
This pad should be no longer that 100 bytes. -subject to change
2. a static head required to id the file type and verify a correct key.
3. number of IDX_ENTRYs in the file.
4. IDX_ENTRYs
5. some type of checksum/hash/message digest of the idx file.
6. checksum of the arc file for this archive.
7. extra data, keys and anything else I need.
8. same as 1.
NOTE: 5. fill a buffer with 3,4,6,7,8. hash that value.
6 is the hash of the file before encryption.
7.extra data [1length][2data]...
1. length of data in bytes. unsigned char length. 1-256
2. data
ARC file format.
[pad][1"arc"][2pad][3FILE_BLOCK][pad] [FILE_BLOCK][pad]... [pad][4checksum]
[pad] - randum number of random bytes
1. static header
2. a random pad of random bytes. the first 2 high order bits, flag which
security mode the file is saved in.
unsigned char x;
x >>= 6;
3. raw file data. the last 4 bytes are the offset to the next block for this file.
block size is user defined and stored in the idx file.
4. a checksum of the file before encryption.