code wiki / (root) / nx_totp_uri.nx

nx_totp_uri.nx

buildroot/runtime/nx_totp_uri.nx

6149 B182 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind orphan librarytopic totp
docsdependenciesstructsconstsfunctions

about

totp_uri.nx -- build otpauth:// enrollment URIs. Google Authenticator Key URI Format (de-facto standard, used by Authy / 1Password / Microsoft Authenticator / Duo). A QR code encodes this URI; scanning provisions a new OTP account. Shape: otpauth://totp/Label?secret=BASE32SECRET&issuer=Name&algorithm=SHA1 &digits=6&period=30 Label is typically \"Issuer:user@example.com\" (colon-separated). Secret is a base32-encoded arbitrary-length key -- 20 bytes is the RFC 6238 recommended length for SHA-1. Composes base32.nx (for secret encoding) + url.nx (for percent-encoding the label + issuer). Invariants: TU1 Secret bytes are base32-encoded with '=' padding stripped (most authenticator apps tolerate padding but some reject it). TU2 Label / issuer percent-encoded so `@`, spaces, `:` are safe in the URI. TU3 Default params (digits=6, period=30, algo=SHA1) match what Google Authenticator assumes on missing params. We emit them anyway for clarity + compat with strict parsers.

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_base32.nx nx_url_canonical.nx nx_totp_uri.nx

imports: nx_syscalls.nxnx_base32.nxnx_url_canonical.nx

imported by: nobody (leaf or entry point)

structs

none

consts

39const TU_ERR_SHORT: i64 = -1

functions

42func tu_put(out: *u8, cap: i64, off: i64, src: *u8, n: i64) -> i64
called by 1: totp_uri_build
54func tu_put_enc(out: *u8, cap: i64, off: i64,
66func tu_put_dec(out: *u8, cap: i64, off: i64, v: i64) -> i64
calls 1: sys_mmap
103func totp_uri_build(out: *u8, cap: i64,
calls 1: tu_put
152func main() -> i64