Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The Hardware Login Key is an ATtiny85-based USB device that securely automates password entry using a physical button or touch sensor. It offers a simple, hardware-driven way to log into systems or websites, with an optional 3D-printed enclosure.

License

Notifications You must be signed in to change notification settings

Paschalis/Hardware-Login-Key

Repository files navigation

πŸ” Hardware Login Key

Hardware Login Key preview
Build status MCU ATtiny85 V-USB firmware Firmware size 1.86 KB flash Flash usage 22% License

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.

Introduction

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. Alt Text

Pressing the tactile switch on the breadboard prototype sends a keystroke that appears in the terminal.

🎯 Purpose

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.

Benefits

  • 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.

How it Works

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.

Alt Text

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.

Alt Text

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.

Compilation Instructions

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.

  1. Connect your programmer to the ATtiny85.
  2. 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

How to Revert to the Internal Oscillator

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:m

This 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.

C Implementation

To compile the C implementation, follow these steps:

  1. Open a terminal.
  2. Navigate to the C_implementation folder.
  3. Read the instructions or refer to using make for the C implementation.

C++ Implementation

To compile the C++ implementation, follow these steps:

  1. Open a terminal.
  2. Navigate to the CPP_implementation folder.
  3. Read the instructions for the C++ implementation.

πŸ“‹ Usage

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.

The Concept in Action

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

Login Steps

  1. Navigate to the password field of the login form.
  2. Manually type the first part of your password (e.g., Key_).
  3. Plug in your hardware key.
  4. Press the button on the key.
  5. The key will automatically type the complex second half of the password (!#2025_complex) and press Enter, logging you in securely.

PCB Designs

In KiCad

Alt Text

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.
    • Through-Hole PCB With tactile switch.
  • SMD (SOIC): For more compact and automated assembly.
    • SMD SOIC PCB With tactile switch.
  • SMD (QFN): For advanced designs requiring a small footprint.
    • QFN PCB With tactile switch.

    • QFN PCB QFN PCB designed for a touch pad using the TTP223 IC for enhanced reliability.

      • Uses a simple high/low output for touch detection, similar to a tactile switch, providing a straightforward 0 or 1 output.
      • The PCB is designed with 4 layers to optimize signal integrity and reliability.

πŸ›’ Requirements

DIP Version

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

Through-Hole PCB

3D model of the hardware login key’s PCB using the Through-Hole (DIP) package in KiCad

SMD Version (SOIC)

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

SMD SOIC PCB

3D model of the hardware login key’s PCB using the SMD (SOIC) package in KiCad.

SMD Version (QFN)

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

QFN PCB

3D model of the hardware login key’s PCB using the QFN package in KiCad.

SMD Version (QFN) with Reversible USB and Touch Functionality

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

QFN PCB

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.)

πŸ—οΈ 3D Printed Case

Enclosure

A 3D printed case is available for the hardware key. To use it, follow these steps:

  1. Open the 3d_printed_case folder.
  2. Load the hardware_key_case.stl file into your 3D printer software.
  3. Print the case using your 3D printer.
  4. Once printed, assemble the hardware key inside the case for added protection and aesthetics.

πŸ§‘β€πŸ’» Authors

  • Paschalis M.

πŸ‘₯ Contributors

πŸ™ Acknowledgements

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.

πŸ“œ License

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! πŸ”βœ¨

About

The Hardware Login Key is an ATtiny85-based USB device that securely automates password entry using a physical button or touch sensor. It offers a simple, hardware-driven way to log into systems or websites, with an optional 3D-printed enclosure.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published