+
Skip to content
/ OTP Public

otp is a program that implements a Time-Based One-Time Password (TOTP) system, adhering to RFC 6238 (TOTP) and RFC 4226 (HOTP).

Notifications You must be signed in to change notification settings

ftTower/OTP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OTP

Cybersecurity Piscine - ft_otp

Nothing ever lasts forever... header

Table of Contents


Implementation Details

Overview

The provided Python script implements a TOTP (Time-based One-Time Password) generator with encryption and decryption capabilities. It supports two main functionalities:

  1. Encrypting a 64-character hexadecimal key and securely storing it in a file.
  2. Generating a TOTP using the stored key.

Features

  • Hexadecimal Key Validation: Ensures the provided key is a valid 64-character hexadecimal string.
  • Encryption: Uses the cryptography library to encrypt the key securely.
  • Decryption: Validates the encryption key and decrypts the stored file.
  • TOTP Generation: Implements the HOTP algorithm as per RFC 4226 and generates time-based OTPs.

Usage

The script accepts the following arguments:

  • -g <key.hex>: Encrypts the provided hexadecimal key and stores it in ft_otp.key. encryption

  • -k <encrypted_file>: Decrypts the stored key and generates TOTPs. get otp new otp

Example

# Encrypt a hexadecimal key
python3 otp-generator.py -g key.hex
#Encrypting your 64 hexa password in key.hex

# Generate TOTPs using the encrypted key
python3 otp-generator.py -k ft_otp.key
#Decrypting your 64 hexa password in ft_otp.key

Error Handling

  • Invalid hexadecimal keys raise a ValueError.
  • Invalid encryption keys result in decryption failure with an appropriate error message.
  • The script handles user interruptions gracefully.

Dependencies

  • cryptography: For encryption and decryption.
  • scanf: For user input parsing.
  • Standard Python libraries: sys, hmac, base64, struct, hashlib, time.

Notes

  • The script ensures that the generated OTPs are 6 digits long.
  • The encryption key is generated dynamically and must be stored securely by the user.
  • The TOTP remains valid for 30 seconds, as per the standard.
oathtool --totp $(cat key.hex | tr -d ' \t\n\r')

About

otp is a program that implements a Time-Based One-Time Password (TOTP) system, adhering to RFC 6238 (TOTP) and RFC 4226 (HOTP).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载