Chris Spencer
30-Sep-2024, 06:04 AM
I downloaded the authenticator demo and found a few changes are needed to address DF24
in the cOneTimePassword.pkg.
Download Authenticator | DataFlex Downloads Center (dataaccess.com) (https://downloads.dataaccess.com/downloads/dataflex/authenticator-993#description)
Once done the authentication works a treat.
I dont know if there is a later version anywhere else
// OATH_API int HOTP(LPCSTR sSecret, int decodetype, int bitcount, int counter)
#IFNDEF get_HOTP24
External_Function HOTP24 "HOTP" oath.dll ;
Pointer sSecret ;
Integer iDecodeType ;
Integer iDigitCount ;
Pointer iCounter ;
Returns Integer
#ENDIF
// OATH_API int TOTP(LPCSTR sSecret, int decodetype, int bitcount, int hmactype, int epoch, int Time, int step)
#IFNDEF get_TOTP24
External_Function TOTP24 "TOTP" oath.dll ;
Pointer sSecret ;
Integer iDecodeType ;
Integer iDigitCount ;
Integer iHMACType ;
Pointer iEpoch ;
Pointer iTime ;
Pointer iStep ;
Returns Integer
#ENDIF
// Function : HOTP
// Purpose : HMAC-based One-time Password Algorithm
Function HOTP String sSecret Returns String
Integer iResult iDigitCount iType
BigInt iCounter
Get piSecretCodeType to iType
Get piDigitCount to iDigitCount
Get piCounter to iCounter
Move (HOTP24(AddressOf(sSecret),iType,iDigitCount,Addre ssOf(iCounter))) to iResult //<---------------------
Function_Return (Right("00000000" + String(iResult), iDigitCount))
End_Function // HOTP
// Function : TOTP
// Purpose : Time-based One-time Password Algorithm
Function TOTP String sSecret Returns String
Integer iType iResult iDigitCount iHMACType
BigInt iEpoch iTime iStep
If (sSecret = "") Begin
Error 999 "TOTP: There is no secret!"
Function_Return ""
End
Get piSecretCodeType to iType
Get piDigitCount to iDigitCount
Get piHMACType to iHMACType
Get piEpoch to iEpoch
Get piTime to iTime
Get piStep to iStep
Move (TOTP24(AddressOf(sSecret),iType,iDigitCount,iHMAC Type,AddressOf(iEpoch),AddressOf(iTime),AddressOf( iStep))) to iResult // <-------------------------
Function_Return (Right("00000000" + String(iResult), iDigitCount))
End_Function // TOTP
// Function : Base16Encode
// Purpose : Returns base16 encoded string
Function Base16Encode String sInput Returns String
String sResult
Pointer pResult //<----------------------------------
Boolean bOk
Move (otpBase16Encode(AddressOf(sInput),Length(sInput)) ) to pResult //<-----------------
Move (PointerToString(pResult)) to sResult
Move (Free(pResult)) to bOk
Function_Return sResult
End_Function // Base16Encode
// Function : Base32Encode
// Purpose : Returns base32 encoded string
Function Base32Encode String sInput Returns String
String sResult
Pointer pResult //<--------------------
Boolean bOk
Move (otpBase32Encode(AddressOf(sInput),Length(sInput)) ) to pResult
Move (PointerToString(pResult)) to sResult // <-----------------------
Move (Free(pResult)) to bOk
Function_Return sResult
End_Function // Base32Encode
in the cOneTimePassword.pkg.
Download Authenticator | DataFlex Downloads Center (dataaccess.com) (https://downloads.dataaccess.com/downloads/dataflex/authenticator-993#description)
Once done the authentication works a treat.
I dont know if there is a later version anywhere else
// OATH_API int HOTP(LPCSTR sSecret, int decodetype, int bitcount, int counter)
#IFNDEF get_HOTP24
External_Function HOTP24 "HOTP" oath.dll ;
Pointer sSecret ;
Integer iDecodeType ;
Integer iDigitCount ;
Pointer iCounter ;
Returns Integer
#ENDIF
// OATH_API int TOTP(LPCSTR sSecret, int decodetype, int bitcount, int hmactype, int epoch, int Time, int step)
#IFNDEF get_TOTP24
External_Function TOTP24 "TOTP" oath.dll ;
Pointer sSecret ;
Integer iDecodeType ;
Integer iDigitCount ;
Integer iHMACType ;
Pointer iEpoch ;
Pointer iTime ;
Pointer iStep ;
Returns Integer
#ENDIF
// Function : HOTP
// Purpose : HMAC-based One-time Password Algorithm
Function HOTP String sSecret Returns String
Integer iResult iDigitCount iType
BigInt iCounter
Get piSecretCodeType to iType
Get piDigitCount to iDigitCount
Get piCounter to iCounter
Move (HOTP24(AddressOf(sSecret),iType,iDigitCount,Addre ssOf(iCounter))) to iResult //<---------------------
Function_Return (Right("00000000" + String(iResult), iDigitCount))
End_Function // HOTP
// Function : TOTP
// Purpose : Time-based One-time Password Algorithm
Function TOTP String sSecret Returns String
Integer iType iResult iDigitCount iHMACType
BigInt iEpoch iTime iStep
If (sSecret = "") Begin
Error 999 "TOTP: There is no secret!"
Function_Return ""
End
Get piSecretCodeType to iType
Get piDigitCount to iDigitCount
Get piHMACType to iHMACType
Get piEpoch to iEpoch
Get piTime to iTime
Get piStep to iStep
Move (TOTP24(AddressOf(sSecret),iType,iDigitCount,iHMAC Type,AddressOf(iEpoch),AddressOf(iTime),AddressOf( iStep))) to iResult // <-------------------------
Function_Return (Right("00000000" + String(iResult), iDigitCount))
End_Function // TOTP
// Function : Base16Encode
// Purpose : Returns base16 encoded string
Function Base16Encode String sInput Returns String
String sResult
Pointer pResult //<----------------------------------
Boolean bOk
Move (otpBase16Encode(AddressOf(sInput),Length(sInput)) ) to pResult //<-----------------
Move (PointerToString(pResult)) to sResult
Move (Free(pResult)) to bOk
Function_Return sResult
End_Function // Base16Encode
// Function : Base32Encode
// Purpose : Returns base32 encoded string
Function Base32Encode String sInput Returns String
String sResult
Pointer pResult //<--------------------
Boolean bOk
Move (otpBase32Encode(AddressOf(sInput),Length(sInput)) ) to pResult
Move (PointerToString(pResult)) to sResult // <-----------------------
Move (Free(pResult)) to bOk
Function_Return sResult
End_Function // Base32Encode