Initiative for Open Authentication
The Initiative for Open Authentication (OATH) is an industry-wide collaboration to develop an open reference architecture using open standards to promote the adoption of strong authentication. They publish the standard which Google Authenticator and other common 2-factor applications use.
The following packages can be used to generate, transfer, and validate OATH credentials:
- - Takes credentials and generates codes. Includes a PAM module for user authentication.
google-authenticatorfor generating new credentials and a PAM module for user authentication. See Google Authenticator.
- Offers a client program
- - Adds OATH support to
- - Decodes QR codes
- - Encodes QR codes
OATH has created two standards of significance to an Arch user, both based on a Base32-encoded shared secret of arbitrary length:
- HMAC (Hash-based message authentication code) One-time Password (HOTP). Every time a password is generated, a counter is incremented. This value is concatenated with a secret key, and then hashed to generate a 6-10 digit code. The authenticating party does the same, except it increments a counter when a code is successfully authenticated. To handle desynchronization of the counter, the authenticating party can also check several (30-100) additional values beyond its current counter state.
- Time-based one-time-password (TOTP), which works much like HOTP except it uses the current time instead of a counter. This solves the desynchronization problem, and eliminates the possibility of an adversary recording OTPs for use later.
URI credential format
Credentials are usually shared in a QR-encoded URI format. All fields must be URI-encoded strings:
- Identifies which account a key is associated with, optionally prefixed with an issuer string. Example:
- Take the standard URI parameter format -
secret- required; this is the Base32 shared secret.
issuer- Indicates the provider or service the account is associated with. If this is absent, the issuer prefix of the label will be used. If both are present, they should be equal.
SHA1by default. Can also be
digits- How long passcodes should be. Default is 6, can be 8.
counter- Required if using HOTP. Initial counter value.
period- Optional if using TOTP. Sets how long a code is valid, 30 seconds by default.
Here is an example:
otpauth://totp/Example%20Company:firstname.lastname@example.org?secret=JBSWY3DPEHPK3PXP&issuer=Example%20Company |type| issuer prefix | account | secret | issuer | | label | parameters |
Tips and Tricks
Decode QR codes
This can be accomplished with tools from. Decode a PNG file:
$ zbarimg my_qr_code.png --quiet --raw
Decode images from a camera:
$ zbarcam /dev/video0
Create QR codes
Thepackage is useful here.
Encode a URI, save it as a PNG:
$ qrencode -o my_code.png 'MY_URI'
Encode a URI, print a QR code to the terminal:
$ qrencode -t ansiutf8 'MY_URI'
To generate your own key in the proper format, you can use something like the following:
$ head -c 16 /dev/urandom | base32 --wrap 0
Generate OTPs from the command line
$ oathtool --base32 --totp KEY