
<p>
Oathtool</p>
<p>
<br>
</p>
<p>
<strong>
06 OATH Options and Oathtool</strong>
</p>
<p>
The OATH standard has several options.</p>
<p>
You need to know which OATH options the site you wish to log into uses in order to use OATH.</p>
<p>
<br>
</p>
<p>
<strong>
07 Options - TOTP versus HOTP</strong>
</p>
<p>
There are two different types of OATH one time passwords, HOTP and TOTP.</p>
<p>
HOTP uses a counter.&nbsp;</p>
<p>
I won't go into more detail on HOTP as I haven't come across anyone using it.</p>
<p>
TOTP uses the current time instead of a counter.</p>
<p>
The time is fed into the OATH algorithm along with the shared secret to generate a new password on both ends of the connection.</p>
<p>
All the instances of OATH that I am familiar with use TOTP.</p>
<p>
<br>
</p>
<p>
<strong>
08 TOTP Mode</strong>
</p>
<p>
Totp has different "modes".</p>
<p>
These modes are hash encoding algorithms such as SHA1, SHA256, or SHA512.</p>
<p>
The correct mode must be selected in order to log in using OATH with TOTP.</p>
<p>
<br>
</p>
<p>
<strong>
09 Encoding - Hex versus Base32</strong>
</p>
<p>
Both ends of the connection must be initialized with a shared secret or key which is required as part of the OATH algorithm.</p>
<p>
This key could be encoded in one of two forms, either hexadecimal or base32.</p>
<p>
Web sites often do not document which encoding method they are using.</p>
<p>
If you cannot determine the encoding of the key by simply looking at it you may need to use trial and error during your first OATH log in attempts to see which type of key has been used.</p>
<p>
<br>
</p>
<p>
<strong>
10 Github and Pypi Options</strong>
</p>
<p>
Github and Pypi are two of the most prominent web sites using OATH.</p>
<p>
Both use the same options, TOTP with SHA1 mode, and base32 encoding.</p>
<p>
<br>
</p>
<p>
<br>
</p>
<p>
<strong>
11 Using Oathtool</strong>
</p>
<p>
oathtool is a simple command line application which generates one time passwords for use with OATH.</p>
<p>
It can be run in a terminal.</p>
<p>
However, can also be turned into a simple GUI application using Zenity. Will discuss this in more detail later.</p>
<p>
By default oathtool uses hotp and hex encoding.</p>
<p>
To use totp and base32 encoding you must specify these on the command line.</p>
<p>
To specify base32 encoding for use with for example Github, pass the "-b" or "--base32" argument on the command line.</p>
<p>
To specify TOTP, pass the "--totp" argument on the command line.</p>
<p>
By default, oathtool uses SHA1 with totp, so you don't need to specify that if you require SHA1.</p>
<p>
If you need a different TOTP mode, you specify that as part of the TOTP argument separated by an "=" character. For example "--totp=SHA256".</p>
<p>
<br>
</p>
<p>
<strong>
12 Oathtool Example</strong>
</p>
<p>
Here is a simple example of using oathtool to create a one time password to use with Github or Pypi.</p>
<p>
Open a terminal and type the following.</p>
<p>
<br>
</p>
<p>
oathtool -b&nbsp;--totp SOMEBIGBASE32SECRETCODE</p>
<p>
<br>
</p>
<p>
The one time password will be printed out in the terminal.</p>
<p>
You can try this out without using a valid key so long as it is a valid base32 string.</p>
<p>
When used with a valid key you then enter that one time password into Github, Pypi, or other web site where it asks for the one time password.</p>
<p>
Note that I have not covered in the above how to store and retrieve the key securely, as that is too big of a topic to cover here.&nbsp;</p>
<p>
<br>
</p>
<p>
<br>
</p>
<p>
<strong>
13 Zenity Example</strong>
</p>
<p>
Oathtool is a command line application, but if you are using Linux it is simple to convert it into a GUI application by using "Zenity".</p>
<p>
Zenity is a simple to use package that creates GUI windows on the command line or in a shell script.</p>
<p>
There are two steps to the proceess.</p>
<p>
First create the OTP from the key by using oathtool and save it in a variable.</p>
<p>
Next, call a Zenity "info" window with the OTP as part of the provided text.</p>
<p>
You can now copy and paste the OTP from the window into your web browser.</p>
<p>
To close the window, click on the "OK" button.</p>
<p>
See the previous note on storing the key securely.&nbsp;</p>
<p>
<br>
</p>
<p>
hprcode=$(oathtool -b&nbsp;--totp SOMEBIGBASE32SECRETCODE)</p>
<p>
zenity --info --width=150 --title="HPR 2FA" --text="&lt;big&gt;2FA code is:&lt;/big&gt; \n\n $hprcode \n"</p>
<p>
<br>
</p>
<p>
If you are using Gnome you can make the script launchable from the desktop by creading a ".desktop" file in the "Desktop" directory.</p>
<p>
<br>
</p>
<p>
<br>
</p>


