PDA

View Full Version : Google Authenticator in DF24



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

Marcia Booth
30-Sep-2024, 03:52 PM
Hi Chris,

There is no other version of the Authenticator. The Security Library (https://downloads.dataaccess.com/downloads/dataflex/security-718#description), on the other hand, is available for DataFlex 24.0 and includes an example workspace as well.

Chris Spencer
30-Sep-2024, 05:16 PM
Downloaded and looked at it. Doesn't this mean that the webapp demo as pointed to in original post needs to be brought up to date using this library?

Marcia Booth
3-Oct-2024, 12:43 PM
That is a good suggestion, Chris. Thank you.

Chris Spencer
9-Dec-2024, 07:00 PM
I see that the date on the downlaod is now Dec 6 2024.
Has this been update to fix the error reported/? and has the security library been updated too?

Download Authenticator | DataFlex Downloads Center (https://downloads.dataaccess.com/downloads/dataflex/authenticator-993#description)