]> err.no Git - yubikey-personalization.old/commitdiff
Fix namespace of ykpers.h.
authorSimon Josefsson <simon@josefsson.org>
Thu, 30 Apr 2009 15:36:59 +0000 (15:36 +0000)
committerSimon Josefsson <simon@josefsson.org>
Thu, 30 Apr 2009 15:36:59 +0000 (15:36 +0000)
selftest.c
ykpers.c
ykpers.h
ykpersonalize.c

index 43fb6db0fb0c2e61dfbe9c36633a9efa19071058..35a9c4a60ad7567cd19baa4d3f042097ed14c7b1 100644 (file)
@@ -33,7 +33,7 @@
 
 int main (void)
 {
-       CONFIG *ykp;
+       ykp_cfg *ykp;
        int rc;
 
        ykp = ykp_create_config ();
index 5764b379f2fd181aa54b23f1f4a17b3318754923..70bf803385b4dc12e4b201d397c7b246eebdf3da 100644 (file)
--- a/ykpers.c
+++ b/ykpers.c
@@ -29,6 +29,7 @@
  */
 
 #include <ykpers.h>
+#include <ykcore.h>
 #include <ykdef.h>
 #include <ykpbkdf2.h>
 
@@ -38,7 +39,9 @@
 
 #include <yubikey.h>
 
-static const CONFIG default_config = {
+
+
+static const ykp_cfg default_config = {
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* fixed */
        { 0, 0, 0, 0, 0, 0 },   /* uid */
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* key */
@@ -51,9 +54,9 @@ static const CONFIG default_config = {
        0                       /* crc */
 };
 
-CONFIG *ykp_create_config(void)
+ykp_cfg *ykp_create_config(void)
 {
-       CONFIG *cfg = malloc(sizeof(CONFIG));
+       ykp_cfg *cfg = malloc(sizeof(ykp_cfg));
        if (cfg) {
                memcpy(cfg, &default_config,
                       sizeof(default_config));
@@ -62,7 +65,7 @@ CONFIG *ykp_create_config(void)
        return 0;
 }
 
-int ykp_free_config(CONFIG *cfg)
+int ykp_free_config(ykp_cfg *cfg)
 {
        if (cfg) {
                free(cfg);
@@ -71,7 +74,7 @@ int ykp_free_config(CONFIG *cfg)
        return 0;
 }
 
-int ykp_AES_key_from_hex(CONFIG *cfg, const char *hexkey) {
+int ykp_AES_key_from_hex(ykp_cfg *cfg, const char *hexkey) {
        char aesbin[256];
        unsigned long int aeslong;
 
@@ -96,7 +99,7 @@ int ykp_AES_key_from_hex(CONFIG *cfg, const char *hexkey) {
        return 0;
 }
 
-int ykp_AES_key_from_passphrase(CONFIG *cfg, const char *passphrase,
+int ykp_AES_key_from_passphrase(ykp_cfg *cfg, const char *passphrase,
                                const char *salt)
 {
        if (cfg) {
@@ -163,10 +166,10 @@ int ykp_AES_key_from_passphrase(CONFIG *cfg, const char *passphrase,
 }
 
 #define def_set_charfield(fnname,fieldname,size,extra)         \
-int ykp_set_ ## fnname(CONFIG *cfg, unsigned char *input, size_t len)  \
+int ykp_set_ ## fnname(ykp_cfg *cfg, unsigned char *input, size_t len) \
 {                                                              \
        if (cfg) {                                              \
-               size_t max_chars = len;         \
+               size_t max_chars = len;                         \
                                                                \
                if (max_chars > (size))                         \
                        max_chars = (size);                     \
@@ -187,7 +190,7 @@ def_set_charfield(fixed,fixed,FIXED_SIZE,cfg->fixedSize = max_chars)
 def_set_charfield(uid,uid,UID_SIZE,)
 
 #define def_set_tktflag(type)                                  \
-int ykp_set_tktflag_ ## type(CONFIG *cfg, bool state)          \
+int ykp_set_tktflag_ ## type(ykp_cfg *cfg, bool state)         \
 {                                                              \
        if (cfg) {                                              \
                if (state)                                      \
@@ -201,7 +204,7 @@ int ykp_set_tktflag_ ## type(CONFIG *cfg, bool state)               \
 }
 
 #define def_set_cfgflag(type)                                  \
-int ykp_set_cfgflag_ ## type(CONFIG *cfg, bool state)          \
+int ykp_set_cfgflag_ ## type(ykp_cfg *cfg, bool state)         \
 {                                                              \
        if (cfg) {                                              \
                if (state)                                      \
@@ -264,7 +267,7 @@ struct map_st config_flags_map[] = {
        { 0, "" }
 };
 
-int ykp_write_config(const CONFIG *cfg,
+int ykp_write_config(const ykp_cfg *cfg,
                     int (*writer)(const char *buf, size_t count,
                                   void *userdata),
                     void *userdata)
@@ -345,7 +348,7 @@ int ykp_write_config(const CONFIG *cfg,
        }
        return 0;
 }
-int ykp_read_config(CONFIG *cfg,
+int ykp_read_config(ykp_cfg *cfg,
                    int (*reader)(char *buf, size_t count,
                                  void *userdata),
                    void *userdata)
index 5b95c95758aaee64d39fa41810a0235d1d32d576..2957fbf275c25f442578e2d87c5e5014a8dbca4b 100644 (file)
--- a/ykpers.h
+++ b/ykpers.h
 #ifndef        __YKPERS_H_INCLUDED__
 #define        __YKPERS_H_INCLUDED__
 
-#include <ykcore.h>
+#include <stddef.h>
+#include <stdbool.h>
 
-CONFIG *ykp_create_config(void);
-int ykp_free_config(CONFIG *cfg);
+typedef struct config_st ykp_cfg;
 
-int ykp_AES_key_from_hex(CONFIG *cfg, const char *hexkey);
-int ykp_AES_key_from_passphrase(CONFIG *cfg, const char *passphrase,
+ykp_cfg *ykp_create_config(void);
+int ykp_free_config(ykp_cfg *cfg);
+
+int ykp_AES_key_from_hex(ykp_cfg *cfg, const char *hexkey);
+int ykp_AES_key_from_passphrase(ykp_cfg *cfg, const char *passphrase,
                                const char *salt);
 
-int ykp_set_access_code(CONFIG *cfg, unsigned char *access_code, size_t len);
-int ykp_set_fixed(CONFIG *cfg, unsigned char *fixed, size_t len);
-int ykp_set_uid(CONFIG *cfg, unsigned char *uid, size_t len);
+int ykp_set_access_code(ykp_cfg *cfg, unsigned char *access_code, size_t len);
+int ykp_set_fixed(ykp_cfg *cfg, unsigned char *fixed, size_t len);
+int ykp_set_uid(ykp_cfg *cfg, unsigned char *uid, size_t len);
 
-int ykp_set_tktflag_TAB_FIRST(CONFIG *cfg, bool state);
-int ykp_set_tktflag_APPEND_TAB1(CONFIG *cfg, bool state);
-int ykp_set_tktflag_APPEND_TAB2(CONFIG *cfg, bool state);
-int ykp_set_tktflag_APPEND_DELAY1(CONFIG *cfg, bool state);
-int ykp_set_tktflag_APPEND_DELAY2(CONFIG *cfg, bool state);
-int ykp_set_tktflag_APPEND_CR(CONFIG *cfg, bool state);
+int ykp_set_tktflag_TAB_FIRST(ykp_cfg *cfg, bool state);
+int ykp_set_tktflag_APPEND_TAB1(ykp_cfg *cfg, bool state);
+int ykp_set_tktflag_APPEND_TAB2(ykp_cfg *cfg, bool state);
+int ykp_set_tktflag_APPEND_DELAY1(ykp_cfg *cfg, bool state);
+int ykp_set_tktflag_APPEND_DELAY2(ykp_cfg *cfg, bool state);
+int ykp_set_tktflag_APPEND_CR(ykp_cfg *cfg, bool state);
 
-int ykp_set_cfgflag_SEND_REF(CONFIG *cfg, bool state);
-int ykp_set_cfgflag_TICKET_FIRST(CONFIG *cfg, bool state);
-int ykp_set_cfgflag_PACING_10MS(CONFIG *cfg, bool state);
-int ykp_set_cfgflag_PACING_20MS(CONFIG *cfg, bool state);
-int ykp_set_cfgflag_ALLOW_HIDTRIG(CONFIG *cfg, bool state);
-int ykp_set_cfgflag_STATIC_TICKET(CONFIG *cfg, bool state);
+int ykp_set_cfgflag_SEND_REF(ykp_cfg *cfg, bool state);
+int ykp_set_cfgflag_TICKET_FIRST(ykp_cfg *cfg, bool state);
+int ykp_set_cfgflag_PACING_10MS(ykp_cfg *cfg, bool state);
+int ykp_set_cfgflag_PACING_20MS(ykp_cfg *cfg, bool state);
+int ykp_set_cfgflag_ALLOW_HIDTRIG(ykp_cfg *cfg, bool state);
+int ykp_set_cfgflag_STATIC_TICKET(ykp_cfg *cfg, bool state);
 
-int ykp_write_config(const CONFIG *cfg,
+int ykp_write_config(const ykp_cfg *cfg,
                     int (*writer)(const char *buf, size_t count,
                                   void *userdata),
                     void *userdata);
-int ykp_read_config(CONFIG *cfg,
+int ykp_read_config(ykp_cfg *cfg,
                    int (*reader)(char *buf, size_t count,
                                  void *userdata),
                    void *userdata);
index 9965c5693b489f7a662d5d1f57385f72ab140d8b..c8470c8960be9debd46f99169d39070dbeadbc3c 100644 (file)
@@ -168,7 +168,7 @@ main(int argc, char **argv)
                                const char *uid = optarg+4;
                                size_t uidlen = strlen (uid);
                                char uidbin[256];
-                               if (uidlen % 2 || uidlen != 8)
+                               if (uidlen % 2 || uidlen != 12)
                                {
                                        fprintf(stderr,
                                                "Invalid hex uid string: %s\n",