Skip to content

Commit

Permalink
Add Formats section and encrypted files header documents
Browse files Browse the repository at this point in the history
  • Loading branch information
zolagonano committed Apr 19, 2024
1 parent a7cbb9e commit 6e0a7e8
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
62 changes: 62 additions & 0 deletions docs/Formats/encrypted-files-header.md
Original file line number Diff line number Diff line change
@@ -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) | |
+-----------------+--------+-------------------------------------------+--------+-------------------------------------------+
```
10 changes: 10 additions & 0 deletions docs/Formats/formats.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 4 additions & 2 deletions docs/concepts/concepts.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 6e0a7e8

Please sign in to comment.