This blog post explains how one-time passwords (OTPs), specifically HOTP and TOTP, work. It breaks down the process of generating these codes, starting with a shared secret key and a counter (HOTP) or timestamp (TOTP). This input is then used with the HMAC-SHA1 algorithm to create a hash. The post details how a specific portion of the hash is extracted and truncated to produce the final 6-digit OTP. It clarifies the difference between HOTP, which uses a counter and requires manual synchronization if skipped, and TOTP, which uses time and allows for a small window of desynchronization. The post also briefly discusses the security benefits of OTPs and why they are effective against certain types of attacks.
DualQRCode.com offers a free online tool to create dual QR codes. These codes seamlessly embed a smaller QR code within a larger one, allowing for two distinct links to be accessed from a single image. The user provides two URLs, customizes the inner and outer QR code colors, and downloads the resulting combined code. This can be useful for scenarios like sharing a primary link with a secondary link for feedback, donations, or further information.
Hacker News users discussed the practicality and security implications of dual QR codes. Some questioned the real-world use cases, suggesting existing methods like shortened URLs or link-in-bio services are sufficient. Others raised security concerns, highlighting the potential for one QR code to be swapped with a malicious link while the other remains legitimate, thereby deceiving users. The technical implementation was also debated, with commenters discussing the potential for encoding information across both codes for redundancy or error correction, and the challenges of displaying two codes clearly on physical media. Several commenters suggested alternative approaches, such as using a single QR code that redirects to a page containing multiple links, or leveraging NFC technology. The overall sentiment leaned towards skepticism about the necessity and security of the dual QR code approach.
Summary of Comments ( 56 )
https://news.ycombinator.com/item?id=43653322
HN users generally praised the article for its clear explanation of HOTP and TOTP, breaking down complex concepts into understandable parts. Several appreciated the focus on building the algorithms from the ground up, rather than just using libraries. Some pointed out potential security risks, such as replay attacks and the importance of secure time synchronization. One commenter suggested exploring WebAuthn as a more secure alternative, while another offered a link to a Python implementation of the algorithms. A few discussed the practicality of different hashing algorithms and the history of OTP generation methods. Several users also appreciated the interactive code examples and the overall clean presentation of the article.
The Hacker News post titled "Behind the 6-digit code: Building HOTP and TOTP from scratch" has generated several comments discussing various aspects of one-time passwords (OTPs).
Some users delve into the technical details. One comment explains the importance of the counter value in HOTP (HMAC-based One-Time Password algorithm), highlighting how discrepancies between the server's and client's counter can lead to synchronization issues and failed logins. They suggest potential solutions like resynchronization mechanisms where the server accepts a range of OTPs or the use of TOTP (Time-based One-Time Password algorithm) which relies on time synchronization instead of counters.
Another user questions the necessity of implementing OTP generation from scratch, arguing that existing libraries are generally robust and well-tested. They express concern about potential security vulnerabilities if the implementation isn't carefully vetted. This spurs a discussion about the educational value of building such systems from scratch, with proponents highlighting the deeper understanding gained through the process. This understanding is contrasted with the potential dangers of blindly relying on libraries without comprehending their inner workings.
The discussion also touches on practical considerations. One comment emphasizes the crucial role of proper secret key management, highlighting the risks associated with weak keys. Another user discusses the usability aspects of OTPs, mentioning potential accessibility challenges for users with certain disabilities. The comment suggests alternative authentication methods might be necessary in such cases to ensure inclusivity.
Finally, some users share their personal experiences and preferences regarding different OTP methods. Some prefer authenticator apps while others express skepticism due to the potential inconvenience of losing access to their devices. The conversation around alternative authentication schemes also covers push notifications, SMS-based OTPs, and WebAuthn, briefly touching upon their respective security and usability trade-offs. A recurring theme in these discussions is the importance of striking a balance between security and user experience when choosing an authentication mechanism.