Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sponsored by ARK] Encryption #24489

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ src/systemcmds/topic_listener/listener_generated.cpp

# colcon
log/
keys/
172 changes: 0 additions & 172 deletions Tools/cryptotools.py

This file was deleted.

91 changes: 0 additions & 91 deletions Tools/decrypt_ulog.py

This file was deleted.

111 changes: 111 additions & 0 deletions Tools/log_encryption/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# PX4 Log Encryption Tools

Tools for generating encryption keys, building PX4 firmware with encrypted logs, downloading logs, and decrypting them.

## Usage

1. **Get the board file**:
To be able to use these methode you need to create your own board file in your board folder. You can just copy one that is used below.
```bash
encrypted_logs.px4board
```
Then using menuconfig you should Enable the settings: Blake2s hash algorithm, Entropy pool and strong random number generator, and Use interrupts to feed timing randomness to entropy pool.
Once you have generated the keys make sure you add them to the boardconfig.

```bash
make <your_board_name>_encrypted_logs menuconfig
```

2. **Generate Keys**:
```bash
cd PX4-Autopilot/Tools/log_encryption
python3 generate_keys.py
```

Make sure you have the right key in your board file
```CONFIG_PUBLIC_KEY1="../../../keys/public/public_key.pub"```

3. **Build Firmware**:
```bash
cd PX4-Autopilot

AND

make <your_board_name>_encrypted_logs

OR

make ark_fmu-v6x_encrypted_logs

OR

make ark_fpv_encrypted_logs

OR

make ark_pi6x_encrypted_logs

AND

Upload the custom fw on your flight controller and record couple of logs
```

4. **Download Logs**:
```bash
cd PX4-Autopilot/Tools/log_encryption

python3 download_logs.py serial:/dev/ttyACM0:57600

OR

python3 download_logs.py udp:0.0.0.0:14550
```

Addresses might need to be adjusted

5. **Decrypt Logs**:
The easiest way to run this is to have your private key and encrypted logs in te following folders respectively:
```bash
PX4-Autopilot/keys/private
PX4-Autopilot/logs/encrypted
```
Then run:
```bash
cd PX4-Autopilot/Tools/log_encryption

AND
# Uses default key + default folder
python3 decrypt_logs.py

OR
# Uses custom key
python3 decrypt_logs.py path/to/private_key.pem

OR
# Uses custom key + specific file
python3 decrypt_logs.py path/to/private_key.pem path/to/custom_log.ulge

OR
# Uses custom key + specific folder
python3 decrypt_logs.py path/to/private_key.pem path/to/custom_log_folder

OR
# Uses default key + specific file
python3 decrypt_logs.py "" path/to/custom_log.ulge

OR
# Uses default key + specific folder
python3 decrypt_logs.py "" path/to/custom_log_folder
```

Your decrypted logs can be found in:
```bash
PX4-Autopilot/logs/decrypted
```
Otherwise

## Directory Structure

- **`keys/`**: Encryption keys.
- **`logs/encrypted/`**: Downloaded encrypted logs.
- **`logs/decrypted/`**: Decrypted logs.
Loading
Loading