Hasp HL Library
Jason A. Donenfeld | Jason@zx2c4.com
This is a very simple library based on libusb
for accessing MemoHASP
functions of the Hasp HL USB dongle. It currently can view the ID of a dongle,
validate the password, read from memory locations, and write to memory
locations.
This library allows use of the dongle without any drivers!
API
Include hasplib.h
, and compile your application alongside hasplib.c
and optionally hasplib-simple.c
.
Main Functions
Get a list of all connected dongles:
size_t hasp_find_dongles(hasp_dongle ***dongles);
Login to that dongle using the password, and optionally view the memory size:
bool hasp_login(hasp_dongle *dongle, uint16_t password1, uint16_t password2, uint16_t *memory_size);
Instead of the first two steps, you can also retreive the first connected dongle that fits your password:
hasp_dongle *hasp_find_login_first_dongle(uint16_t password1, uint16_t password2);
Read the ID of a dongle:
bool hasp_id(hasp_dongle *dongle, uint32_t *id);
Read from a memory location:
bool hasp_read(hasp_dongle *dongle, uint16_t location, uint16_t *value);
Write to a memory location:
bool hasp_write(hasp_dongle *dongle, uint16_t location, uint16_t value);
Free the list of dongles opened earlier:
void hasp_free_dongles(hasp_dongle **dongles);
Free a single dongle:
void hasp_free_dongle(hasp_dongle *dongle);
Simple Functions
The simple API wraps the main API and provides access to a default dongle, which is the first connected dongle that responds to the given passwords. It handles dongle disconnects and reconnections.
Create a hasp_simple *
object for a given password pair:
hasp_simple *hasp_simple_login(uint16_t password1, uint16_t password2);
Free this object:
void hasp_simple_free(hasp_simple *simple);
Read an ID, returning 0 if an error occurred:
uint32_t hasp_simple_id(hasp_simple *simple);
Read a memory location, returning 0 if an error occurred:
uint16_t hasp_simple_read(hasp_simple *simple, uint16_t location);
Write to a memory location, returning its success:
bool hasp_simple_write(hasp_simple *simple, uint16_t location, uint16_t value);
Licensing
This is released under the GPLv3. See COPYING
for more information. If you
need a less restrictive license, please contact me.