Press or tap to auto-type your password suffix β the full password never exists in one place.
The prefix stays in your mind, the suffix lives in your hand.
This project offers a straightforward solution for securely logging into a system or website using a hardware key. By pressing a physical button connected to an ATtiny85 microcontroller, users can automate the login process, thereby reducing the risk of password exposure.
Pressing the tactile switch on the breadboard prototype sends a keystroke that appears in the terminal.
The aim of this project is to provide a more secure alternative to manually typing long or complex passwords, particularly in environments where there may be observers or surveillance. With the hardware key, users can log in quickly and securely without the risk of their password being intercepted or observed.
- Enhanced Security: Prevents password interception by keystroke loggers or shoulder surfing.
- Convenience: Simplifies the login process, especially for systems with lengthy or complex passwords.
- Privacy: Maintains the confidentiality of passwords in public or shared environments.
- Portability: Easily carried and used on multiple systems or devices.
The hardware key utilizes an ATtiny85 microcontroller with the V-USB library to implement USB Human Interface Device (HID) keyboard functionality. This allows the ATtiny85 to act as a keyboard when connected to a computer via USB. When the button connected to the ATtiny85 is pressed, it sends predefined keystrokes to the computer, automating the login process.
Sequence: (1) user types the prefix, (2) user triggers the device (tactile button or TTP223), and (3) the ATtiny85 injects suffix + Enter via USB HID. The host concatenates the parts to form the full credential.
From code to reality! The ATtiny85 Hardware Login Key project and its various prototypes. What started as a simple idea is now a fully functional set of secure login devices.
Tip
First time working with the ATtiny85?
Before diving into this project, it's highly recommended to test your hardware setup and compilation process with a simpler program. The ATtiny85_Simple_Code_Test project is a perfect "Hello, World!" for your hardware. It plays music through a speaker and confirms that your ATtiny85, programmer, and toolchain are all working correctly before you tackle the more complex V-USB library.
You can modify the permissions of /dev/ttyACM0 to facilitate communication with your serial device. For detailed instructions, click here.
Important
One-Time Fuse Setup for External Crystal
The ATtiny85 must be configured to use the external 16MHz crystal. This is done by setting its "fuse bits." This is a one-time operation for each chip.
- Connect your programmer to the ATtiny85.
- Run the following command to set the fuses for a 16MHz external crystal:
avrdude -c avrisp -p attiny85 -P /dev/ttyACM0 -b 19200 -U lfuse:w:0xFF:m -U hfuse:w:0xDD:m
If you later wish to use this ATtiny85 for a different project that does not require an external crystal, you can revert it to use its internal 8MHz oscillator.
Run the following command:
avrdude -c avrisp -p attiny85 -P /dev/ttyACM0 -b 19200 -U lfuse:w:0xE2:m -U hfuse:w:0xDF:mThis restores the chip to use its internal 8MHz clock source, which is a common setting for many projects (like the ATtiny85_Simple_Code_Test).
Warning
Be extremely careful when setting fuses. Incorrect values can permanently "brick" your microcontroller. Always double-check the fuse values before executing the command.
To compile the C implementation, follow these steps:
- Open a terminal.
- Navigate to the
C_implementationfolder. - Read the instructions or refer to using make for the C implementation.
To compile the C++ implementation, follow these steps:
- Open a terminal.
- Navigate to the
CPP_implementationfolder. - Read the instructions for the C++ implementation.
This hardware key uses a "Two-Piece Password" approach for enhanced security. The device does not store your full password. Instead, it stores only the complex second half, while you remember and type the simpler first half. This makes the physical key useless if it is ever lost or stolen.
Let's imagine your full, desired password is: Key_!#2025_complex
- The part you remember and type first (The Prefix):
Key_ - The part stored on your hardware key (The Suffix):
!#2025_complex
- Navigate to the password field of the login form.
- Manually type the first part of your password (e.g.,
Key_). - Plug in your hardware key.
- Press the button on the key.
- The key will automatically type the complex second half of the password (
!#2025_complex) and press Enter, logging you in securely.
The hardware key is available in multiple PCB package versions to accommodate different assembly preferences:
- Through-Hole (DIP): Easy to assemble manually, suitable for prototyping.
- SMD (SOIC): For more compact and automated assembly.
- SMD (QFN): For advanced designs requiring a small footprint.
| Reference | Value | Datasheet | Footprint | Qty | DNP |
|---|---|---|---|---|---|
| C1, C2 | 22pF | ~ | Capacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mm | 2 | |
| C3 | 100nF | ~ | Capacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mm | 1 | |
| C4 | 10uF | ~ | Capacitor_THT:CP_Radial_D4.0mm_P2.00mm | 1 | |
| D1, D2 | 3V6 | ~ | Diode_THT:D_DO-15_P10.16mm_Horizontal | 2 | |
| J1 | USB-AM-S-X-X-TH | USB-AM-S-X-X-TH:SAMTEC_USB-AM-S-X-X-TH | 1 | ||
| J2 | Conn_01x06_Pin | ~ | Connector_Molex:Molex_PicoBlade_53047-0610_1x06_P1.25mm_Vertical | 1 | |
| R1, R2 | 68R | ~ | Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal | 2 | |
| R3 | 10k | ~ | Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal | 1 | |
| R4 | 1k5 | ~ | Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P5.08mm_Horizontal | 1 | |
| S1 | B3F-1000 | B3F-1000:SW_B3F-1000 | 1 | ||
| U1 | ATtiny85-20P | link | Package_DIP:DIP-8_W7.62mm | 1 | |
| Y1 | 16MHz | ~ | Crystal:Crystal_HC49-4H_Vertical | 1 |
3D model of the hardware login keyβs PCB using the Through-Hole (DIP) package in KiCad
| Reference | Value | Datasheet | Footprint | Qty | DNP |
|---|---|---|---|---|---|
| C1 | 100nF | ~ | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | 1 | |
| C2, C3 | 22pF | ~ | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | 2 | |
| C4 | 10ΞΌF | ~ | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | 1 | |
| D1, D2 | 3V6 | ~ | Diode_SMD:D_0603_1608Metric_Pad1.05x0.95mm_HandSolder | 2 | |
| J1 | USB-AM-S-X-X-TH | USB-AM-S-X-X-TH:USB_PCB | 1 | ||
| J2 | Conn_01x06_Pin | ~ | Connector_JST:JST_SH_SM06B-SRSS-TB_1x06-1MP_P1.00mm_Horizontal | 1 | |
| R1, R2 | 68R | ~ | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | 2 | |
| R3 | 1k5 | ~ | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | 1 | |
| R5 | 10k | ~ | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | 1 | |
| S2 | PTS525SM15SMTR2LFS | PTS525SM15SMTR2LFS:SW_PTS525SM15SMTR2LFS | 1 | ||
| U1 | ATtiny85-20P | link | Package_SO:SOIC-8_5.3x5.3mm_P1.27mm | 1 | |
| Y2 | 16MHz | ~ | Crystal:Crystal_SMD_3225-4Pin_3.2x2.5mm | 1 |
3D model of the hardware login keyβs PCB using the SMD (SOIC) package in KiCad.
| Reference | Value | Datasheet | Footprint | Qty | DNP |
|---|---|---|---|---|---|
| C1 | 100nF | ~ | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | 1 | |
| C2, C3 | 22pF | ~ | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | 2 | |
| C4 | 10ΞΌF | ~ | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | 1 | |
| D1, D2 | 3V6 | ~ | Diode_SMD:D_0603_1608Metric_Pad1.05x0.95mm_HandSolder | 2 | |
| J1 | USB-AM-S-X-X-TH | USB-AM-S-X-X-TH:USB_PCB | 1 | ||
| J2 | Conn_01x06_Pin | ~ | Connector_JST:JST_SH_SM06B-SRSS-TB_1x06-1MP_P1.00mm_Horizontal | 1 | |
| R1, R2 | 68R | ~ | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | 2 | |
| R3 | 1k5 | ~ | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | 1 | |
| R5 | 10k | ~ | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | 1 | |
| S2 | PTS525SM15SMTR2LFS | PTS525SM15SMTR2LFS:SW_PTS525SM15SMTR2LFS | 1 | ||
| U1 | ATtiny85-20M | link | Package_DFN_QFN:QFN-20-1EP_4x4mm_P0.5mm_EP2.5x2.5mm_ThermalVias | 1 | |
| Y2 | 16MHz | ~ | Crystal:Crystal_SMD_3225-4Pin_3.2x2.5mm | 1 |
3D model of the hardware login keyβs PCB using the QFN package in KiCad.
| Reference | Value | Datasheet | Footprint | Qty | DNP |
|---|---|---|---|---|---|
| C1 | 100nF | ~ | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | 1 | |
| C2, C3 | 22pF | ~ | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | 2 | |
| C4 | 1uF | ~ | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | 1 | |
| C5 | 30pF | ~ | Capacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolder | 1 | |
| C6 | 10ΞΌF | ~ | Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder | 1 | |
| D1, D2 | 3V6 | ~ | Diode_SMD:D_0603_1608Metric_Pad1.05x0.95mm_HandSolder | 2 | |
| J1 | USB-AM-S-X-X-TH | USB-AM-S-X-X-TH:USB_PCB | 1 | ||
| J2 | M50-3930642 | M50-3930642:HARWIN_M50-3930642 | 1 | ||
| R1, R2 | 68R | ~ | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | 2 | |
| R3 | 1k5 | ~ | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | 1 | |
| R5 | 10k | ~ | Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolder | 1 | |
| TP1, TP2 | TestPoint | ~ | TestPoint:TestPoint_Pad_D3.0mm | 2 | |
| U1 | ATtiny85-20M | link | Package_DFN_QFN:QFN-20-1EP_4x4mm_P0.5mm_EP2.5x2.5mm_ThermalVias | 1 | |
| U2 | TTP223-BA6 | TTP223-BA6:SOT23-6 | 1 | ||
| Y2 | 16MHz | ~ | Crystal:Crystal_SMD_3225-4Pin_3.2x2.5mm | 1 |
3D model of the hardware login keyβs PCB using the QFN package in KiCad.
With the TTP223 IC. (Uses simple high/low output for touch detection, similar to a tactile switch, with default code for straightforward 0 or 1 output.)
A 3D printed case is available for the hardware key. To use it, follow these steps:
- Open the
3d_printed_casefolder. - Load the
hardware_key_case.stlfile into your 3D printer software. - Print the case using your 3D printer.
- Once printed, assemble the hardware key inside the case for added protection and aesthetics.
This project stands on the shoulders of giants. A special thank you to the developers and communities behind these essential open-source tools:
- V-USB: The core USB functionality of this hardware key is made possible by the V-USB library, a firmware-only USB driver for AVR microcontrollers from Objective Development.
- KiCad: All PCB designs were created using KiCad, a powerful, free, and open-source electronics design automation (EDA) suite. Learn more at the KiCad website.
This project is licensed under the GPLv3 License - see the LICENSE file for details.
Enjoy your secure hardware login key! Thank you for visiting Hardware-Login-Key! πβ¨