]> err.no Git - yubikey-personalization/commitdiff
move ticket import/export definitions ykpers_lcl.c
authorKlas Lindfors <klas@yubico.com>
Fri, 12 Apr 2013 13:46:56 +0000 (15:46 +0200)
committerKlas Lindfors <klas@yubico.com>
Fri, 12 Apr 2013 13:46:56 +0000 (15:46 +0200)
.gitignore
Makefile.am
ykpers-json.c
ykpers.c
ykpers_lcl.c [new file with mode: 0644]
ykpers_lcl.h

index 3402c563776fbac58f9b2abb4f9f9826f45876e5..0e67d966c09485991035f64139630e38395b5764 100644 (file)
@@ -89,5 +89,7 @@ ykpers.lo
 ykpers.o
 ykpers-json.lo
 ykpers-json.o
+ykpers_lcl.lo
+ykpers_lcl.o
 ykpersonalize
 ykpersonalize.o
index 96207ab54024dc96c606cbdcc7786b22a5eb1ba5..e8a7ffdd718bb908bffa9d47b4741987859401ee 100644 (file)
@@ -46,7 +46,7 @@ ykpers_include_HEADERS += ykpbkdf2.h
 
 lib_LTLIBRARIES = libykpers-1.la
 libykpers_1_la_SOURCES = ykpers.c ykpers-version.c ykpbkdf2.c ykpers-json.c
-libykpers_1_la_SOURCES += ykpers_lcl.h ykpers-json.h
+libykpers_1_la_SOURCES += ykpers_lcl.h ykpers-json.h ykpers_lcl.c
 libykpers_1_la_SOURCES += rfc4634/hmac.c rfc4634/usha.c rfc4634/sha.h  \
        rfc4634/sha1.c rfc4634/sha224-256.c rfc4634/sha384-512.c        \
        rfc4634/sha-private.h
index 6d0ac79bf0abe22d5e074d00f28ad5f53420238a..aed86e36db6dd7a6e8e213017cbc0d32c23bde66 100644 (file)
 #include <json/json.h>
 #include <string.h>
 
-static struct map_st modes_map[] = {
-       { MODE_OATH_HOTP,       0,      "oathHOTP",     0, 0 },
-       { MODE_CHAL_HMAC,       0,      "hmacCR",       0, 0 },
-       { MODE_STATIC_TICKET,   0,      "staticTicket", 0, 0 }, /* XXX: name? */
-       { MODE_CHAL_YUBICO,     0,      "yubicoCR",     0, 0 },
-       { MODE_OTP_YUBICO,      0,      "yubicoOTP",    0, 0 },
-       { 0, 0, 0, 0, 0 }
-};
-
 int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) {
        json_object *jobj = json_object_new_object();
        json_object *yprod_json = json_object_new_object();
@@ -68,7 +59,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) {
                        }
                }
 
