TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

RFC6238 TOTP implementation in pure PostgreSQL

68 pointsby pyramationabout 4 years ago

7 comments

susamabout 4 years ago
This is very interesting if it was done for fun. However, this is very likely unsuitable for real world usage. A couple of issues I could see with a quick glance:<p>- Using &#x27;=&#x27; for comparing TOTPs in the totp.verify function[1] is not safe from timing attacks.<p>- The function random() used in the totp.random_base32 function[2] is not a cryptographically secure random number generator.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;pyramation&#x2F;totp&#x2F;blob&#x2F;7ec3104&#x2F;packages&#x2F;totp&#x2F;sql&#x2F;launchql-totp--0.0.3.sql#L111" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pyramation&#x2F;totp&#x2F;blob&#x2F;7ec3104&#x2F;packages&#x2F;tot...</a><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;pyramation&#x2F;totp&#x2F;blob&#x2F;7ec3104&#x2F;packages&#x2F;totp&#x2F;sql&#x2F;launchql-totp--0.0.3.sql#L121" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pyramation&#x2F;totp&#x2F;blob&#x2F;7ec3104&#x2F;packages&#x2F;tot...</a>
评论 #26260778 未加载
评论 #26267814 未加载
评论 #26267842 未加载
nayukiabout 4 years ago
The author&#x27;s main SQL code seems to be in this file: <a href="https:&#x2F;&#x2F;github.com&#x2F;pyramation&#x2F;totp&#x2F;blob&#x2F;master&#x2F;packages&#x2F;totp&#x2F;deploy&#x2F;schemas&#x2F;totp&#x2F;procedures&#x2F;generate_totp.sql" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pyramation&#x2F;totp&#x2F;blob&#x2F;master&#x2F;packages&#x2F;totp...</a><p>For comparison, these are my relatively short TOTP implementations in {TypeScript, Python, Java, Rust, C++}: <a href="https:&#x2F;&#x2F;www.nayuki.io&#x2F;page&#x2F;time-based-one-time-password-tools" rel="nofollow">https:&#x2F;&#x2F;www.nayuki.io&#x2F;page&#x2F;time-based-one-time-password-tool...</a> . I even have a 6-line Python function.
评论 #26259777 未加载
评论 #26260798 未加载
评论 #26260354 未加载
pyramationabout 4 years ago
Author here. Here is the full code if anyone is interested: <a href="https:&#x2F;&#x2F;github.com&#x2F;pyramation&#x2F;totp&#x2F;blob&#x2F;master&#x2F;packages&#x2F;totp&#x2F;sql&#x2F;launchql-totp--0.0.3.sql" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pyramation&#x2F;totp&#x2F;blob&#x2F;master&#x2F;packages&#x2F;totp...</a>
mattowen_ukabout 4 years ago
I can&#x27;t be the only [UK] person who sees &#x27;TOTP&#x27; and immediately thinks &#x27;Top of the Pops&#x27;! XD
steve-chavezabout 4 years ago
Cool! I remember seeing a pg TOTP implementation in this gist[1] before. Seems this extension was based off that?<p>[1]: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;bwbroersma&#x2F;676d0de32263ed554584ab132434ebd9" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;bwbroersma&#x2F;676d0de32263ed554584ab132...</a>
评论 #26268028 未加载
potatochupabout 4 years ago
Can someone explain where&#x2F;why this might be used? Or is it just for fun?
评论 #26259271 未加载
评论 #26259314 未加载
评论 #26259718 未加载
darkrabout 4 years ago
nice to see sqitch[1] in use here<p>1: <a href="https:&#x2F;&#x2F;sqitch.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sqitch.org&#x2F;</a>
评论 #26272391 未加载