5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * Copyright 2005,2006 TRI-D Systems, Inc.
28 * Card Features bitmask.
31 /* sync/async modes */
32 #define OTP_CF_AM 0x01 << 1 /* async mode (chal/resp) */
33 #define OTP_CF_ES 0x01 << 2 /* event synchronous */
34 #define OTP_CF_TS 0x01 << 3 /* time synchronous */
35 #define OTP_CF_SM (OTP_CF_ES|OTP_CF_TS)
37 #define OTP_CF_HD 0x01 << 4 /* hex display */
38 #define OTP_CF_DD 0x01 << 5 /* dec display */
39 #define OTP_CF_R8 0x01 << 6 /* 8 digit response */
40 #define OTP_CF_R7 0x01 << 7 /* 7 digit response */
41 #define OTP_CF_R6 0x01 << 8 /* 6 digit response */
42 #define OTP_CF_RP 0x01 << 9 /* phone response */
43 /* sync challenge length */
44 #define OTP_CF_C8 0x01 << 10 /* 8 byte challenge */
45 #define OTP_CF_C4 0x01 << 11 /* 4 byte challenge */
46 #define OTP_CF_CL (OTP_CF_C8|OTP_CF_C4)
47 #define OTP_CF_CL_SHIFT 10 /* convert mask to value */
48 /* nominal twindow (TRI-D) */
49 #define OTP_CF_TW0 0x01 << 12 /* twindow 2^0 */
50 #define OTP_CF_TW1 0x01 << 13 /* twindow 2^1 */
51 #define OTP_CF_TW2 0x01 << 14 /* twindow 2^2 */
52 #define OTP_CF_TW3 0x01 << 15 /* twindow 2^3 */
53 #define OTP_CF_TW (OTP_CF_TW0|OTP_CF_TW1|OTP_CF_TW2|OTP_CF_TW3)
54 #define OTP_CF_TW_SHIFT 12 /* convert mask to value */
55 /* force rwindow for event+time sync cards (TRI-D) */
56 #define OTP_CF_FRW0 0x01 << 16 /* force event window 2^0 */
57 #define OTP_CF_FRW1 0x01 << 17 /* force event window 2^1 */
58 #define OTP_CF_FRW2 0x01 << 18 /* force event window 2^2 */
59 #define OTP_CF_FRW (OTP_CF_FRW0|OTP_CF_FRW1|OTP_CF_FRW2)
60 #define OTP_CF_FRW_SHIFT 16 /* convert mask to value */
62 #define OTP_CF_VS1 0x01 << 19 /* vendor specific 1 */
63 #define OTP_CF_VS2 0x01 << 20 /* vendor specific 2 */
64 #define OTP_CF_VS3 0x01 << 21 /* vendor specific 3 */
65 #define OTP_CF_VS4 0x01 << 22 /* vendor specific 4 */
67 #define OTP_CF_MAX 0x01 << 31 /* MAX placeholder */
69 #define OTP_MAX_RESPONSE_LEN 16 /* Secure Computing can do 16 */
72 typedef struct cardops_t {
74 size_t prefix_len; /* to avoid strlen(prefix) */
76 int (*name2fm)(const char *, uint32_t *);
77 int (*keystring2keyblock)(const char *, unsigned char [OTP_MAX_KEY_LEN]);
78 int (*nullstate)(const otp_option_t *, const otp_card_info_t *,
79 otp_user_state_t *, time_t, const char *);
80 int (*challenge)(const otp_card_info_t *, otp_user_state_t *,
81 unsigned char [OTP_MAX_CHALLENGE_LEN], time_t, int, int,
83 int (*response)(otp_card_info_t *,
84 const unsigned char [OTP_MAX_CHALLENGE_LEN], size_t,
85 char [OTP_MAX_RESPONSE_LEN + 1], const char *);
86 int (*updatecsd)(otp_user_state_t *, time_t, int, int, int);
87 int (*isconsecutive)(const otp_card_info_t *, const otp_user_state_t *, int,
89 int (*maxtwin)(const otp_card_info_t *, const char [OTP_MAX_CSD_LEN + 1]);
90 char *(*printchallenge)(char [OTP_MAX_CHALLENGE_LEN * 2 + 1],
91 const unsigned char [OTP_MAX_CHALLENGE_LEN], size_t);
93 #define OTP_MAX_VENDORS 16
94 extern cardops_t otp_cardops[OTP_MAX_VENDORS];
95 extern int otp_num_cardops;
97 #endif /* OTP_CARDOPS_H */