TOTP.EXE 
(MD5   7b31ebb4505ad3d5d6398997e1cc8036)
(SHA-1 26e77cfaa8f5c25d99038fe3fcfda7d1ccb89d19)


Copyright (c) 2025 Axel Meiss

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Introduction

Today, Two-Factor-Authentication (2FA) is a common way of authentication of a user to a system. Usually, the standard method of authentication is the login by supplying a login-id (user name) and a password. In the past decades it has become obvious that this method alone may not be sufficient anymore to protect systems from unauthorized access. So, engineers have devised a strategy to overcome this problem by adding another method of authentication. A good way to do this is to create a temporary code which will be given to the user. This temporary code will only be valid for seconds or minutes and which has to be entered by user. This temporary code shall be called One-Time Password (OTP). Preferably, this code will be submitted to the user to a separate device. A widely used method is sending the user an SMS which holds the temporary code. Many users have already encountered this procedure. A different way of creating a temporary code is letting a device _calculate_ a valid OTP. Based on a secret that both the system and the user hold, an OTP is created using cryptographic functions which should make it highly improbable for eaves-dropper to predict OTPs without having the secret. Engineers have come up with a solution using time as the base of the calculation and called the baby "Time-based One-Time Password" (TOTP). Calculating the TOTP is actually what the attached program does. 
For smartphones there are plenty of apps which perform this calculation, notably the Google Authenticator. There are also TOTP-generators online available. For me, it was a programming task which I wanted to complete, having a stand-alone application on my computer. Actually, the OS/2 version is a byproduct.

Description

The TOTP program is a command line utility that creates Time-based One-Time Passwords based on the computer's clock and a secret. The secret is a base32-string which will be internally converted to binary data. The algorithm is derived from the following RFC:

RFC 2104 HMAC: Keyed-Hashing for Message Authentication
RFC 4226 HOTP: An HMAC-Based One-Time Password Algorithm
RFC 6238 TOTP: Time-Based One-Time Password Algorithm

The program loops indefinitely and should be stopped using <Ctrl-C>


Syntax

totp.exe <time interval in seconds> <count of displayed digits> <base32-string>

<time interval>             between 1 and 60. RFC6238 defaults to 30 seconds
<count of displayed digits> between 6 and 10. Defaults to 6 digits
<base32-string>             string consisting only of characters A-Z and the digit characters 2-9 (0 and 1 are omitted)
                            this string should have a length of a multiple of 8 (8,16,24,32,40...) otherwise it will produce invalid codes

 
Remarks
After having created the TOTP-generator for my internal use I was wondering if there was an OS/2 TOTP-generator. I could not find one on hobbesarchive.com (Thanks for supplying and maintening this archive!). That is why I created the OS/2 version of it to let OS/2 users have a native TOTP-generator.  
This program has been compiled using OpenWatcom 1.9 on an eComStation 1.2 installation in VirtualBox. So, it should be executable on any system based on OS/2 4.52. I haven't tested it on previous versions but it may be as well executable on OS/2 3.0.
Source code is not supplied because there are plenty of sources on Github or www.rosettacode.org. I did not use any of them. Instead, I encourage programmers to create their own version of a TOTP-generator because I think it is an interesting and rewarding programming task. 
TOTP may use different hashing algorithms, proposed are SHA-1, SHA-256, SHA-512. I only implemented SHA-1 which is most widely used.
The program is free of charge but if you like the program or if you use it regularly you may donate the amount of $1 or EUR 1 via PayPal
to this email address:
jungfernschreiber@gmail.com

Thanks for using OS/2
Axel 





