From 6e0a7e88af4b6169433400e46de5db4349321dd6 Mon Sep 17 00:00:00 2001 From: Zola Gonano Date: Fri, 19 Apr 2024 12:05:29 +0000 Subject: [PATCH] Add Formats section and encrypted files header documents --- docs/Formats/encrypted-files-header.md | 62 ++++++++++++++++++++++++++ docs/Formats/formats.md | 10 +++++ docs/concepts/concepts.md | 6 ++- 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 docs/Formats/encrypted-files-header.md create mode 100644 docs/Formats/formats.md diff --git a/docs/Formats/encrypted-files-header.md b/docs/Formats/encrypted-files-header.md new file mode 100644 index 0000000..356e8e8 --- /dev/null +++ b/docs/Formats/encrypted-files-header.md @@ -0,0 +1,62 @@ +--- +title: Header Format for Encrypted Files +layout: default +parent: Formats +--- + +## Header Format for Encrypted Files + +When Sare encrypts a file, it adds a header at the beginning to keep everything organized. Here's how it looks: + +### Magic Bytes + +At the very start, there are some special letters that show it's a Sare-encrypted file. + +- **Magic Bytes:** `CRYPTOPIA` + +### Header Structure + +The header has a few parts: + +1. **Version (4 bytes):** This is just a number that shows which version of encryption Sare used. + +2. **Metadata Length (8 bytes):** This number tells how long the metadata section is. + +3. **Metadata (variable length):** This part has info about how the file was encrypted. It includes stuff like what method was used to hide the key and if there's a signature. + +4. **Signature Length (8 bytes):** If there's a signature, this number says how long it is. If there's no signature, it's just 0. + +5. **Signature (variable length):** If there's a signature, it's right here. It's like a stamp that proves the file is real. + +### Encoding and Decoding + +#### Encoding + +To put together the header: + +1. Start with the magic bytes `CRYPTOPIA`. +2. Add the version number. +3. Write down how long the metadata part is. +4. Write the metadata. +5. Say how long the signature part is (if there's one). +6. Write the signature. + +#### Decoding + +To understand the header: + +1. Check if it starts with `CRYPTOPIA`. +2. Look at the version number. +3. See how long the metadata part is, and read it. +4. Check if there's a signature and read it if there is. + +### Schematics + +Here's a simple schematic to visualize the structure of the header: + +``` ++-----------------+--------+-------------------------------------------+--------+-------------------------------------------+ +| Magic Bytes | Version| Metadata Length | Metadata | Sig Len| Signature | +| (CRYPTOPIA) | (4 bytes) | (8 bytes) | | (8 bytes) | | ++-----------------+--------+-------------------------------------------+--------+-------------------------------------------+ +``` diff --git a/docs/Formats/formats.md b/docs/Formats/formats.md new file mode 100644 index 0000000..5ee795c --- /dev/null +++ b/docs/Formats/formats.md @@ -0,0 +1,10 @@ +--- +layout: default +title: Formats +nav_order: 3 +has_children: true +--- + +## Formats + +This section provides an overview of the various formats utilized within the project for encryption, metadata, and other relevant data structures. diff --git a/docs/concepts/concepts.md b/docs/concepts/concepts.md index 5792ce3..ad14d70 100644 --- a/docs/concepts/concepts.md +++ b/docs/concepts/concepts.md @@ -1,8 +1,10 @@ --- layout: default -title: Concepts +title: Concepts nav_order: 2 has_children: true --- -Hello +## Concepts + +The "Concepts" section provides an introduction to the fundamental ideas and theories guiding the development and implementation of the encryption system.