MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / DecryptTOTPSecret

Function DecryptTOTPSecret

internal/crypto/totp.go:44–49  ·  view source on GitHub ↗

DecryptTOTPSecret decrypts a value previously written by EncryptTOTPSecret. It is strict: the stored value MUST carry the TOTPCipherPrefix marker. Callers handling a row written by an older release should detect ErrTOTPSecretNotEncrypted and treat the raw stored value as a legacy base32 secret.

(stored, key string)

Source from the content-addressed store, hash-verified

42// release should detect ErrTOTPSecretNotEncrypted and treat the raw
43// stored value as a legacy base32 secret.
44func DecryptTOTPSecret(stored, key string) (string, error) {
45 if !strings.HasPrefix(stored, TOTPCipherPrefix) {
46 return "", ErrTOTPSecretNotEncrypted
47 }
48 return DecryptAES(key, strings.TrimPrefix(stored, TOTPCipherPrefix))
49}
50
51// IsEncryptedTOTPSecret reports whether the stored value carries the
52// TOTPCipherPrefix marker. Used by the totp authenticator's lazy

Calls 1

DecryptAESFunction · 0.85