Midbar (Teensy 4.1 Version) V2.0
by Northstrix in Circuits > Microcontrollers
993 Views, 3 Favorites, 0 Comments
Midbar (Teensy 4.1 Version) V2.0
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.
Supplies
- 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
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.0, Midbar V4.0, KhadashPay V2.0, Midbar (Raspberry Pi Pico Version) V2.0, KhadashPay V2.0 (Raspberry Pi Pico Version), Midbar V5.0, Midbar (STM32F401CCU6 Version), KhadashPay V3.0 (STM32F401CCU6 Version), KhadashPay V3.0, Midbar (STM32F401CCU6 + Arduino Uno Version), KhadashPay V3.5, Black 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)
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
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
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
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
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
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
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
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 website, the 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
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
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
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:
- Select the "Logins In EEPROM" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Add" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Encoder + Keyboard" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Enter the username;
- Either quad-click the encoder button or press "Enter" on the USB keyboard;
- Enter the password;
- Either quad-click the encoder button or press "Enter" on the USB keyboard;
- Enter the website;
- 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
To view a login from the EEPROM:
- Select the "Logins In EEPROM" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "View" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- 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
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:
- Select the "Logins In EEPROM" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Type" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Press either the "↑" (Upwards Arrow) key on the USB keyboard or the encoder button to type the website;
- Press either the "↑" (Upwards Arrow) key on the USB keyboard or the encoder button to type the username;
- 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
To delete a login from the EEPROM:
- Select the "Logins In EEPROM" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Delete" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- Press either the "A" button or the "Enter" key on the USB keyboard.
Add Login to SD Card
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:
- Select the "Logins On SD Card" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Add" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Encoder + Keyboard" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Enter the title;
- Either quad-click the encoder button or press "Enter" on the USB keyboard;
- Enter the username;
- Either quad-click the encoder button or press "Enter" on the USB keyboard;
- Enter the password;
- Either quad-click the encoder button or press "Enter" on the USB keyboard;
- Enter the website;
- 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
To view a login from the SD card:
- Select the "Logins On SD Card" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "View" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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
To edit a login stored on the SD card:
- Select the "Logins On SD Card" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Edit" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the input source;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- 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
To type a login from the SD card:
- Select the "Logins On SD Card" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Type" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Press either the "↑" (Upwards Arrow) key on the USB keyboard or the encoder button to type the website;
- Press either the "↑" (Upwards Arrow) key on the USB keyboard or the encoder button to type the username;
- 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
To delete a login from the SD card:
- Select the "Logins On SD Card" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Delete" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- 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
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:
- Open the Serial Terminal (because the ciphertext is printed to it);
- Select the "Encryption Algorithms" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the line with the name of the encryption algorithm you would like to use;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Encrypt String" line;
- Choose the input source;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- 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;
- 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
To decrypt string:
- Open the Serial Terminal (because you'll need to paste the ciphertext to it);
- Select the "Encryption Algorithms" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the line with the name of the encryption algorithm you've used to encrypt the text;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Decrypt String" line;
- Choose where to display the decrypted string;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Paste the ciphertext to the Serial Terminal;
- 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
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:
- Select the "Hash Functions" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "SHA-256" or "SHA-512" line depending on the hash function you'd like to use;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Enter the string you'd like to hash;
- 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
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:
- Select the "Other Options" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Back Up Data From EEPROM" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "SD Card" line;
- 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
You can restore the EEPROM data from the SD card or the Serial Terminal.
To restore data to the EEPROM from the SD card:
- Select the "Other Options" line in the main menu;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "Restore Data To EEPROM" line;
- Press either the "A" button or the "Enter" key on the USB keyboard;
- Select the "SD Card" line;
- Press either the "A" button or the "Enter" key on the USB keyboard.
Find a Good Use for Midbar
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.