code wiki / (root) / totp_uri.nx

totp_uri.nx

buildroot/runtime/totp_uri.nx

6055 B176 linesdepth 4pulls 5 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

syscalls.nx base32.nx url.nx totp_uri.nx

imports: syscalls.nxbase32.nxurl.nx

imported by: nobody (leaf or entry point)

structs

none

consts

33const TU_ERR_SHORT: i64 = -1

functions

36func tu_put(out: *u8, cap: i64, off: i64, src: *u8, n: i64) -> i64 {
called by 1: totp_uri_build
48func tu_put_enc(out: *u8, cap: i64, off: i64,
60func tu_put_dec(out: *u8, cap: i64, off: i64, v: i64) -> i64 {
97func totp_uri_build(out: *u8, cap: i64,
calls 1: tu_put
146func main() -> i64 {