From: Klas Lindfors Date: Thu, 11 Apr 2013 12:06:15 +0000 (+0200) Subject: add support for prefix X-Git-Tag: v1.13.0~57 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c49f0d6d1ffa4310f3fc2b09d7a25777d861c664;p=yubikey-personalization add support for prefix --- diff --git a/ykpers-json.c b/ykpers-json.c index 3035a36..bc1c545 100644 --- a/ykpers-json.c +++ b/ykpers-json.c @@ -31,6 +31,8 @@ #include "ykpers_lcl.h" #include "ykpers-json.h" +#include + #include #include @@ -63,9 +65,6 @@ static struct map_st ticket_flags_map[] = { static struct map_st config_flags_map[] = { { CFGFLAG_HMAC_LT64, "hmacLT64", MODE_CHAL_HMAC }, /* XXX: name? */ { CFGFLAG_CHAL_BTN_TRIG, "buttonReqd", MODE_CHAL_RESP }, - { CFGFLAG_OATH_FIXED_MODHEX1, "oathFixedModhex1", MODE_OATH_HOTP }, /* XXX: name? */ - { CFGFLAG_OATH_FIXED_MODHEX2, "oathFixedModhex2", MODE_OATH_HOTP }, /* XXX: name? */ - { CFGFLAG_OATH_FIXED_MODHEX, "oathFixedModhex", MODE_OATH_HOTP }, /* XXX: name? */ { CFGFLAG_SEND_REF, "sendRef", MODE_OUTPUT }, /* XXX: name? */ { CFGFLAG_TICKET_FIRST, "ticketFirst", MODE_OUTPUT }, /* XXX: name? */ { CFGFLAG_PACING_10MS, "pacing10MS", MODE_OUTPUT }, /* XXX: name? */ @@ -131,6 +130,31 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) { json_object_object_add(jobj, "yubiProdConfig", yprod_json); json_object_object_add(yprod_json, "options", options_json); + + if(ycfg.fixedSize != 0 && mode != MODE_STATIC_TICKET) { + json_object *jPrefix; + char prefix[5] = {0}; + + yubikey_modhex_encode(prefix, (const char*)ycfg.fixed, 2); + if(mode == MODE_OATH_HOTP) { + int flag = ycfg.cfgFlags & CFGFLAG_OATH_FIXED_MODHEX; + json_object *fixed_modhex = json_object_new_boolean( + flag == CFGFLAG_OATH_FIXED_MODHEX ? 1 : 0); + json_object_object_add(options_json, "fixedModhex", fixed_modhex); + + if(flag == 0) { + yubikey_hex_encode(prefix, (const char*)ycfg.fixed, 2); + } else if(flag == CFGFLAG_OATH_FIXED_MODHEX1) { + yubikey_hex_encode(prefix + 2, (const char*)ycfg.fixed + 1, 1); + } + } + jPrefix = json_object_new_string(prefix); + json_object_object_add(yprod_json, "prefix", jPrefix); + } else if(mode != MODE_STATIC_TICKET) { + json_object *scope = json_object_new_string("noPublicId"); + json_object_object_add(yprod_json, "scope", scope); + } + if(mode == MODE_OATH_HOTP) { json_object *oathDigits; json_object *randomSeed;