1 /* -*- mode:C; c-file-style: "bsd" -*- */ 2 /* 3 * Copyright (c) 2013 Yubico AB 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials provided 16 * with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef __YKPERS_LCL_H_INCLUDED__ 32 #define __YKPERS_LCL_H_INCLUDED__ 33 34 #include "ykcore_lcl.h" 35 #include "ykpers.h" 36 37 # ifdef __cplusplus 38 extern "C" { 39 # endif 40 41 struct ykp_config_t { 42 unsigned int yk_major_version; 43 unsigned int yk_minor_version; 44 unsigned int yk_build_version; 45 unsigned int command; 46 47 YK_CONFIG ykcore_config; 48 49 unsigned int ykp_acccode_type; 50 }; 51 52 extern bool capability_has_hidtrig(const YKP_CONFIG *cfg); 53 extern bool capability_has_ticket_first(const YKP_CONFIG *cfg); 54 extern bool capability_has_static(const YKP_CONFIG *cfg); 55 extern bool capability_has_static_extras(const YKP_CONFIG *cfg); 56 extern bool capability_has_slot_two(const YKP_CONFIG *cfg); 57 extern bool capability_has_chal_resp(const YKP_CONFIG *cfg); 58 extern bool capability_has_oath_imf(const YKP_CONFIG *cfg); 59 extern bool capability_has_serial_api(const YKP_CONFIG *cfg); 60 extern bool capability_has_serial(const YKP_CONFIG *cfg); 61 extern bool capability_has_oath(const YKP_CONFIG *cfg); 62 extern bool capability_has_ticket_mods(const YKP_CONFIG *cfg); 63 extern bool capability_has_update(const YKP_CONFIG *cfg); 64 extern bool capability_has_fast(const YKP_CONFIG *cfg); 65 extern bool capability_has_numeric(const YKP_CONFIG *cfg); 66 extern bool capability_has_dormant(const YKP_CONFIG *cfg); 67 extern bool capability_has_led_inv(const YKP_CONFIG *cfg); 68 69 struct map_st { 70 uint8_t flag; 71 const char *flag_text; 72 const char *json_text; 73 bool (*capability)(const YKP_CONFIG *cfg); 74 unsigned char mode; 75 int (*setter)(YKP_CONFIG *cfg, bool state); 76 }; 77 78 extern struct map_st _ticket_flags_map[]; 79 extern struct map_st _config_flags_map[]; 80 extern struct map_st _extended_flags_map[]; 81 extern struct map_st _modes_map[]; 82 83 #define MODE_CHAL_HMAC 0x01 84 #define MODE_OATH_HOTP 0x02 85 #define MODE_OTP_YUBICO 0x04 86 #define MODE_CHAL_YUBICO 0x08 87 #define MODE_STATIC_TICKET 0x10 88 89 #define MODE_CHAL_RESP MODE_CHAL_YUBICO | MODE_CHAL_HMAC 90 #define MODE_OUTPUT MODE_STATIC_TICKET | MODE_OTP_YUBICO | MODE_OATH_HOTP 91 #define MODE_ALL 0xff 92 93 # ifdef __cplusplus 94 } 95 # endif 96 97 #endif /* __YKPERS_LCL_H_INCLUDED__ */ 98