aboutsummaryrefslogtreecommitdiff
path: root/NK_C_API.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-04-19 15:12:28 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2018-04-19 15:12:28 +0200
commit391a276ba35216337b777c65fda62561a6e9383f (patch)
tree201f025951868128fc64c0253589546ca0dea53f /NK_C_API.h
parent7f5f471d8f3a67fe109e4c8c241de2e1098d275e (diff)
parent9ab13fd0ae3d85dcb9a3fcef0594aacb1946086b (diff)
downloadlibnitrokey-391a276ba35216337b777c65fda62561a6e9383f.tar.gz
libnitrokey-391a276ba35216337b777c65fda62561a6e9383f.tar.bz2
Merge branch '110-mixed_strings'
Make sure all C API strings are deallocable. Tested with Python's 3.6.5 'pytest -sv test_{pro,storage}.py' on Storage v0.50, Ubuntu 18.04 Closes #110
Diffstat (limited to 'NK_C_API.h')
-rw-r--r--NK_C_API.h32
1 files changed, 17 insertions, 15 deletions
diff --git a/NK_C_API.h b/NK_C_API.h
index 3a6aa2a..222e5e1 100644
--- a/NK_C_API.h
+++ b/NK_C_API.h
@@ -28,13 +28,15 @@
#ifdef _MSC_VER
#define NK_C_API __declspec(dllexport)
#else
-#define NK_C_API
+#define NK_C_API
#endif
#ifdef __cplusplus
extern "C" {
#endif
+ static const int MAXIMUM_STR_REPLY_LENGTH = 8192;
+
/**
* The Nitrokey device models supported by the API.
*/
@@ -91,13 +93,13 @@ extern "C" {
* Return the debug status string. Debug purposes.
* @return command processing error code
*/
- NK_C_API const char * NK_status();
+ NK_C_API char * NK_status();
/**
* Return the device's serial number string in hex.
* @return string device's serial number in hex
*/
- NK_C_API const char * NK_device_serial_number();
+ NK_C_API char * NK_device_serial_number();
/**
* Get last command processing status. Useful for commands which returns the results of their own and could not return
@@ -183,14 +185,14 @@ extern "C" {
* @param slot_number TOTP slot number, slot_number<15
* @return char[20] the name of the slot
*/
- NK_C_API const char * NK_get_totp_slot_name(uint8_t slot_number);
+ NK_C_API char * NK_get_totp_slot_name(uint8_t slot_number);
/**
*
* @param slot_number HOTP slot number, slot_number<3
* @return char[20] the name of the slot
*/
- NK_C_API const char * NK_get_hotp_slot_name(uint8_t slot_number);
+ NK_C_API char * NK_get_hotp_slot_name(uint8_t slot_number);
/**
* Erase HOTP slot data from the device
@@ -249,7 +251,7 @@ extern "C" {
* @param slot_number HOTP slot number, slot_number<3
* @return HOTP code
*/
- NK_C_API const char * NK_get_hotp_code(uint8_t slot_number);
+ NK_C_API char * NK_get_hotp_code(uint8_t slot_number);
/**
* Get HOTP code from the device (PIN protected)
@@ -258,7 +260,7 @@ extern "C" {
* otherwise should be set to empty string - ''
* @return HOTP code
*/
- NK_C_API const char * NK_get_hotp_code_PIN(uint8_t slot_number, const char *user_temporary_password);
+ NK_C_API char * NK_get_hotp_code_PIN(uint8_t slot_number, const char *user_temporary_password);
/**
* Get TOTP code from the device
@@ -268,7 +270,7 @@ extern "C" {
* @param last_interval last interval
* @return TOTP code
*/
- NK_C_API const char * NK_get_totp_code(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
+ NK_C_API char * NK_get_totp_code(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time,
uint8_t last_interval);
/**
@@ -281,7 +283,7 @@ extern "C" {
* otherwise should be set to empty string - ''
* @return TOTP code
*/
- NK_C_API const char * NK_get_totp_code_PIN(uint8_t slot_number, uint64_t challenge,
+ NK_C_API char * NK_get_totp_code_PIN(uint8_t slot_number, uint64_t challenge,
uint64_t last_totp_time, uint8_t last_interval,
const char *user_temporary_password);
@@ -343,21 +345,21 @@ extern "C" {
* @param slot_number password safe slot number, slot_number<16
* @return slot name
*/
- NK_C_API const char *NK_get_password_safe_slot_name(uint8_t slot_number);
+ NK_C_API char *NK_get_password_safe_slot_name(uint8_t slot_number);
/**
* Get password safe slot login
* @param slot_number password safe slot number, slot_number<16
* @return login from the PWS slot
*/
- NK_C_API const char *NK_get_password_safe_slot_login(uint8_t slot_number);
+ NK_C_API char *NK_get_password_safe_slot_login(uint8_t slot_number);
/**
* Get the password safe slot password
* @param slot_number password safe slot number, slot_number<16
* @return password from the PWS slot
*/
- NK_C_API const char *NK_get_password_safe_slot_password(uint8_t slot_number);
+ NK_C_API char *NK_get_password_safe_slot_password(uint8_t slot_number);
/**
* Write password safe data to the slot
@@ -582,7 +584,7 @@ extern "C" {
* Storage only
* @return string with devices attributes
*/
- NK_C_API const char* NK_get_status_storage_as_string();
+ NK_C_API char* NK_get_status_storage_as_string();
/**
* Get SD card usage attributes as string.
@@ -590,7 +592,7 @@ extern "C" {
* Storage only
* @return string with SD card usage attributes
*/
- NK_C_API const char* NK_get_SD_usage_data_as_string();
+ NK_C_API char* NK_get_SD_usage_data_as_string();
/**
* Get progress value of current long operation.
@@ -614,7 +616,7 @@ extern "C" {
* @example Example of returned data: '00005d19:dacc2cb4_p_0001:0010:02;000037c7:4cf12445_p_0001:000f:02;0001:000c:02'
* @return string delimited id's of connected devices
*/
- NK_C_API const char* NK_list_devices_by_cpuID();
+ NK_C_API char* NK_list_devices_by_cpuID();
/**