How to Read Encrypted Books and Encrypt Strings Using Custom Key on Midbar (Teensy 4.1) V3.0

by Northstrix in Circuits > Microcontrollers

141 Views, 1 Favorites, 0 Comments

How to Read Encrypted Books and Encrypt Strings Using Custom Key on Midbar (Teensy 4.1) V3.0

IMG_20240109_114751.jpg

This tutorial is an accessory to the "DIY Hardware Data Vault With Teensy 4.1 (Midbar (Teensy 4.1) V3.0)"

Before reading this tutorial, ensure that you've completed the aforementioned tutorial at least to step 15.

Supplies

Encryption Algorithm

Serpent in CBC.png

Both books and plaintexts encrypted with the custom key are passed through the Serpent in the CBC mode encryption algorithm.

The only difference between the books and the plaintexts encrypted with the custom key is that the encryption algorithm also attaches the 32-bit tag in front of a plaintext before passing it to the encryption algorithm.

Get Encryption Key

4.png

Before you can encrypt a book you need to get an encryption key. To do so:

  1. Open the Serial Terminal (because the book encryption key is printed to it);
  2. Select the "Other Options" line in the main menu;
  3. Press the "Enter" key on the USB keyboard;
  4. Select the "Read Encrypted Book" line in the main menu;
  5. Press the "Enter" key on the USB keyboard;
  6. Select the "Print Encryption Key" line in the main menu;
  7. Press the "Enter" key on the USB keyboard.

Get the Book in the Text Format

1.png
2.png
3.png

Find a book you want to encrypt to begin with. There are several websites where you can find it, such as Project Gutenberg (note that this is not a promotion for the website, I just find it to be a convenient option). Next, you will need to obtain the book in either UTF-8 or ASCII encoding. Once you have done that, simply copy the entire text of the book (use Ctrl + A for this) and paste it into a new text document (use Ctrl + V). Name the file however you want and save it.

Encrypt the Book

1.png
2.png
3.png
4.png
5.png

To encrypt a book:

  1. Launch the "Book Encrypter For Midbar Teensy 4.1 V3.0.exe" executable file from the "Teensy 4.1 Version\V3.0\Book Encrypter For Midbar Teensy 4.1 V3.0\Book Encrypter For Midbar Teensy 4.1 V3.0\bin\Debug\net6.0-windows" folder;
  2. Click on "File" and then select "Encrypt Book;"
  3. Paste the encryption key to the textbox in the pop-up entry;
  4. Press the "OK" button;
  5. Navigate to the folder where the book you want to encrypt is located, select the book, and then press the "Open" button;
  6. Wait for the encryption process to complete;
  7. In the pop-up window, choose where to save the encrypted book, and press the "Save" button to actually save it.

Move the Encrypted Book to the SD Card

mb.png

Now move the encrypted book(s) to the "books" folder on an SD card.

Make sure that the SD card is formatted to the "FAT32" file system!

Read Encrypted Book

IMG_20240109_114720.jpg
IMG_20240109_114729.jpg
IMG_20240109_114737.jpg
IMG_20240109_114744.jpg
IMG_20240109_114751.jpg
IMG_20240109_114811.jpg

To read an encrypted book:

  1. Select the "Other Options" line in the main menu;
  2. Press the "Enter" key on the USB keyboard;
  3. Select the "Read Encrypted Book" line in the main menu;
  4. Press the "Enter" key on the USB keyboard;
  5. Select the "Read Book" line in the main menu;
  6. Press the "Enter" key on the USB keyboard;
  7. Select the book you'd like to read by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  8. Press the "Enter" key on the USB keyboard;
  9. Press the "Esc" key on the USB keyboard to close the book and return to the main menu, press any other key on the USB keyboard to get to the next page.

Encrypt String With Custom Key

IMG_20240109_114924.jpg
IMG_20240109_114933.jpg
IMG_20240109_114940.jpg
IMG_20240109_114947.jpg
IMG_20240109_115027.jpg
IMG_20240109_115053.jpg
cphrtxt.png

To encrypt string with a custom key:

  1. Open the Serial Terminal (because the ciphertext is printed to it);
  2. Select the "Other Options" line in the main menu;
  3. Press the "Enter" key on the USB keyboard;
  4. Select the "Custom Key Encryption" line in the main menu;
  5. Press the "Enter" key on the USB keyboard;
  6. Select the "Encrypt String" line;
  7. Choose the input source;
  8. Press the "Enter" key on the USB keyboard;
  9. Enter the key on the USB keyboard;
  10. Press the "Enter" key on the USB keyboard;
  11. Depending on the chosen input source, either enter the text you'd like to encrypt on the USB keyboard or paste it to the Serial Terminal;
  12. Depending on the chosen input source, either press the "Enter" key on the USB keyboard or press the "Send" button in the Serial Terminal.

Decrypt String With Custom Key

IMG_20240109_115153.jpg
IMG_20240109_115159.jpg
IMG_20240109_115205.jpg
IMG_20240109_115211.jpg
IMG_20240109_115246.jpg
IMG_20240109_115227.jpg
IMG_20240109_115259.jpg

To decrypt string with a custom key:

  1. Open the Serial Terminal (because you'll need to paste the ciphertext to it);
  2. Select the "Other Options" line in the main menu;
  3. Press the "Enter" key on the USB keyboard;
  4. Select the "Custom Key Encryption" line in the main menu;
  5. Press the "Enter" key on the USB keyboard;
  6. Select the "Decrypt String" line;
  7. Choose where to display the decrypted string;
  8. Press the "Enter" key on the USB keyboard;
  9. Enter the key on the USB keyboard;
  10. Press the "Enter" key on the USB keyboard;
  11. Paste the ciphertext to the Serial Terminal;
  12. Press the "Send" button in the Serial Terminal.