SentinelKeys theKey =newSentinelKeys();
// class for the key SentinelKeysLicense theLicense =newSentinelKeysLicense(); // class for the license
declare the following
variables to use with the2 classes.
long DeveloperID; // Developer ID of Sentinel Keys key int[] licHandle =new int[1];
// Handle for License
int
status;
// The Sentinel Keys API return codes
acquire a License from the
Sentinel Keys key using the SFNTGetLicense() API function.
status = theKey.SFNTGetLicense(theLicense.DEVELOPERID,
theLicense.SOFTWARE_KEY,
theLicense.LICENSEID, theKey.SP_STANDALONE_MODE, licHandle);
if thedonglenot found or invaliddongle inserted then you can take he appropriate action, i.e: exit the application.
if(status !=
theKey.SP_SUCCESS)
{
JOptionPane.showMessageDialog(null,"Dongle not found!","error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
call the ECC feature
tosign a255byte data
with the key stored in the dongle and later verify it with the key stored inthe
application.
byte[] signBuffer =new byte[255]; // data to be signed byte[] signResult =new byte[42];
//
signed data
if the sign/verify calls is
successfulthen the dongle and the application are integrated successfuly and your application cannot run without the dongle.
API Demonstration
We will demonstrate how tointegratethe dongle APIs with
yourapplicationusing the SentinelHardware
KeysAPI, which comes with the software development kit of the
dongle.
Application:Protecting a java applicationplication using the Sentinel
Hardware Key. Programming
language:Java 1.6 Dongle
Type:Sentinel Hardware Key. Dongle
SDK:Sentinel Keys 1.2.1 OS:Windows XP SP2.
Design the strategy
usethe Sentinel Keys software kittoadd anynumber of features your strategy requires, from counters to AES 128-bit features and ECCsign/verify features.
for simplicitycity's
sake we willonlyadd one ECC feature to the protection strategy.ECC(EllipticCurve Cryptography)isapublic key cryptography system that uses two keys to make a secureand private session between two parties, hence the dongle and the application. open the
kit,add an ECC feature and thenclick
'build'. the kit will program the key withthe strategy, prepare a code sketch andgenerate the header file you will include in your program.
Create the application
copy thecom.safenet.sentinelfolder which were generated by the kit to the project src folder.
copy the license
fileSentinelKeysLicense.javato the src folder, this file contains license and key information.
copy the Sentinel Keys client
librarySentinelKeysJDK.dllto your<WINDIR>/system32 directory.
Call the APIs
Create the application
copy thecom.safenet.sentinelfolder which were generated by the kit to the project src folder.
copy the license
fileSentinelKeysLicense.javato the src folder, this file contains license and key information.
copy the Sentinel Keys client
librarySentinelKeysJDK.dllto your<WINDIR>/system32 directory.