1. Integration API configuration
BaroPAM-related dynamic linking library is used to verify the one-time authentication key.
API | Documentation | Etc |
barokey.h libbarokey.dll |
Unmanaged C++ dll version for C# related to BaroPAM. (.Compiled based on .NET Framework 4.0) |
|
barokey_clr.h barokey_clr.dll |
BaroPAM related clr version, managed C++ dll version for C#. (.Compiled based on .NET Framework 4.0) |
|
libcrypto-1_1-x64.dll libssl-1_1-x64.dll |
Open SSL related dlls |
Note) To use the BaroPAM related dll, it must be located in the "C:\Windows\System32" directory.
The header file for BaroPAM, a one-time authentication key, is as follows.
barokey.h)
#ifndef _BAROKEY_API_H_ #define _BAROKEY_API_H_ #ifdef BAROPAMCORE_EXPORTS #define BAROPAMCORE_API __declspec(dllexport) #else #define BAROPAMCORE_API __declspec(dllimport) #endif #ifdef __cplusplus extern "C" { #endif BAROPAMCORE_API BOOL BARO_ENCRYPT(const char* data, char* enc_result, unsigned long buf_len); BAROPAMCORE_API BOOL BARO_DECRYPT(const char* data, char* dec_result, unsigned long buf_len); BAROPAMCORE_API BOOL BARO_GENERATEKEY(const char* login_id, const char* phone_no, const char* cycle_time, char* ota_key, unsigned long buf_len); BAROPAMCORE_API BOOL BARO_VERIFYKEY(const char* login_id, const char* phone_no, const char* cycle_time, char* ota_key); BAROPAMCORE_API char* BARO_ENCRYPTA(const char* data); BAROPAMCORE_API char* BARO_DECRYPTA(const char* data); BAROPAMCORE_API char* BARO_GENERATEKEYA(const char* login_id, const char* phone_no, const char* cycle_time); BAROPAMCORE_API bool BARO_VERIFYKEYA(const char* login_id, const char* phone_no, const char* cycle_time, char* ota_key); BAROPAMCORE_API wchar_t* BARO_ENCRYPTSW(const wchar_t* data); BAROPAMCORE_API wchar_t* BARO_DECRYPTSW(const wchar_t* data); BAROPAMCORE_API wchar_t* BARO_GENERATEKEYW(const wchar_t* login_id, const wchar_t* phone_no, const wchar_t* cycle_time); BAROPAMCORE_API bool BARO_VERIFYKEYW(const wchar_t* login_id, const wchar_t* phone_no, const wchar_t* cycle_time, wchar_t* totp); #ifdef __cplusplus } #endif #endif //_BAROKEY_API_H_ |
Barokey_clr.h)
#pragma once using namespace System; namespace BaroPAM { public ref class BaroKeyCLR { // TODO: Add your methods for this class here. // in libbarokey.lib /* BAROPAMCORE_API wchar_t* BARO_ENCRYPTSW(const wchar_t* data); BAROPAMCORE_API wchar_t* BARO_DECRYPTSW(const wchar_t* data); BAROPAMCORE_API wchar_t* BARO_GENERATEKEYW(const wchar_t* login_id, const wchar_t* phone_no, const wchar_t* cycle_time); BAROPAMCORE_API bool BARO_VERIFYKEYW(const wchar_t* login_id, const wchar_t* phone_no, const wchar_t* cycle_time, wchar_t* totp); */ protected: //BaroPAMCore* m_baropam = nullptr; public: // TODO: Add your methods for this class here. BaroKeyCLR(void); ~BaroKeyCLR(void); String^ BARO_ENCRYPTW(String^ data); String^ BARO_DECRYPTW(String^ data); String^ BARO_GENERATEKEYW(String^ login_id, String^ phone_no, String^ cycle_time); bool BARO_VERIFYKEYW(String^ login_id, String^ phone_no, String^ cycle_time, String^ ota_key); String^ BARO_ENCRYPTA(String^ data); String^ BARO_DECRYPTA(String^ data); String^ BARO_GENERATEKEYA(String^ login_id, String^ phone_no, String^ cycle_time); bool BARO_VERIFYKEYA(String^ login_id, String^ phone_no, String^ cycle_time, String^ ota_key); }; } |
2. Integration API function
1) BARO_VERIFYKEYA function(If you are using Unmanaged C++ dll)
- NAME
BARO_VERIFYKEYA
- SYNOPSIS
BOOL BARO_VERIFYKEY(const char* login_id, const char* phone_no, const char* cycle_time, char* ota_key)
- DESCRIPTION
A function that verifies whether the entered one-time authentication key is correct.
login_id: Set the ID entered in the login-ID field of the login screen.
phone_no: Login-ID set user's smart phone number only with numbers.
cycle_time: Set the generation cycle (3~60 seconds) of one-time authentication key
specified for each user.
ota_key: Set the one-time authentication key created and entered in the BaroPAM app on the
login screen.
If the generation period of the smart phone number for each user and the one-time authentication key designated for each individual is different from the generator of the one-time authentication key, verification may fail because the one-time authentication key is different. You must match the information.
- RETURN VALUES
On success, true is returned, and on failure, false is returned.
2) BARO_VERIFYKEYA function(In case of clr version supporting single byte)
- NAME
BARO_VERIFYKEYA
- SYNOPSIS
bool BARO_VERIFYKEYA(String^ login_id, String^ phone_no, String^ cycle_time, String^ ota_key)
- DESCRIPTION
A function that verifies whether the entered one-time authentication key is correct.
login_id: Set the ID entered in the login-ID field of the login screen.
phone_no: Login-ID set user's smart phone number only with numbers.
cycle_time: Set the generation cycle (3~60 seconds) of one-time authentication key
specified for each user.
ota_key: Set the one-time authentication key created and entered in the BaroPAM app on the
login screen.
If the generation period of the smart phone number for each user and the one-time authentication key designated for each individual is different from the generator of the one-time authentication key, verification may fail because the one-time authentication key is different. You must match the information.
- RETURN VALUES
On success, true is returned, and on failure, false is returned.
3) BARO_VERIFYKEYW function(For the clr version that supports Unicode)
- NAME
BARO_VERIFYKEYW
- SYNOPSIS
bool BARO_VERIFYKEYW(String^ login_id, String^ phone_no, String^ cycle_time, String^ ota_key)
- DESCRIPTION
A function that verifies whether the entered one-time authentication key is correct.
login_id: Set the ID entered in the login-ID field of the login screen.
phone_no: Login-ID set user's smart phone number only with numbers.
cycle_time: Set the generation cycle (3~60 seconds) of one-time authentication key
specified for each user.
ota_key: Set the one-time authentication key created and entered in the BaroPAM app on the
login screen.
If the generation period of the smart phone number for each user and the one-time authentication key designated for each individual is different from the generator of the one-time authentication key, verification may fail because the one-time authentication key is different. You must match the information.
- RETURN VALUES
On success, true is returned, and on failure, false is returned.
3. Authentication key verification part
When configuring the Visual Studio environment, you must set "x64" in "Platform" in "Configuration Manager". If not, just click "new" to register.
After creating a C# .NET Framework project, click "Add References…" in the project in Solution Explorer.
After creating a C# .NET Framework project, register "barokey_clr.dll" in References in the project in Solution Explorer.
Example) BARO_VERIFYKEYA function (when using Unmanaged C++ dll)
How to pass const char * to C function in C# is as follows.
const char* is a string in .NET. On the managed side, I don't understand the concept of read-only parameters.
When this is used in P/Invoke context, MarshalAs property must be declared and marshaled to LPStr.
The resulting signature is:
[DllImport("SomeModule.dll")] public static extern void set_param([MarshalAs(UnmanagedType.LPStr)]string lpString); |
using System; using System.Text; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; //this namespace is for sqlclient server using System.Configuration; // this namespace is add I am adding connection name in web config file config connection name using System.Runtime.InteropServices; //DLL support namespace WebApplication1 { public partial class _Default : Page { [DllImport("libbarokey.dll", CallingConvention = CallingConvention.Cdecl)] extern public static bool BARO_VERIFYKEYA( [MarshalAs(UnmanagedType.LPStr)] String login_id ,[MarshalAs(UnmanagedType.LPStr)] String phone_no ,[MarshalAs(UnmanagedType.LPStr)] String cycle_time ,[MarshalAs(UnmanagedType.LPStr)] String ota_key ); protected void Page_Load(object sender, EventArgs e) { } protected void btnCert_Click(object sender, EventArgs e) { try { String strLogin_id = txtLogin_id.Text; String strKey = txota_key.Text; bool chkKey = false; String strPhone_no = "01027714076"; String strCycle_time = "30"; chkKey = BARO_VERIFYKEYA( strLogin_id, strPhone_no, strCycle_time, strKey ); if (chkKey == true) { lblMessage.Text = "One-time authentication key verification success......!!"; } else { lblMessage.Text = "One-time authentication key verification failure......!!"; } } catch (Exception ex) { Response.Write(ex.Message); } } } } |
Ex) BARO_VERIFYKEYA / BARO_VERIFYKEYW function (if using clr version)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace BaroKeyCLR_Test { public partial class Form1 : Form { //BaroKEY(C++/CLI)용 객체를 선언. BaroPAM.BaroKeyCLR barokey = new BaroPAM.BaroKeyCLR(); public Form1() { InitializeComponent(); inLoginID.Text = "User"; inPhoneNo.Text = "01042483224"; } private void btnVerify_Click(object sender, EventArgs e) { try { String strLogin_id = inLoginID.Text; String strPhone_no = inPhoneNo.Text; String strCycle_time = "30"; String strOta_key = outOtaKey.Text; //BaroKEY(C++/CLI)용 객체에서 해당 API를 사용.(Single Byte용) bool bRet = barokey.BARO_VERIFYKEYA(strLogin_id, strPhone_no, strCycle_time, strOta_key); if (!bRet) { MessageBox.Show(string.Format(">>\n{0}\n{1}\n{2}\n{3}\n--ID or PASSWORD doesn't match. \nRetry please." , strLogin_id, strPhone_no, strCycle_time, strOta_key)); } else { MessageBox.Show("OK"); } } catch (Exception ex) { MessageBox.Show("DLL Load error : " + ex.Message); } } //UNICODE private void button1_Click(object sender, EventArgs e) { try { String strLogin_id = inLoginID.Text; String strPhone_no = inPhoneNo.Text; String strCycle_time = "30"; String strOta_key = outOtaKey.Text; //BaroKEY(C++/CLI)용 객체에서 해당 API를 사용한다.(UNICODE 용) bool bRet = barokey.BARO_VERIFYKEYW(strLogin_id, strPhone_no, strCycle_time, strOta_key); if (!bRet) { MessageBox.Show(string.Format(">>\n{0}\n{1}\n{2}\n{3}\n--ID or PASSWORD doesn't match. \nRetry please." , strLogin_id, strPhone_no, strCycle_time, strOta_key)); } else { MessageBox.Show("OK"); } } catch (Exception ex) { MessageBox.Show("DLL Load error : " + ex.Message); } } } } |
Ex) verifyKEY function (when using barokey.jar, a Java library module)
Sequence of the work)
1) Download ikvmbin-7.2.4630.5.zip
ikvm is a tool that converts a Java module (jar) into a dll for use in C#.
Download: https://osdn.net/projects/sfnet_ikvm/downloads/ikvm/7.2.4630.5/ikvmbin-7.2.4630.5.zip/
2) Unzip ikvmbin-7.2.4630.5.zip
Unzip ikvmbin-7.2.4630.5.zip into "C:\Program Files (x86)\" directory.
3) Setting the environment variable (PATH)
4) Compile barokey.java (compiled in java version "1.7.0_79")
C:\work\etc> javac barokey.java |
5) Create barokey.jar file
C:\work\etc> jar cf barokey.jar barokey.class |
6) Convert barokey.jar file to barokey.dll file through ikvm
C:\work\etc> ikvm barokey.jar |
7) Add the barokey.dll file to the references of the C# project
After creating a C# .NET Framework project, register "barokey.dll" in References in the project in Solution Explorer.
8) Call verifyKEY() method in C# program
… public bool getOTACheck(String login_id, String phone_no, String cycle_time, String ota_key) { bool retVal = false; try { retVal = barokey.verifyKEY(login_id, phone_no, cycle_time, ota_key); } catch (Exception ex) { throw new Exception(throwEx(ex)); } return retVal; } … |
4. Notes (IIS environment)
Describes how to switch between the 32-bit version of Microsoft ASP.NET 1.1 and the 32-bit version and 64-bit version of ASP.NET 2.0 on the 64-bit version of Microsoft Windows.
If you have installed both versions of ASP.NET, you may receive an error message if you do not follow the steps to set up each ASP.NET environment to run on Microsoft Internet Information Services (IIS) 6.0. For example, if ASP.NET is not set up properly, you may receive the following error message on a web page:
Service unavailable |
Error messages similar to the following may be logged in the application log:
IIS 6.0 supports both 32-bit mode and 64-bit mode, but it does not support running both modes simultaneously on a 64-bit version of Windows. ASP.NET 1.1 runs only in 32-bit mode, and ASP.NET 2.0 runs in 32-bit mode and 64-bit mode. So, to run ASP.NET 1.1 and ASP.NET 2.0 at the same time, you need to run IIS in 32-bit mode.
1) ASP.NET 1.1, 32-bit version
To run the 32-bit version of ASP.NET 1.1:
① Click Start, click Run, type cmd, and click OK.
② Enter the following command to enable 32-bit mode.
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1 |
③ Install the ASP.NET 1.1 version by entering the following command and install the script map
under the IIS root and then:
%SYSTEMROOT%\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe –i |
④ Check that the status of ASP.NET version 1.1.4322 is set to Allowed in the list of web service
extensions in Internet Information Services Manager.
2) ASP.NET 2.0, 32-bit version
To run the 32-bit version of ASP.NET 2.0:
① Click Start, click Run, type cmd, and click OK.
② Enter the following command to enable 32-bit mode.
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1 |
③ Enter the following command to install the ASP.NET 2.0 (32-bit) version and install the script
map under the IIS root and then:
%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i |
④ Make sure that the status of ASP.NET version 2.0.50727 (32-bit) is set to Allowed in the list
of Web service extensions in Internet Information Services Manager.
3) ASP.NET 2.0, 64-bit version
To run the 64-bit version of ASP.NET 2.0:
① Click Start, click Run, type cmd, and click OK.
② Enter the following command to disable 32-bit mode.
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 0 |
③ Install the ASP.NET 2.0 version by entering the following command and install the script map
under the IIS root and then:
%SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i |
④ In Internet Information Services Manager, in the list of Web service extensions, verify that
the status of ASP.NET version 2.0.50727 is set to Allowed.
Note) The build version of ASP.NET 2.0 may differ depending on the currently released build version. The above steps correspond to build version 2.0.50727.
'▶ BaroSolution > 가이드' 카테고리의 다른 글
BaroPAM solution's API guide for no-remember passwords(C) (0) | 2021.02.23 |
---|---|
BaroPAM solution's API guide for no-remember passwords(dll) (0) | 2021.02.13 |
BaroPAM solution's API guide for no-remember passwords(NodeJS web server) (0) | 2021.02.03 |
BaroPAM solution's API guide for no-remember passwords(Java) (0) | 2021.02.01 |
기억할 필요 없는 비밀번호를 위한 BaroPAM의 API 가이드(NodeJS 웹 서버) (0) | 2021.01.29 |