libyubihsm
|
Libyubihsm is a library for communicating with a YubiHSM 2 device.
To use the library, include <yubihsm.h> in the C code and pass the -lyubihsm flag to the linker. Debug output is controlled with the function yh_set_verbosity().
First step of using a YubiHSM 2 is to initialize the library with yh_init(), initialize a connector with yh_init_connector() and then connect it to the YubiHSM 2 with yh_connect(). After this, a session must be established with yh_create_session_derived(), yh_create_session() or yh_begin_create_session_ext(). The session must then be authenticated using yh_authenticate_session().
When a session is authenticated, commands can be exchanged over it. The functions in the namespace yh_util are high-level convenience functions that do specific tasks with the device.
All public functions and definitions can be found in yubihsm.h
Here is a small example of establishing a session with a YubiHSM 2 and fetching some pseudo random bytes before closing the session.