Midbar (Teensy 4.1 Version) V2.0

by Northstrix in Circuits > Microcontrollers

891 Views, 3 Favorites, 0 Comments

Midbar (Teensy 4.1 Version) V2.0

IMG_20230719_184125.jpg

Advancements in cryptanalysis and hacking techniques are continuing to reduce the cost of unauthorized access to your data, making it easier and more attractive for different parties to get it.

I won't get into details about the motivation of each party and the goals they're trying to achieve by obtaining your data. Instead, I would like to focus on the solution to that problem.

In my opinion, the only way to keep your data private is to raise the cost of unauthorized access to it as high as possible. The best-case scenario is to raise the costs of unauthorized access to your data so high that it would significantly outweigh any potential reward for any party.

To raise the cost of unauthorized access to your data - I've developed Midbar (which later on "evolved" into a multi-user Cipherbox, and then it kinda turned back into Midbar because I realized that a "multi-user Midbar" is superfluous and not as stable as a single-user one).


Midbar (מדבר) is a Hebrew word that means "pasture," "uninhabited land," "wilderness," "large tracts of wilderness (around cities)," and "desert." I had two reasons for choosing the word Midbar as the name of this project. First - while working on my previous projects, I noticed that the so-called "device that keeps your personal data secure in an encrypted form" market is pretty much a "desert around the oasis of the password manager market." Second - I couldn't find a better word to describe this project. At first, I wanted to call it a "Password Vault," but it's more than that. So, I decided to call it Midbar.

You can also read this tutorial on Medium and Hackster.

Supplies

IMG_20230719_185132.jpg
  • Teensy 4.1 x1
  • 2.4 Inch TFT LCD with ILI9341 x1
  • USB Keyboard x1
  • USB 2.0 Port (I took it from the panel expansion bracket) x1
  • Micro SD Card x1
  • Mifare RC522 RFID Reader x1
  • RFID cards x4
  • EC11 Rotary Encoder x1
  • 4.7k resistors x7
  • 100nf capacitors x2
  • Buttons x2

How It Came to Be

When I got my hands on the Teensy 4.1 Development Board. I've discovered that Teensy 4.1 handles a USB keyboard quite well, even if a keyboard is connected via a USB hub. Additionally, this board is compatible with lots of handy libraries and boasts a powerful 600 Mhz CPU. Amazed by that, I started the development of the Midbar (Teensy 4.1 Version).

After releasing the version of Midbar mentioned above and receiving feedback on it, I spent some time considering the possible improvements. Eventually, I came to the conclusion that the Midbar (Teensy 4.1 Version) V2.0 should be able to store data in the EEPROM, have the ability to back up and restore the EEPROM data, and function as a USB keyboard when necessary. I also decided to make this version of Midbar RFID-lockable (RFID cards + master password to be exact) like, for example, Midbar (STM32F401CCU6 + Arduino Uno Version)Midbar (ESP32 Version) V4.0, and Midbar (Raspberry Pi Pico Version) V2.0.

3DES + AES + Blowfish + Serpent Encryption Algorithm in CBC Mode

3des+aes+blowfish+serpent_in_cbc.png

The "3DES + AES + Blowfish + Serpent" encryption algorithm in cipher block chaining mode first appeared in the Midbar V2.5. And since then has been utilized by the Midbar (Raspberry Pi Pico Version)Midbar V3.0Midbar V4.0KhadashPay V2.0Midbar (Raspberry Pi Pico Version) V2.0KhadashPay V2.0 (Raspberry Pi Pico Version)Midbar V5.0Midbar (STM32F401CCU6 Version)KhadashPay V3.0 (STM32F401CCU6 Version)KhadashPay V3.0Midbar (STM32F401CCU6 + Arduino Uno Version)KhadashPay V3.5Black Swan V2.0, Midbar (Teensy 4.1 Version), and Hash Latch.

