如果能让你成为双因素认证设备,那该多好。
MTOTP: Wouldn't it be nice if you were the 2FA device?

原始链接: https://github.com/VBranimir/mTOTP/tree/develop

## mTOTP:人工驱动的双因素认证 mTOTP 是一种实验性的、手动计算的时间型一次性密码 (TOTP),专为*没有*电子 2FA 设备的场景设计。与标准的 TOTP 不同,它优先考虑人工计算、可审计性和确定性——这意味着相同的输入*始终*产生相同的输出。它有意允许为特定未来的登录时间进行预计算,使时间成为身份验证过程中的明确且约定的元素。 该过程使用一个 10 位数的密钥和一个计划的登录时间,通过一系列确定性步骤生成一个 6 位数的 OTP:构建时间向量、从密钥创建数字替换“S-box”、组合时间和密钥数字、应用 S-box、通过模运算扩散数字,最后,折叠并计算最终数字。 至关重要的是,mTOTP 避免了随机性。软件可以*验证*手动生成的代码,但核心计算设计为可以精神执行(通过练习)。正在开发 PAM 模块和 Keycloak 集成等工具来支持其使用。

## mTOTP:可人工计算的二因素认证 - 摘要 一 Hacker News 讨论围绕“mTOTP”项目展开,该项目旨在利用人工计算作为身份验证的第二因素(github.com/vbranimir)。核心思想是让用户心算基于时间的 One-Time Password (TOTP),而不是依赖应用程序或硬件令牌。 虽然有趣,但评论员们争论这是否真正符合*双因素认证*的定义。 担忧在于,这本质上是一个更复杂的密码——“你知道的东西”,而不是“你拥有的东西”。 安全性依赖于记住密钥并执行计算,如果密钥泄露或使用几个正确的 OTP 进行暴力破解,则容易受到攻击。 然而,支持者认为,只要密钥不直接输入,它就能提供一定程度的安全性,尤其是在防范网络钓鱼方面。 这就像将你的大脑用作保存密钥的“设备”。 该项目被呈现为一个早期的实验,积极寻求贡献以提高其安全性和实用性。
相关文章

原文

It takes a special kind of geek to not carry a 2FA device. One who becomes the 2FA.

mTOTP is an experimental, manual variant of TOTP designed to be computed by a human without electronic devices. It explores the limits of time-based authentication under strict human constraints and makes no claims of cryptographic equivalence to standard TOTP.


mTOTP is a human‑executable OTP scheme designed to be:

  • deterministic
  • mentally doable (with practice)
  • auditable and explainable
  • reproducible by both humans and software

This protocol intentionally allows OTPs to be calculated for future times. Rather than treating this as a limitation, it makes it a requirement: the user must know when they intend to authenticate, and the verifier checks against that agreed moment. Time is therefore not an approximation, but an explicit part of the protocol - Turning authentication time from reactive to intentional. This document describes the exact algorithm used by the tool, written for humans first.

This protocol is designed for human execution first, with software acting as a helper and verifier.
Clarity, determinism, and mental tractability are intentional design goals.

pam_mtotp SSH demo

An mTOTP is generated from:

  • a secret numeric key
  • a planned login time

The algorithm uses:

  • a key‑derived digit S‑box
  • digitwise modular arithmetic
  • a simple diffusion step
  • a deterministic fold into a 6‑digit OTP

No randomness is involved during generation.


  • Secret key (10 digits): 1234598760
    (If your key is shorter than 10 digits, pad or derive it consistently before use.)

  • Planned login time:
    2026‑01‑17 17:00


Step 1 - Build Time Vector

Convert the planned login time into the format, take into account that you are calculating for the server-side set time:

Example:

2026‑01‑17 17:00 → 2601171700

Result:


Step 2 - Build Sbox from the Secret Key

The S‑box is a digit substitution table (0–9 → 0–9) derived only from the secret key. S-box (Substitution Box) is a digit-remapping table that replaces each digit (0–9) with another digit to introduce non-linearity. It is derived deterministically from the secret key by writing down each digit the first time it appears in the key, then appending any missing digits (0–9) in order; the position is the input digit and the value is the output digit.

  1. Read the key left to right
  2. Write down each digit the first time it appears
  3. Ignore repeated digits
  4. Append any missing digits (0–9) at the end, in normal order
  5. The position is the input digit
    The value is the output digit

Secret key:

Unique digits in order:

Final S‑box list:

S‑box table:

Input :  0 1 2 3 4 5 6 7 8 9
Output:  1 2 3 4 5 9 8 7 6 0

Step 3 - Combine Time and Key (mod 10)

Add the time digits and key digits position‑by‑position, using mod 10.

Time: 2601171700
Key : 1234598760
----------------
Result: 3835669460

Call this:


Step 4 - Apply Sbox Substitution

Replace each digit of C using the S‑box table.

Mapping from Step 2:

0→1  1→2  2→3  3→4  4→5
5→9  6→8  7→7  8→6  9→0

Apply to:

Result:


Step 5 - Diffusion (Digit Mixing)

Diffusion mixes the digits so each position depends on the previous result: starting with the last digit, each digit is replaced by the sum of itself and the previous output (mod 10). This ensures that changing a single digit affects all following digits while remaining simple enough to do mentally.

  1. Set:
  1. For each digit from left to right:
new_digit = (current_digit + a) mod 10
a = new_digit

Start:

Diffused result:

(Length is always preserved.)


Step 6 - Fold to 5 Digits

Pair digits from the front and back and add them mod 10 like folded in half:

or:

(c1+c6) (c2+c7) (c3+c8) (c4+c9) (c5+c10)

From our last step result:

Calculation:

5+0 = 5
1+0 = 1
5+5 = 0
4+3 = 7
2+4 = 6

Result:


Step 7 - Calculate Final Digit (o6)

Add the five OTP digits and take mod 10:

(5+1+0+7+6) mod 10 = 19 mod 10 = 9


Invariants & Sanity Checks

  • S‑box is derived only from the key
  • Length stays 10 digits until folding
  • S‑box substitution never changes length
  • Diffusion always uses the previous result
  • Final OTP is always 6 digits

Tool README

PAM module

Keycloak module

联系我们 contact @ memedata.com