Pastilda. Part 1. The beginning.
What's going on?
This is the first article in a series about our internal hardware project that has become our first commercial product.
Read this article if you are interested in the development of electronics, hardware devices, and crowdfunding.
A lot of notes and discussions are devoted to the difficult issue of safe password storage, the topic is interesting and seems to be relevant for a long time to come. There are various software solutions for storing passwords, but many of them are characterized by the following disadvantages:
· Closed source code reduces trust and bug fixing speed;
· You need to install additional software for auto-complete;
· After entering the master password, the entire database is open and accessible, including for malware, especially on untrusted devices;
· Using mobile applications for storing passwords still implies manual keyboard input, for example, when you need to log in to your desktop PC;
· Auto-completion is not possible in some cases, for example, in bios or console;
In Third Pin, we concluded that the most convenient solution would be a simple and inexpensive device that allows you to store and enter logins/passwords on any device in hardware without installing any software.
First of all, we studied the information to understand who else came up with the idea of storing and entering passwords in hardware, and how it was implemented. The options found can be divided into the following categories:
· Encrypted drives or just a flash drive with a password. You can safely store documents, but you cannot enter them automatically;
· Devices with biometric identification (for example). Biometric identification looks attractive, but it is less universal than a character password. If you need to remotely give someone access to the device, fingerprint transmission will become a real problem. Additional sensors increase the cost of the product. In the case of compromise, it is difficult to quickly change prints;
· Software password managers with a hardware token key that gives access to the database (for example) have the same drawbacks as program managers without a token key;
· Devices for entering 1–4 passwords and their generation (example, example). The closest solutions. Of the shortcomings, it should be noted the limited number of stored passwords as well as the management of exclusive buttons on the device, which is not very convenient.
None of the devices found fully matched our idea. We were delighted and continued to think.
Not so long ago, for corporate tasks of storing passwords, instead of papers, browsers, and biological memory, we began to use KeePass. Quite satisfied with the convenience and versatility of this product, we decided to adapt it to the tasks of hardware password storage by porting it to the microcontroller.
However, a huge number of questions remained. How to select the desired entry in the database on the device? How to show the user which record is selected? Should we place buttons on the device? Add screen? How should it connect to a computer? And to the tablet? Or to the phone?
First of all, we decided not to add a screen. If the needs to enter a password — most likely, he already has a screen. As for the connection methods, we decided not to consider wireless interfaces, because they can be vulnerable to interception.
For management, we decided to use a standard keyboard and to directly enter saved passwords into forms, we will emulate keyboard commands. “Interception” of control occurs when you enter a special key combination. By default, we chose the combination Ctrl + Shift + ~, because it is convenient for pressing and is practically never used. The project was called Pastilda (from words password + tilda), we associate it with something tasty and sweet, and also helps not to forget the main key combination for working with the device.
While in passive mode, Pastilda transmits all messages from the keyboard to the PC without changes, waiting for a special combination to be pressed. After entering the combination, the device enters the active mode. If at this moment the cursor is in the text input field — it can be the “Login” field or any other text field — a single-line text menu appears in it.
How does it work?
To work with the KeePass database stored in Pastilda’s memory, the user enters a master password, and then, using the navigation keys, selects the name of the account he is interested in and presses the enter. Pastilda enters the desired username and password in the appropriate fields. At the same time, the database is decrypted on the device, and the target system does not get access to the master password and to the entire database. Exit from the active mode occurs either automatically, after entering the password, or after pressing the “Shift + Ctrl + ~” combination again. Yes, by the way, you can come up with your own combinations.
Version 0.1 was designed to test ideas, usability and all kinds of pampering. The following features were planned in the current version:
· USB composite device (HID + Mass Storage);
· USB host;
· Work with one KeePass base;
· Single-line menu;
Everything is simple — the STM32f405 controller, two connectors and a flash drive on SPI. Also a bit of protection, an SWD connector and, of course, an RGB LED. The choice of components did not cause difficulties. We just love STM. Memory selected from existing.
All components in ordinary cases, so that the board is cheap and fast in production. Size 40x17 mm, 4 layers.
· USB host, in order to recognize the keyboard connected to the device and to forward messages from it further to the PC
· composite USB device (msd + hid): in Pastilda mode, the device should be able to be a keyboard, in addition, always accessible as an external drive, for convenient adding and removing passwords.
Waiting for their fate:
· FAT for reading data written to flash memory so that we can walk around directories and take the desired password;
· KeePass decryption, work with records;
We want to implement work with any devices that understand the external keyboard. We have already tested the work of our prototype with an Android smartphone via USB OTG, everything works fine. For the convenience of navigating the menu when using Pastilda with mobile devices, we will make a separate USB-module with a wheel-button.
Another idea is a small flex-rigid printed circuit board that plugs directly into the USB connector, ending up between the host and device pins. A hard piece of the board with the components is glued onto the body of the device plug. Thus, the device will be quite difficult to detect. However, why do we need this? Just an idea.
The built-in memory of Pastilda can be used to store data (if speed is not particularly important), and here are possible options: just a USB drive, which is always visible when the device is connected, or an encrypted drive. KeePass databases, key files, etc. supposed to be stored in this space.
The code is posted on Bitbucket, along with hardware. GNU GPL License.
Naturally, you can develop something of your own on the basis of this project, we thought about such ideas:
· game cheat emulation kbd + mouse;
· streaming hardware encryption USB flash.
Find customers and earn millions. About this in the next article.
Do you like the article?
Write your questions and let’s discuss!