]> err.no Git - yubikey-personalization/commitdiff
add functions for manipulating the device_config
authorKlas Lindfors <klas@yubico.com>
Mon, 3 Dec 2012 09:53:11 +0000 (10:53 +0100)
committerKlas Lindfors <klas@yubico.com>
Mon, 3 Dec 2012 09:53:11 +0000 (10:53 +0100)
libykpers-1.map
ykpers.c
ykpers.h

index 5c887c28139e7c1063c4bc439220dc44b5f22c5b..56dab3699b650f82c14e508acb34ce6267a4749a 100644 (file)
@@ -169,5 +169,10 @@ LIBYKPERS_1.10 {
   ykp_ndef_as_text;
   yk_check_firmware_version2;
   yk_set_usb_mode;
+  ykp_alloc_device_config;
+  ykp_free_device_config;
+  ykp_set_device_mode;
+  ykp_set_device_chalresp_timeout;
+  ykp_set_device_autoeject_time;
 # Variables:
 } LIBYKPERS_1.9;
index f2dd87545b5572ef37fe415ff1205a43e29ba0bb..0daf6fecd1273cfe7d5e931a3f4f1dce15b3f157 100644 (file)
--- a/ykpers.c
+++ b/ykpers.c
@@ -500,6 +500,55 @@ int ykp_set_ndef_access_code(YK_NDEF *ndef, unsigned char *access_code)
        return 1;
 }
 
+YK_DEVICE_CONFIG *ykp_alloc_device_config(void)
+{
+       YK_DEVICE_CONFIG *cfg = malloc(sizeof(YK_DEVICE_CONFIG));
+       if(cfg) {
+               memset(cfg, 0, sizeof(YK_DEVICE_CONFIG));
+               return cfg;
+       }
+       return 0;
+}
+
+int ykp_free_device_config(YK_DEVICE_CONFIG *device_config)
+{
+       if(device_config) {
+               free(device_config);
+               return 1;
+       }
+       return 0;
+}
+
+int ykp_set_device_mode(YK_DEVICE_CONFIG *device_config, unsigned char mode)
+{
+       if(device_config) {
+               device_config->mode = mode;
+               return 1;
+       }
+       ykp_errno = YKP_EINVAL;
+       return 0;
+}
+
+int ykp_set_device_chalresp_timeout(YK_DEVICE_CONFIG *device_config, unsigned char timeout)
+{
+       if(device_config) {
+               device_config->crTimeout = timeout;
+               return 1;
+       }
+       ykp_errno = YKP_EINVAL;
+       return 0;
+}
+
+int ykp_set_device_autoeject_time(YK_DEVICE_CONFIG *device_config, unsigned short eject_time)
+{
+       if(device_config) {
+               device_config->autoEjectTime = eject_time;
+               return 1;
+       }
+       ykp_errno = YKP_EINVAL;
+       return 0;
+}
+
 static bool vcheck_all(const YKP_CONFIG *cfg)
 {
        return true;
index 4eeec6a5eb64dc5fd9b605de341ff5de6c14ce3f..847094461cdd5762c4025a6d0b78af1b546ef114 100644 (file)
--- a/ykpers.h
+++ b/ykpers.h
@@ -74,6 +74,12 @@ int ykp_construct_ndef_text(YK_NDEF *ndef, const char *text, const char *lang, b
 int ykp_set_ndef_access_code(YK_NDEF *ndef, unsigned char *access_code);
 int ykp_ndef_as_text(YK_NDEF *ndef, char *text, size_t len);
 
+YK_DEVICE_CONFIG *ykp_alloc_device_config(void);
+int ykp_free_device_config(YK_DEVICE_CONFIG *device_config);
+int ykp_set_device_mode(YK_DEVICE_CONFIG *device_config, unsigned char mode);
+int ykp_set_device_chalresp_timeout(YK_DEVICE_CONFIG *device_config, unsigned char timeout);
+int ykp_set_device_autoeject_time(YK_DEVICE_CONFIG *device_config, unsigned short eject_time);
+
 int ykp_set_access_code(YKP_CONFIG *cfg, unsigned char *access_code, size_t len);
 int ykp_set_fixed(YKP_CONFIG *cfg, unsigned char *fixed, size_t len);
 int ykp_set_uid(YKP_CONFIG *cfg, unsigned char *uid, size_t len);