Although the "3DES + AES + Blowfish + Serpent" encryption algorithm ain't exactly what I would call "a cryptographically weak encryption algorithm," operating it in a weird derivation of the ECB mode, the way it was done by the Midbar V2.0 wasn't the best idea that I had. Even though that wouldn't've allowed the attacker to produce the legitimate ciphertext by swapping the blocks within the ciphertext, an attacker could still make a legitimate ciphertext by replacing the nth block of the ciphertext N1 with the nth block of the ciphertext N2. To fix that vulnerability (instead of just notifying the user that the decrypted ciphertext might've been forged), I made the "3DES + AES + Blowfish + Serpent" encryption algorithm work in CBC mode. So, if an attacker replaces a block of ciphertext, they spoil not just that block but also the subsequent one.

I'll be honest with you, the bit-flipping attack "kinda works," but I doubt that it would ever go unnoticed because of the "HMAC-SHA256"-based integrity verification feature

And let's not forget that this encryption algorithm performs the operation called superencryption.

As defined by NIST, superencryption is an encryption operation for which the plaintext input to be transformed is the ciphertext output of a previous encryption operation.

Such organization of the encryption algorithms makes a combined encryption algorithm that is at least as strong as the strongest one in the cascade, has a longer key, might be more resistant to some attacks, and might produce a ciphertext with higher entropy. Anyway. It won't hurt to have an additional layer of security (or several of them).

Integrity Verification (for Data Stored on SD Card)

Integrity verification.png

The Midbar (Teensy 4.1 Version) V2.0 is the eleventh version of Midbar that verifies the integrity of the whole record. So, the legitimate ciphertexts moved between the cells aren't much of a threat to it.

The "HMAC-SHA256"-based integrity verification feature functions in the following way:

When you add a record to Midbar, it consolidates all the data you have entered into one string, computes a tag for that string, and then saves the newly computed tag in the encrypted form.

When Midbar decrypts your data, it also decrypts the previously saved tag and computes a new one for the decrypted data. It then compares both tags. If they don't match - Midbar notifies you that the integrity verification failed.

EEPROM Partitioning

partitioning.png

To enable you to use the Midbar (Teensy 4.1 Version) V2.0 without the SD card, I've partitioned the Teensy EEPROM to store the "set master password" byte, encrypted tag of the master password, sixteen login credentials, and the encrypted tag of all that I've just mentioned (to verify the integrity of all that data).

EEPROM Integrity Check

EEPROM Integrity Check.png

Since there's not that much space available in EEPROM, I've decided to use a single IV for a record stored in the EEPROM and to verify the integrity of the whole EEPROM area utilized by the Midbar (Teensy 4.1 Version) V2.0 instead of individually verifying the integrity of each record, the way it's done for the records stored on the SD card.

Prepare the Software

You need to install the Arduino IDE and Teensyduino to flash Teensy 4.1.

For more information on that, please refer to: https://www.pjrc.com/teensy/td_download.html

Download Firmware

You can download the firmware for Midbar from one of these sources.

SourceForge: https://sourceforge.net/projects/midbar/

GitHub: https://github.com/Northstrix/Midbar

If you just need the firmware for the device alongside the RNG, then I would advise you to download a 0.2 MB archive from SourceForge.

But if you need the firmware for all versions of Midbar alongside the extra code, photos, and diagrams, in that case, I would advise you to download the 199 MB archive from GitHub.

Download and Install the Libraries

Adafruit_ILI9341: https://github.com/adafruit/Adafruit_ILI9341

Adafruit-GFX-Library: https://github.com/adafruit/Adafruit-GFX-Library

Adafruit_BusIO: https://github.com/adafruit/Adafruit_BusIO

EncButton: https://github.com/GyverLibs/EncButton

rfid: https://github.com/miguelbalboa/rfid

The process of unpacking libraries is typical. You can unpack the content of the archive into the folder: ...\Arduino\libraries. Or open the Arduino IDE, click to the Sketch -> Include Library -> Add .ZIP Library... and select every archive with libraries.

Other required libraries are already present in one way or another.

Clear EEPROM

Clear EEPROM.png

To use Midbar, you first need to clear EEPROM.

To do so, upload the firmware from the "Teensy 4.1 Version\V2.0\Clear_EEPROM" folder into Teensy 4.1.

Generate Keys

Gen_keys.png

To make the unauthorized deciphering of your data computationally infeasible - It is crucial to generate your own keys and never reuse them

It's entirely up to you how to generate the keys. I can only offer you an option to do so.

I've modified one of my previous projects to work as a random number generator, the generated output seems "random enough" for me, but I haven't run any tests. So, I can't guarantee that it's random.

Use it at your own risk!

To generate the keys for Midbar - launch gen.exe from the "Teensy 4.1 Version\V2.0\Untested RNG" folder and click the "Gen. keys for Midbar (Teensy 4.1) V2.0" button. The background turns from dark gray to light gray when you press that button.

Modify Firmware

mod_keys.png

Open the "Firmware.ino" file from the "Teensy 4.1 Version\V2.0\Firmware" folder, and then replace my keys with those you've generated.

You can also change the number of available slots for the data stored on the SD card by modifying the value in the "#define MAX_NUM_OF_RECS 999" line.

Upload the Modified Firmware Into Teensy 4.1

modf.png

Upload the modified firmware from the "Teensy 4.1 Version\V2.0\Firmware" folder into Teensy 4.1.

Don't forget to set the value of the "USB Type" line to the "Serial + Keyboard + Mouse + Joystick."

Assemble Midbar

Midbar Circuit Diagram.png

Assemble the circuit and insert a Micro SD card formatted to the FAT32 filesystem into the Teensy's built-in SD card slot. When it comes to the "BL" pin of the ILI9341 display, different versions of the display have different requirements on what to do with it. Some versions specify that it must be connected to the +3.3V, some require it to be grounded, and others allow you to leave it unconnected.

According to the PJRC official websitethe digital pins of Teensy 4.1 are not 5V tolerant. Because of that, I would strongly advise you to double-check that you haven't accidentally connected anything to the "5V" pin.

As for the possible component replacements:

  • You can replace 4.7k resistors with 2.2k - 10k resistors;
  • And you can replace the capacitors with 22nf - 100nf capacitors.

Power the Midbar Up and Tap Four RFID Cards on the RFID Reader

IMG_20230719_103331.jpg
IMG_20230719_103611.jpg
IMG_20230719_103621.jpg
IMG_20230719_103648.jpg

After being powered up, the Midbar displays the "Midbar Teensy 4.1" and "Tap RFID card N1" inscriptions alongside the lock screen.

Tap four RFID cards on the RFID reader one after another. The most important thing here is to tap the cards in the same order every time you unlock Midbar. Otherwise, it just won't unlock.

If you don't have four cards, you can tap one card four times.


*Credit for the photo of New Orleans:

Photo by Morgan Petroski on Unsplash

Set Master Password

IMG_20230719_103927.jpg
IMG_20230719_103943.jpg
IMG_20230719_103951.jpg

To use the Midbar, you first need to set the master password.

You can only enter the master password using the encoder and USB keyboard.

And remember that you can't change your master password without performing the factory reset first!

Midbar won't be able to decrypt your data without your master password because the keys for the encryption algorithms are partially derived from it. Perhaps, it won't even unlock without the correct master password.

When you're done entering your master password, either quad-click the encoder button or press the "Enter" on the USB keyboard.


After you've unlocked the vault and got to the main menu:

  • Either turn the rotary encoder to the right or press the "" (DOWNWARDS ARROW) key on the USB keyboard to go down the menu.
  • Either turn the rotary encoder to the left or press the "" (UPWARDS ARROW) key on the USB keyboard to go up the menu.
  • Press either the "A" button or the "Enter" key on the USB keyboard to open the selected menu.
  • While in the submenu, press either the "B" button or the "Esc" key on the USB keyboard to return to the main menu.


While entering a text in a tab:

  • Press either the "A" button or the "" (UPWARDS ARROW) key on the USB keyboard to add a character displayed in the top-left corner of the screen to the input.
  • Press either the "B" button or the "" (DOWNWARDS ARROW) key on the USB keyboard to remove the last character from the input.
  • Either quad-click the encoder button four or press "Enter" on the USB keyboard to continue;
  • Either quintuple-click the encoder button (click it five times in quick succession) or press the "Esc" button on the USB keyboard to cancel the current operation.


*If the hexadecimal value in the top-right corner of the screen decreases when you rotate the encoder to the right, I would advise you to swap the wires connected to the "37" and "38" pins.

Add Login to EEPROM

IMG_20230719_144625.jpg
IMG_20230719_144715.jpg
IMG_20230719_144723.jpg
IMG_20230719_144731.jpg
IMG_20230719_144817.jpg
IMG_20230719_144849.jpg
IMG_20230719_145023.jpg

The Midbar (Teensy 4.1 Version) V2.0 offers 16 slots to store your login credentials in the EEPROM.

To add a login to the EEPROM from the encoder and USB keyboard:

  1. Select the "Logins In EEPROM" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "Add" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Choose the slot you want to put the login to either by rotating the encoder or by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  6. Press either the "A" button or the "Enter" key on the USB keyboard;
  7. Select the "Encoder + Keyboard" line;
  8. Press either the "A" button or the "Enter" key on the USB keyboard;
  9. Enter the username;
  10. Either quad-click the encoder button or press "Enter" on the USB keyboard;
  11. Enter the password;
  12. Either quad-click the encoder button or press "Enter" on the USB keyboard;
  13. Enter the website;
  14. Either quad-click the encoder button or press "Enter" on the USB keyboard.

*All credentials demonstrated here are entirely fictitious. Any similarity to actual credentials is purely coincidental.


View Login From EEPROM

IMG_20230719_145044.jpg
IMG_20230719_145057.jpg
IMG_20230719_145107.jpg
IMG_20230719_145115.jpg

To view a login from the EEPROM:

  1. Select the "Logins In EEPROM" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "View" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Choose the slot you want to view login from either by rotating the encoder or by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  6. Press either the "A" button or the "Enter" key on the USB keyboard.


*All credentials demonstrated here are entirely fictitious. Any similarity to actual credentials is purely coincidental.

Type Login From EEPROM

IMG_20230719_145126.jpg
IMG_20230719_145142.jpg
IMG_20230719_145211.jpg
IMG_20230719_145221.jpg
IMG_20230719_145232.jpg
IMG_20230719_145241.jpg
typed_from_EEPROM.png

The type feature allows you to use the Midbar (Teensy 4.1 Version) V2.0 as a USB keyboard. In other words, this version of Midbar can input your data to the computer as if you were typing it on a USB keyboard connected to your computer.

To type a login from the EEPROM:

  1. Select the "Logins In EEPROM" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "Type" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Choose the slot you want to type login from either by rotating the encoder or by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  6. Press either the "A" button or the "Enter" key on the USB keyboard;
  7. Press either the "" (Upwards Arrow) key on the USB keyboard or the encoder button to type the website;
  8. Press either the "" (Upwards Arrow) key on the USB keyboard or the encoder button to type the username;
  9. Press either the "" (Upwards Arrow) key on the USB keyboard or the encoder button to type the password.

*All credentials demonstrated here are entirely fictitious. Any similarity to actual credentials is purely coincidental.

Delete Login From EEPROM

IMG_20230719_145625.jpg
IMG_20230719_145644.jpg
IMG_20230719_145651.jpg
IMG_20230719_145706.jpg

To delete a login from the EEPROM:

  1. Select the "Logins In EEPROM" line;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "Delete" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Select the login you would like to delete either by rotating the encoder or by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  6. Press either the "A" button or the "Enter" key on the USB keyboard.

Add Login to SD Card

IMG_20230719_150109.jpg
IMG_20230719_150117.jpg
IMG_20230719_150126.jpg
IMG_20230719_150134.jpg
IMG_20230719_150148.jpg
IMG_20230719_150208.jpg
IMG_20230719_150243.jpg
IMG_20230719_150339.jpg
IMG_20230719_150346.jpg

With the Midbar (Teensy 4.1 Version) V2.0, you can store as many records on the SD card as you wish, as long as there is enough space on it.

Each record stored on an SD card has its own encrypted (verification) tag and a unique IV for each field.

To add a login to the SD card from the encoder and USB keyboard:

  1. Select the "Logins On SD Card" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "Add" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Choose the slot you want to put the login to either by rotating the encoder or by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  6. Press either the "A" button or the "Enter" key on the USB keyboard;
  7. Select the "Encoder + Keyboard" line;
  8. Press either the "A" button or the "Enter" key on the USB keyboard;
  9. Enter the title;
  10. Either quad-click the encoder button or press "Enter" on the USB keyboard;
  11. Enter the username;
  12. Either quad-click the encoder button or press "Enter" on the USB keyboard;
  13. Enter the password;
  14. Either quad-click the encoder button or press "Enter" on the USB keyboard;
  15. Enter the website;
  16. Either quad-click the encoder button or press "Enter" on the USB keyboard.


Based on the tests I've conducted, the Teensy 4.1 is capable of encrypting and decrypting a string of 10 000 characters using the 3DES + AES + Blowfish + Serpent encryption algorithm in CBC mode. Technically, you can put 10 000 characters into a field of a record.


*All credentials demonstrated here are entirely fictitious. Any similarity to actual credentials is purely coincidental.


View Login From SD Card

IMG_20230719_150437.jpg
IMG_20230719_150447.jpg
IMG_20230719_150459.jpg
IMG_20230719_150506.jpg
IMG_20230719_150513.jpg
rec_from_sd_in_ser.png

To view a login from the SD card:

  1. Select the "Logins On SD Card" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "View" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Choose the slot you want to view login from either by rotating the encoder or by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  6. Press either the "A" button or the "Enter" key on the USB keyboard;
  7. Press either the "" (Upwards Arrow) key on the USB keyboard or the encoder button to print the record to the serial terminal. Note that this feature isn't available for the data stored in the EEPROM.


*All credentials demonstrated here are entirely fictitious. Any similarity to actual credentials is purely coincidental.

Edit Login Stored on SD Card

IMG_20230719_150722.jpg
IMG_20230719_150732.jpg
IMG_20230719_150743.jpg
IMG_20230719_150752.jpg
IMG_20230719_150801.jpg
IMG_20230719_150829.jpg
IMG_20230719_150835.jpg

To edit a login stored on the SD card:

  1. Select the "Logins On SD Card" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "Edit" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Select the login you would like to edit either by rotating the encoder or by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  6. Press either the "A" button or the "Enter" key on the USB keyboard;
  7. Select the input source;
  8. Press either the "A" button or the "Enter" key on the USB keyboard;
  9. Depending on the chosen input source, either enter the new password you'd like to set on the encoder and USB keyboard or paste it to the Serial Terminal;
  10. Depending on the chosen input source, either quad-click the encoder button (or press "Enter") or press the "Send" button in the Serial Terminal.


*All credentials demonstrated here are entirely fictitious. Any similarity to actual credentials is purely coincidental.

Type Login From SD Card

IMG_20230719_150848.jpg
IMG_20230719_150855.jpg
IMG_20230719_150906.jpg
IMG_20230719_150913.jpg
IMG_20230719_150920.jpg
IMG_20230719_150928.jpg
IMG_20230719_151003.jpg
typed_from_sd.png

To type a login from the SD card:

  1. Select the "Logins On SD Card" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "Type" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Choose the slot you want to type login from either by rotating the encoder or by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  6. Press either the "A" button or the "Enter" key on the USB keyboard;
  7. Press either the "" (Upwards Arrow) key on the USB keyboard or the encoder button to type the website;
  8. Press either the "" (Upwards Arrow) key on the USB keyboard or the encoder button to type the username;
  9. Press either the "" (Upwards Arrow) key on the USB keyboard or the encoder button to type the password.

*All credentials demonstrated here are entirely fictitious. Any similarity to actual credentials is purely coincidental.

Delete Login From SD Card

IMG_20230719_151113.jpg
IMG_20230719_151119.jpg
IMG_20230719_151125.jpg
IMG_20230719_151135.jpg

To delete a login from the SD card:

  1. Select the "Logins On SD Card" line;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "Delete" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Select the login you would like to delete either by rotating the encoder or by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  6. Press either the "A" button or the "Enter" key on the USB keyboard.


The process of working with records of other types is very similar to the process of working with logins. And by the way, the "Type" feature works for all records stored on an SD card regardless of their type.

Encrypt String

IMG_20230719_164141.jpg
IMG_20230719_164154.jpg
IMG_20230719_164201.jpg
IMG_20230719_164209.jpg
IMG_20230719_164216.jpg

The Midbar (Teensy 4.1 Version) V2.0 utilizes seven encryption algorithms. You can use any of them to encrypt your data.

To encrypt string:

  1. Open the Serial Terminal (because the ciphertext is printed to it);
  2. Select the "Encryption Algorithms" line in the main menu;
  3. Press either the "A" button or the "Enter" key on the USB keyboard;
  4. Select the line with the name of the encryption algorithm you would like to use;
  5. Press either the "A" button or the "Enter" key on the USB keyboard;
  6. Select the "Encrypt String" line;
  7. Choose the input source;
  8. Press either the "A" button or the "Enter" key on the USB keyboard;
  9. Depending on the chosen input source, either enter the text you'd like to encrypt on the encoder and USB keyboard or paste it to the Serial Terminal;
  10. Depending on the chosen input source, either quad-click the encoder button (or press "Enter") or press the "Send" button in the Serial Terminal.


Plaintext:

Just in case you've forgotten why I called this project Midbar - Midbar is a Hebrew word that means "pasture," "uninhabited land," "wilderness," "large tracts of wilderness (around cities)," and "desert." I had two reasons for choosing the word Midbar as the name of this project. First - while working on my previous projects, I noticed that the so-called "device that keeps your personal data secure in an encrypted form" market is pretty much a "desert around the oasis of the password manager market." Second - I couldn't find a better word to describe this project. At first, I wanted to call it a "Password Vault," but it's more than that. So, I decided to call it Midbar.

Ciphertext:

0dbc3250e5e381fc764688d8d5c2831346faa30b6356f8dcc947000cfcd707a7b5c2d3dfbbb5034030a580e9605c6cacf57c6998b6c22a77ff697cf0c6fa7eef04e6dbfb3ff697bef765d471a64faa8197a1b15a67a3e2414c0d228994fbd9da92ec1e62052d9f3ea909ae91a3182f7afabc55112f4052eab2da7ef1a08567804c5fc8a8bc57d1354e52715a2d7226eb1e4f1dfb63c0304d828f289abd9546143a4cb7c33ce1521124de880ad85e95f595e5941bbeb284aa4d134dbffdf5067bae7c3a0da123143fa81ab8ad46c10258c2b250b89ea91f2a13b99ea05f2ba2b7e893c8c02f44fe7552c17b4471a21f0bb54ea0bcab82f042aa047dc63ae1ff8b2d106695f0dfd7ce2e9e41f1e0b3acd95e3f6cf578669025017e2effdc58668693d46f2eee696b033139504d4f0a5e338064c4a858353329ea4b0f3e358d46a4e77648518eacf3d06d2449c5f9f59b81d6618907a4551084a600c4cd1f523e87148b05d3e1b3091572004e3219295342f573e4e142c1bdca590eb68eac76342d9cd7ff32b40eebc43f30148cc953ea8d595d5563258024d66ed6dbd144a7f7fab3d7c4242c8bb85e20919a16c77d42d20fe5b1f308be37f92ae524182c7899cfd3a95b0784378248f9c4c3ddba1f7d01bfe9af77db647b513a6ed6bb99d6f3ac388cf54a446bf558225b935fd522b5c5e4e4a39618e1bcdc664b8e34797de0235b87d2c1709d06ff0d9e1b34cb3b0e0a27d7bff8fbddb94e957a229cfeeec9594a46011384405f088419f7b67b74822879b4195eb761bbe367465121d054e95f1574da36c7b5d6b7264326da439e7b6c98702f47a51d6aa8d4ed8e9c3283982c9fe06902aac89e65c874f7a4a31bd896b17f09b9aa80cb75d5e97139b6f1ec4b6c450f6f773b8ee026dd1ea34aa941437193119f58d46743997d9a655046b125056c61e0702336cd6f41b50c5539ef0ef0a0de97d7f6d47f4ac0ab87515a600852824a4d19c8845764d37d9586866353e451ad881ef2a6f46f701ff64199629260b87e01f155b78247f725218e50ffdd9bee61890bd07455e077cff6ece899e5a265622d8680aa6efc51eef7ea441bb29088815b88a68835fdbafb9fdea78e4197115ed494a4566c6e8b39f2ce456e38d10f8c98c8fd46838285dc99b2772c8f18bdbd5819ae27e5014d0307b325d40f40e693b9dff6ade152ac1a0c571f852c32fa777cc2faaf65d64a8a37a8c350d4a4fb56de1de8b7dcad7a52eb5d40a6ce35cf4fcc5a1203f97f6a5e3eaeb6e5ea58b86f244eaa1312d0720ba2d7f8435632bd919eaf32da4856c417114ed3d480f174522cdf1ea59bbff29f2d30e7775532a2d7db68f7a674c342f35f39bcf078c8a13e369deacbd4fc16630d615340556ad40e47114de169edc5d39bc5be56d398c77ef69c1768e0e33ad68eec45ba1eff45acf983269cb869831f4775126171ff0b36d16f6d97865860d2191f1476caa79e89f4b6de0dfed6c5ec7b644f7fb768b0e9bf9252712092322ebff18aae13d28c39f43e5290fd2404f829575ea61091c18373d693d848fa27c8ee0a355c6b6cd2be3ee142d28698c25afb75b71cb329950939839a4b022d9f58fc4cd0936b89fa8372e9b14d0c18aa48db0bd76ae1

Decrypt String

IMG_20230719_164421.jpg
IMG_20230719_164427.jpg
IMG_20230719_164434.jpg
IMG_20230719_164439.jpg
IMG_20230719_164446.jpg
IMG_20230719_164459.jpg
IMG_20230719_164547.jpg

To decrypt string:

  1. Open the Serial Terminal (because you'll need to paste the ciphertext to it);
  2. Select the "Encryption Algorithms" line in the main menu;
  3. Press either the "A" button or the "Enter" key on the USB keyboard;
  4. Select the line with the name of the encryption algorithm you've used to encrypt the text;
  5. Press either the "A" button or the "Enter" key on the USB keyboard;
  6. Select the "Decrypt String" line;
  7. Choose where to display the decrypted string;
  8. Press either the "A" button or the "Enter" key on the USB keyboard;
  9. Paste the ciphertext to the Serial Terminal;
  10. Press the "Send" button in the Serial Terminal.


Ciphertext:

0dbc3250e5e381fc764688d8d5c2831346faa30b6356f8dcc947000cfcd707a7b5c2d3dfbbb5034030a580e9605c6cacf57c6998b6c22a77ff697cf0c6fa7eef04e6dbfb3ff697bef765d471a64faa8197a1b15a67a3e2414c0d228994fbd9da92ec1e62052d9f3ea909ae91a3182f7afabc55112f4052eab2da7ef1a08567804c5fc8a8bc57d1354e52715a2d7226eb1e4f1dfb63c0304d828f289abd9546143a4cb7c33ce1521124de880ad85e95f595e5941bbeb284aa4d134dbffdf5067bae7c3a0da123143fa81ab8ad46c10258c2b250b89ea91f2a13b99ea05f2ba2b7e893c8c02f44fe7552c17b4471a21f0bb54ea0bcab82f042aa047dc63ae1ff8b2d106695f0dfd7ce2e9e41f1e0b3acd95e3f6cf578669025017e2effdc58668693d46f2eee696b033139504d4f0a5e338064c4a858353329ea4b0f3e358d46a4e77648518eacf3d06d2449c5f9f59b81d6618907a4551084a600c4cd1f523e87148b05d3e1b3091572004e3219295342f573e4e142c1bdca590eb68eac76342d9cd7ff32b40eebc43f30148cc953ea8d595d5563258024d66ed6dbd144a7f7fab3d7c4242c8bb85e20919a16c77d42d20fe5b1f308be37f92ae524182c7899cfd3a95b0784378248f9c4c3ddba1f7d01bfe9af77db647b513a6ed6bb99d6f3ac388cf54a446bf558225b935fd522b5c5e4e4a39618e1bcdc664b8e34797de0235b87d2c1709d06ff0d9e1b34cb3b0e0a27d7bff8fbddb94e957a229cfeeec9594a46011384405f088419f7b67b74822879b4195eb761bbe367465121d054e95f1574da36c7b5d6b7264326da439e7b6c98702f47a51d6aa8d4ed8e9c3283982c9fe06902aac89e65c874f7a4a31bd896b17f09b9aa80cb75d5e97139b6f1ec4b6c450f6f773b8ee026dd1ea34aa941437193119f58d46743997d9a655046b125056c61e0702336cd6f41b50c5539ef0ef0a0de97d7f6d47f4ac0ab87515a600852824a4d19c8845764d37d9586866353e451ad881ef2a6f46f701ff64199629260b87e01f155b78247f725218e50ffdd9bee61890bd07455e077cff6ece899e5a265622d8680aa6efc51eef7ea441bb29088815b88a68835fdbafb9fdea78e4197115ed494a4566c6e8b39f2ce456e38d10f8c98c8fd46838285dc99b2772c8f18bdbd5819ae27e5014d0307b325d40f40e693b9dff6ade152ac1a0c571f852c32fa777cc2faaf65d64a8a37a8c350d4a4fb56de1de8b7dcad7a52eb5d40a6ce35cf4fcc5a1203f97f6a5e3eaeb6e5ea58b86f244eaa1312d0720ba2d7f8435632bd919eaf32da4856c417114ed3d480f174522cdf1ea59bbff29f2d30e7775532a2d7db68f7a674c342f35f39bcf078c8a13e369deacbd4fc16630d615340556ad40e47114de169edc5d39bc5be56d398c77ef69c1768e0e33ad68eec45ba1eff45acf983269cb869831f4775126171ff0b36d16f6d97865860d2191f1476caa79e89f4b6de0dfed6c5ec7b644f7fb768b0e9bf9252712092322ebff18aae13d28c39f43e5290fd2404f829575ea61091c18373d693d848fa27c8ee0a355c6b6cd2be3ee142d28698c25afb75b71cb329950939839a4b022d9f58fc4cd0936b89fa8372e9b14d0c18aa48db0bd76ae1

Plaintext:

Just in case you've forgotten why I called this project Midbar - Midbar is a Hebrew word that means "pasture," "uninhabited land," "wilderness," "large tracts of wilderness (around cities)," and "desert." I had two reasons for choosing the word Midbar as the name of this project. First - while working on my previous projects, I noticed that the so-called "device that keeps your personal data secure in an encrypted form" market is pretty much a "desert around the oasis of the password manager market." Second - I couldn't find a better word to describe this project. At first, I wanted to call it a "Password Vault," but it's more than that. So, I decided to call it Midbar.

Hash String

IMG_20230719_164609.jpg
IMG_20230719_164616.jpg
IMG_20230719_164652.jpg
IMG_20230719_164659.jpg

The Midbar utilizes two hash functions: SHA-256 and SHA-512.

If you're not familiar with the hash functions, let me give you a simple explanation of what the hash function is.

A hash function is a mathematical function that takes some data as an input and produces a fixed-size, unique output value, known as a hash. The hash function always produces the same output given the same input.


To hash a string:

  1. Select the "Hash Functions" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "SHA-256" or "SHA-512" line depending on the hash function you'd like to use;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Enter the string you'd like to hash;
  6. Either quad-click the encoder button or press "Enter" on the USB keyboard.


Input data:

Midbar Teensy 4.1 Version

Hash:

ec640e3951b7475c8a7366a76f72c63e288e50b75a1160a54fa778f6910fdf27978117d4d34cd70cbd225e08ee4c673c6ef4a74c0d3710ff7401c6394607aada

Back Up Data From EEPROM

IMG_20230719_164722.jpg
IMG_20230719_164729.jpg
IMG_20230719_164737.jpg

Another handy feature of this version of Midbar is its ability to easily back up the EEPROM data to the Serial Terminal or the SD card.

To back up the EEPROM data to the SD card:

  1. Select the "Other Options" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "Back Up Data From EEPROM" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Select the "SD Card" line;
  6. Press either the "A" button or the "Enter" key on the USB keyboard.


After you back up the EEPROM data to the SD card, the "Midback" file should appear there.


*Note that performing the factory reset will erase the backup of the EEPROM data from the SD card.

Restore Data to EEPROM

IMG_20230719_164722.jpg
IMG_20230719_164747.jpg
IMG_20230719_164755.jpg

You can restore the EEPROM data from the SD card or the Serial Terminal.

To restore data to the EEPROM from the SD card:

  1. Select the "Other Options" line in the main menu;
  2. Press either the "A" button or the "Enter" key on the USB keyboard;
  3. Select the "Restore Data To EEPROM" line;
  4. Press either the "A" button or the "Enter" key on the USB keyboard;
  5. Select the "SD Card" line;
  6. Press either the "A" button or the "Enter" key on the USB keyboard.

Find a Good Use for Midbar

IMG_20230719_144506.jpg

The Midbar (Teensy 4.1 Version) V2.0 is the first version of Midbar that can function as a USB keyboard. It has inherited all the positive aspects of the Midbar (Teensy 4.1 Version), such as the USB keyboard support and the ability to easily encrypt and decrypt a string of 10 000 characters without any problems whatsoever. Judging by the CPU clock speed and the CoreMark benchmark performance, the Teensy version of Midbar is the most powerful version of Midbar (so far).

And while Midbar is no guarantee of world peace or social harmony, I do believe that it's an important contribution to the protection of your data from unauthorized access.

I think it's also worth mentioning that Midbar's source code is distributed under the MIT license. That grants you the freedom to customize and modify Midbar according to your preferences. So if you want to make your own version of Midbar or use it as a base for your own project, don't wait for anyone else to do it for you. Take the initiative into your own hands and do it.

If you found this tutorial to be useful, please consider sharing it.

Thank you for reading this tutorial.