-               for(p = modes_map; p->flag; p++) {
+               for(p = _modes_map; p->flag; p++) {
                        if(p->flag == mode) {
                                json_object *jmode = json_object_new_string(p->json_text);
                                json_object_object_add(yprod_json, "mode", jmode);
@@ -132,7 +123,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) {
                        json_object_object_add(options_json, "randomSeed", randomSeed);
                }
 
-               for(p = ticket_flags_map; p->flag; p++) {
+               for(p = _ticket_flags_map; p->flag; p++) {
                        if(!p->json_text) {
                                continue;
                        }
@@ -143,7 +134,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) {
                        }
                }
 
-               for(p = config_flags_map; p->flag; p++) {
+               for(p = _config_flags_map; p->flag; p++) {
                        if(!p->json_text) {
                                continue;
                        }
@@ -154,7 +145,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) {
                        }
                }
 
-               for(p = extended_flags_map; p->flag; p++) {
+               for(p = _extended_flags_map; p->flag; p++) {
                        if(!p->json_text) {
                                continue;
                        }
index 9957035845eb6bcf28cb391ca9ff7f30ed3fda6f..bd8233df966b2068927056614e25a1b35028c50f 100644 (file)
--- a/ykpers.c
+++ b/ykpers.c
@@ -938,7 +938,7 @@ static int ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len
 
                /* ticket_flags: */
                buffer[0] = '\0';
-               for (p = ticket_flags_map; p->flag; p++) {
+               for (p = _ticket_flags_map; p->flag; p++) {
                        if ((ycfg.tktFlags & p->flag) == p->flag
                            && p->capability(cfg)
                            && (!p->mode || (mode & p->mode) == mode)) {
@@ -955,7 +955,7 @@ static int ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len
                /* config_flags: */
                buffer[0] = '\0';
                t_flags = ycfg.cfgFlags;
-               for (p = config_flags_map; p->flag; p++) {
+               for (p = _config_flags_map; p->flag; p++) {
                        if ((t_flags & p->flag) == p->flag
                            && p->capability(cfg)
                            && (!p->mode || (mode & p->mode) == mode)) {
@@ -975,7 +975,7 @@ static int ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len
 
                /* extended_flags: */
                buffer[0] = '\0';
-               for (p = extended_flags_map; p->flag; p++) {
+               for (p = _extended_flags_map; p->flag; p++) {
                        if ((ycfg.extFlags & p->flag) == p->flag
                            && p->capability(cfg)
                            && (!p->mode || (mode & p->mode) == mode)) {
diff --git a/ykpers_lcl.c b/ykpers_lcl.c
new file mode 100644 (file)
index 0000000..4b2f13a
--- /dev/null
@@ -0,0 +1,87 @@
+/* -*- mode:C; c-file-style: "bsd" -*- */
+/*
+ * Copyright (c) 2013 Yubico AB
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *
+ *     * Redistributions in binary form must reproduce the above
+ *       copyright notice, this list of conditions and the following
+ *       disclaimer in the documentation and/or other materials provided
+ *       with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "ykpers_lcl.h"
+
+struct map_st _ticket_flags_map[] = {
+       { TKTFLAG_TAB_FIRST,    "TAB_FIRST",    "tabFirst",     capability_has_ticket_mods,     MODE_OUTPUT },
+       { TKTFLAG_APPEND_TAB1,  "APPEND_TAB1",  "tabBetween",   capability_has_ticket_mods,     MODE_OUTPUT },
+       { TKTFLAG_APPEND_TAB2,  "APPEND_TAB2",  "tabLast",      capability_has_ticket_mods,     MODE_OUTPUT },
+       { TKTFLAG_APPEND_DELAY1,"APPEND_DELAY1","appendDelay1", capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
+       { TKTFLAG_APPEND_DELAY2,"APPEND_DELAY2","appendDelay2", capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
+       { TKTFLAG_APPEND_CR,    "APPEND_CR",    "appendCR",     capability_has_ticket_mods,     MODE_OUTPUT },
+       { TKTFLAG_PROTECT_CFG2, "PROTEXT_CFG2", "protectSecond",capability_has_slot_two,        0 },
+       { TKTFLAG_OATH_HOTP,    "OATH_HOTP",    0,              capability_has_oath,            MODE_OATH_HOTP },
+       { TKTFLAG_CHAL_RESP,    "CHAL_RESP",    0,              capability_has_chal_resp,       MODE_CHAL_RESP },
+       { 0, 0, 0, 0, 0 }
+};
+
+struct map_st _config_flags_map[] = {
+       { CFGFLAG_CHAL_YUBICO,          "CHAL_YUBICO",          0,              capability_has_chal_resp,       MODE_CHAL_YUBICO },
+       { CFGFLAG_CHAL_HMAC,            "CHAL_HMAC",            0,              capability_has_chal_resp,       MODE_CHAL_HMAC },
+       { CFGFLAG_HMAC_LT64,            "HMAC_LT64",            "hmacLT64",     capability_has_chal_resp,       MODE_CHAL_HMAC }, /* XXX: name? */
+       { CFGFLAG_CHAL_BTN_TRIG,        "CHAL_BTN_TRIG",        "buttonReqd",   capability_has_chal_resp,       MODE_CHAL_RESP },
+       { CFGFLAG_OATH_HOTP8,           "OATH_HOTP8",           0,              capability_has_oath,            MODE_OATH_HOTP },
+       { CFGFLAG_OATH_FIXED_MODHEX1,   "OATH_FIXED_MODHEX1",   0,              capability_has_oath,            MODE_OATH_HOTP },
+       { CFGFLAG_OATH_FIXED_MODHEX2,   "OATH_FIXED_MODHEX2",   0,              capability_has_oath,            MODE_OATH_HOTP },
+       { CFGFLAG_OATH_FIXED_MODHEX,    "OATH_FIXED_MODHEX",    0,              capability_has_oath,            MODE_OATH_HOTP },
+       { CFGFLAG_SEND_REF,             "SEND_REF",             "sendRef",      capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
+       { CFGFLAG_TICKET_FIRST,         "TICKET_FIRST",         "ticketFirst",  capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
+       { CFGFLAG_PACING_10MS,          "PACKING_10MS",         "pacing10MS",   capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
+       { CFGFLAG_PACING_20MS,          "PACING_20MS",          "pacing20MS",   capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
+       { CFGFLAG_ALLOW_HIDTRIG,        "ALLOW_HIDTRIG",        "allowHidtrig", capability_has_hidtrig,         MODE_OUTPUT }, /* XXX: name? */
+       { CFGFLAG_SHORT_TICKET,         "SHORT_TICKET",         "shortTicket",  capability_has_static_extras,   MODE_STATIC_TICKET }, /* XXX: name? */
+       { CFGFLAG_STRONG_PW1,           "STRONG_PW1",           "strongPw1",    capability_has_static_extras,   MODE_STATIC_TICKET }, /* XXX: name? */
+       { CFGFLAG_STRONG_PW2,           "STRONG_PW2",           "strongPw2",    capability_has_static_extras,   MODE_STATIC_TICKET }, /* XXX: name? */
+       { CFGFLAG_MAN_UPDATE,           "MAN_UPDATE",           "manUpdate",    capability_has_static_extras,   MODE_STATIC_TICKET }, /* XXX: name? */
+       { 0, 0, 0, 0, 0 }
+};
+
+struct map_st _extended_flags_map[] = {
+       { EXTFLAG_SERIAL_BTN_VISIBLE,   "SERIAL_BTN_VISIBLE",   "serialBtnVisible",     capability_has_serial,          0 },
+       { EXTFLAG_SERIAL_USB_VISIBLE,   "SERIAL_USB_VISIBLE",   "serialUsbVisible",     capability_has_serial,          0 },
+       { EXTFLAG_SERIAL_API_VISIBLE,   "SERIAL_API_VISIBLE",   "serialApiVisible",     capability_has_serial_api,      0 },
+       { EXTFLAG_USE_NUMERIC_KEYPAD,   "USE_NUMERIC_KEYPAD",   "useNumericKeypad",     capability_has_numeric,         0 },
+       { EXTFLAG_FAST_TRIG,            "FAST_TRIG",            "fastTrig",             capability_has_fast,            0 },
+       { EXTFLAG_ALLOW_UPDATE,         "ALLOW_UPDATE",         "allowUpdate",          capability_has_update,          0 },
+       { EXTFLAG_DORMANT,              "DORMANT",              "dormant",              capability_has_dormant,         0 },
+       { EXTFLAG_LED_INV,              "LED_INV",              "ledInverted",          capability_has_led_inv,         0 },
+       { 0, 0, 0, 0, 0 }
+};
+
+
+struct map_st _modes_map[] = {
+       { MODE_OATH_HOTP,       0,      "oathHOTP",     0, 0 },
+       { MODE_CHAL_HMAC,       0,      "hmacCR",       0, 0 },
+       { MODE_STATIC_TICKET,   0,      "staticTicket", 0, 0 }, /* XXX: name? */
+       { MODE_CHAL_YUBICO,     0,      "yubicoCR",     0, 0 },
+       { MODE_OTP_YUBICO,      0,      "yubicoOTP",    0, 0 },
+       { 0, 0, 0, 0, 0 }
+};
index 715e12c7abc93c8424a33741ee8e632574d80e85..d51922cb93edd50dec59a3c3876142d1e7a3ff99 100644 (file)
@@ -64,7 +64,6 @@ extern bool capability_has_numeric(const YKP_CONFIG *cfg);
 extern bool capability_has_dormant(const YKP_CONFIG *cfg);
 extern bool capability_has_led_inv(const YKP_CONFIG *cfg);
 
-
 struct map_st {
        uint8_t flag;
        const char *flag_text;
@@ -73,6 +72,11 @@ struct map_st {
        unsigned char mode;
 };
 
+extern struct map_st _ticket_flags_map[];
+extern struct map_st _config_flags_map[];
+extern struct map_st _extended_flags_map[];
+extern struct map_st _modes_map[];
+
 #define MODE_CHAL_HMAC         0x01
 #define MODE_OATH_HOTP         0x02
 #define MODE_OTP_YUBICO                0x04
@@ -82,52 +86,6 @@ struct map_st {
 #define MODE_CHAL_RESP         MODE_CHAL_YUBICO | MODE_CHAL_HMAC
 #define MODE_OUTPUT            MODE_STATIC_TICKET | MODE_OTP_YUBICO | MODE_OATH_HOTP
 
-static struct map_st ticket_flags_map[] = {
-       { TKTFLAG_TAB_FIRST,    "TAB_FIRST",    "tabFirst",     capability_has_ticket_mods,     MODE_OUTPUT },
-       { TKTFLAG_APPEND_TAB1,  "APPEND_TAB1",  "tabBetween",   capability_has_ticket_mods,     MODE_OUTPUT },
-       { TKTFLAG_APPEND_TAB2,  "APPEND_TAB2",  "tabLast",      capability_has_ticket_mods,     MODE_OUTPUT },
-       { TKTFLAG_APPEND_DELAY1,"APPEND_DELAY1","appendDelay1", capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
-       { TKTFLAG_APPEND_DELAY2,"APPEND_DELAY2","appendDelay2", capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
-       { TKTFLAG_APPEND_CR,    "APPEND_CR",    "appendCR",     capability_has_ticket_mods,     MODE_OUTPUT },
-       { TKTFLAG_PROTECT_CFG2, "PROTEXT_CFG2", "protectSecond",capability_has_slot_two,        0 },
-       { TKTFLAG_OATH_HOTP,    "OATH_HOTP",    0,              capability_has_oath,            MODE_OATH_HOTP },
-       { TKTFLAG_CHAL_RESP,    "CHAL_RESP",    0,              capability_has_chal_resp,       MODE_CHAL_RESP },
-       { 0, 0, 0, 0, 0 }
-};
-
-static struct map_st config_flags_map[] = {
-       { CFGFLAG_CHAL_YUBICO,          "CHAL_YUBICO",          0,              capability_has_chal_resp,       MODE_CHAL_YUBICO },
-       { CFGFLAG_CHAL_HMAC,            "CHAL_HMAC",            0,              capability_has_chal_resp,       MODE_CHAL_HMAC },
-       { CFGFLAG_HMAC_LT64,            "HMAC_LT64",            "hmacLT64",     capability_has_chal_resp,       MODE_CHAL_HMAC }, /* XXX: name? */
-       { CFGFLAG_CHAL_BTN_TRIG,        "CHAL_BTN_TRIG",        "buttonReqd",   capability_has_chal_resp,       MODE_CHAL_RESP },
-       { CFGFLAG_OATH_HOTP8,           "OATH_HOTP8",           0,              capability_has_oath,            MODE_OATH_HOTP },
-       { CFGFLAG_OATH_FIXED_MODHEX1,   "OATH_FIXED_MODHEX1",   0,              capability_has_oath,            MODE_OATH_HOTP },
-       { CFGFLAG_OATH_FIXED_MODHEX2,   "OATH_FIXED_MODHEX2",   0,              capability_has_oath,            MODE_OATH_HOTP },
-       { CFGFLAG_OATH_FIXED_MODHEX,    "OATH_FIXED_MODHEX",    0,              capability_has_oath,            MODE_OATH_HOTP },
-       { CFGFLAG_SEND_REF,             "SEND_REF",             "sendRef",      capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
-       { CFGFLAG_TICKET_FIRST,         "TICKET_FIRST",         "ticketFirst",  capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
-       { CFGFLAG_PACING_10MS,          "PACKING_10MS",         "pacing10MS",   capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
-       { CFGFLAG_PACING_20MS,          "PACING_20MS",          "pacing20MS",   capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
-       { CFGFLAG_ALLOW_HIDTRIG,        "ALLOW_HIDTRIG",        "allowHidtrig", capability_has_hidtrig,         MODE_OUTPUT }, /* XXX: name? */
-       { CFGFLAG_SHORT_TICKET,         "SHORT_TICKET",         "shortTicket",  capability_has_static_extras,   MODE_STATIC_TICKET }, /* XXX: name? */
-       { CFGFLAG_STRONG_PW1,           "STRONG_PW1",           "strongPw1",    capability_has_static_extras,   MODE_STATIC_TICKET }, /* XXX: name? */
-       { CFGFLAG_STRONG_PW2,           "STRONG_PW2",           "strongPw2",    capability_has_static_extras,   MODE_STATIC_TICKET }, /* XXX: name? */
-       { CFGFLAG_MAN_UPDATE,           "MAN_UPDATE",           "manUpdate",    capability_has_static_extras,   MODE_STATIC_TICKET }, /* XXX: name? */
-       { 0, 0, 0, 0, 0 }
-};
-
-static struct map_st extended_flags_map[] = {
-       { EXTFLAG_SERIAL_BTN_VISIBLE,   "SERIAL_BTN_VISIBLE",   "serialBtnVisible",     capability_has_serial,          0 },
-       { EXTFLAG_SERIAL_USB_VISIBLE,   "SERIAL_USB_VISIBLE",   "serialUsbVisible",     capability_has_serial,          0 },
-       { EXTFLAG_SERIAL_API_VISIBLE,   "SERIAL_API_VISIBLE",   "serialApiVisible",     capability_has_serial_api,      0 },
-       { EXTFLAG_USE_NUMERIC_KEYPAD,   "USE_NUMERIC_KEYPAD",   "useNumericKeypad",     capability_has_numeric,         0 },
-       { EXTFLAG_FAST_TRIG,            "FAST_TRIG",            "fastTrig",             capability_has_fast,            0 },
-       { EXTFLAG_ALLOW_UPDATE,         "ALLOW_UPDATE",         "allowUpdate",          capability_has_update,          0 },
-       { EXTFLAG_DORMANT,              "DORMANT",              "dormant",              capability_has_dormant,         0 },
-       { EXTFLAG_LED_INV,              "LED_INV",              "ledInverted",          capability_has_led_inv,         0 },
-       { 0, 0, 0, 0, 0 }
-};
-
 # ifdef __cplusplus
 }
 # endif