From d82829f6fc0f55d3eddcf26d14637883541ce452 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 28 Jan 2019 11:53:58 +0100 Subject: Add NK_get_status function to get status struct Currently, the C API provides access to the device status using the NK_get_{major,minor}_firmware_version, NK_device_serial_number and NK_read_config functions. Each function sends a command to the device, although the data is returned in a single response. This patch adds a NK_status struct and a NK_get_status function that provide access to this data with a single command. --- NK_C_API.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'NK_C_API.h') diff --git a/NK_C_API.h b/NK_C_API.h index 47b2567..c59beb4 100644 --- a/NK_C_API.h +++ b/NK_C_API.h @@ -137,6 +137,47 @@ extern "C" { struct NK_device_info* next; }; + /** + * Stores the common device status for all Nitrokey devices. + */ + struct NK_status { + /** + * The major firmware version, e. g. 0 in v0.40. + */ + uint8_t firmware_version_major; + /** + * The minor firmware version, e. g. 40 in v0.40. + */ + uint8_t firmware_version_minor; + /** + * The serial number of the smart card. + */ + uint32_t serial_number_smart_card; + /** + * The HOTP slot to generate a password from if the numlock + * key is pressed twice (slot 0-1, or any other value to + * disable the function). + */ + uint8_t config_numlock; + /** + * The HOTP slot to generate a password from if the capslock + * key is pressed twice (slot 0-1, or any other value to + * disable the function). + */ + uint8_t config_capslock; + /** + * The HOTP slot to generate a password from if the scrolllock + * key is pressed twice (slot 0-1, or any other value to + * disable the function). + */ + uint8_t config_scrolllock; + /** + * Indicates whether the user password is required to generate + * an OTP value. + */ + bool otp_user_password; + }; + /** * Stores the status of a Storage device. */ @@ -317,6 +358,17 @@ extern "C" { */ NK_C_API char * NK_status(); + /** + * Get the stick status common to all Nitrokey devices and return the + * command processing error code. If the code is zero, i. e. the + * command was successful, the storage status is written to the output + * pointer's target. The output pointer must not be null. + * + * @param out the output pointer for the status + * @return command processing error code + */ + NK_C_API int NK_get_status(struct NK_status* out); + /** * Return the device's serial number string in hex. * @return string device's serial number in hex -- cgit v1.2.1