aboutsummaryrefslogtreecommitdiff
path: root/NK_C_API.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2019-01-29 16:37:22 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2019-01-29 16:37:22 +0100
commit1bf90425d2006558ce4f4aac0ed5680d31b77918 (patch)
treec6789df5d10d1b5f6b83c5d1c7c2889e5ad2a6d9 /NK_C_API.h
parentb0d1d6a1a44210a25b3d0e6950ec08f551714ccf (diff)
parentdc9dd81105634aeb100c47637fedef425f0ac6f9 (diff)
downloadlibnitrokey-1bf90425d2006558ce4f4aac0ed5680d31b77918.tar.gz
libnitrokey-1bf90425d2006558ce4f4aac0ed5680d31b77918.tar.bz2
Merge branch 'pr_155'
Add Status structure, and a general command for using it as a result. Usable to limit calls to the device, when multiple status fields are required at given time. Tested on Nitrokey Pro v0.7 and v0.10. Run offline tests as well (C++ and Python). Fixes #155
Diffstat (limited to 'NK_C_API.h')
-rw-r--r--NK_C_API.h64
1 files changed, 63 insertions, 1 deletions
diff --git a/NK_C_API.h b/NK_C_API.h
index 47b2567..79d80c0 100644
--- a/NK_C_API.h
+++ b/NK_C_API.h
@@ -138,6 +138,47 @@ extern "C" {
};
/**
+ * 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.
*/
struct NK_storage_status {
@@ -312,10 +353,31 @@ extern "C" {
NK_C_API enum NK_device_model NK_get_device_model();
/**
+ * Return the debug status string. Debug purposes. This function is
+ * deprecated in favor of NK_get_status_as_string.
+ * @return string representation of the status or an empty string
+ * if the command failed
+ */
+ DEPRECATED
+ NK_C_API char * NK_status();
+
+ /**
* Return the debug status string. Debug purposes.
+ * @return string representation of the status or an empty string
+ * if the command failed
+ */
+ NK_C_API char * NK_get_status_as_string();
+
+ /**
+ * 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 char * NK_status();
+ NK_C_API int NK_get_status(struct NK_status* out);
/**
* Return the device's serial number string in hex.