root / libcacard / vcard_emul.h @ fc27eefe
History | View | Annotate | Download (2.1 kB)
1 | 111a38b0 | Robert Relyea | /*
|
---|---|---|---|
2 | 111a38b0 | Robert Relyea | * This is the actual card emulator.
|
3 | 111a38b0 | Robert Relyea | *
|
4 | 111a38b0 | Robert Relyea | * These functions can be implemented in different ways on different platforms
|
5 | 111a38b0 | Robert Relyea | * using the underlying system primitives. For Linux it uses NSS, though direct
|
6 | 111a38b0 | Robert Relyea | * to PKCS #11, openssl+pkcs11, or even gnu crypto libraries+pkcs #11 could be
|
7 | 111a38b0 | Robert Relyea | * used. On Windows CAPI could be used.
|
8 | 111a38b0 | Robert Relyea | *
|
9 | 111a38b0 | Robert Relyea | * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
10 | 111a38b0 | Robert Relyea | * See the COPYING.LIB file in the top-level directory.
|
11 | 111a38b0 | Robert Relyea | */
|
12 | 111a38b0 | Robert Relyea | |
13 | 111a38b0 | Robert Relyea | #ifndef VCARD_EMUL_H
|
14 | 111a38b0 | Robert Relyea | #define VCARD_EMUL_H 1 |
15 | 111a38b0 | Robert Relyea | |
16 | 111a38b0 | Robert Relyea | #include "card_7816t.h" |
17 | 111a38b0 | Robert Relyea | #include "vcard.h" |
18 | 111a38b0 | Robert Relyea | #include "vcard_emul_type.h" |
19 | 111a38b0 | Robert Relyea | |
20 | 111a38b0 | Robert Relyea | /*
|
21 | 111a38b0 | Robert Relyea | * types
|
22 | 111a38b0 | Robert Relyea | */
|
23 | 111a38b0 | Robert Relyea | typedef enum { |
24 | 111a38b0 | Robert Relyea | VCARD_EMUL_OK = 0,
|
25 | 111a38b0 | Robert Relyea | VCARD_EMUL_FAIL, |
26 | 111a38b0 | Robert Relyea | /* return values by vcard_emul_init */
|
27 | 111a38b0 | Robert Relyea | VCARD_EMUL_INIT_ALREADY_INITED, |
28 | 111a38b0 | Robert Relyea | } VCardEmulError; |
29 | 111a38b0 | Robert Relyea | |
30 | 111a38b0 | Robert Relyea | /* options are emul specific. call card_emul_parse_args to change a string
|
31 | 111a38b0 | Robert Relyea | * To an options struct */
|
32 | 111a38b0 | Robert Relyea | typedef struct VCardEmulOptionsStruct VCardEmulOptions; |
33 | 111a38b0 | Robert Relyea | |
34 | 111a38b0 | Robert Relyea | /*
|
35 | 111a38b0 | Robert Relyea | * Login functions
|
36 | 111a38b0 | Robert Relyea | */
|
37 | 111a38b0 | Robert Relyea | /* return the number of login attempts still possible on the card. if unknown,
|
38 | 111a38b0 | Robert Relyea | * return -1 */
|
39 | 111a38b0 | Robert Relyea | int vcard_emul_get_login_count(VCard *card);
|
40 | 111a38b0 | Robert Relyea | /* login into the card, return the 7816 status word (sw2 || sw1) */
|
41 | 111a38b0 | Robert Relyea | vcard_7816_status_t vcard_emul_login(VCard *card, unsigned char *pin, |
42 | 111a38b0 | Robert Relyea | int pin_len);
|
43 | 111a38b0 | Robert Relyea | |
44 | 111a38b0 | Robert Relyea | /*
|
45 | 111a38b0 | Robert Relyea | * key functions
|
46 | 111a38b0 | Robert Relyea | */
|
47 | 111a38b0 | Robert Relyea | /* delete a key */
|
48 | 111a38b0 | Robert Relyea | void vcard_emul_delete_key(VCardKey *key);
|
49 | 111a38b0 | Robert Relyea | /* RSA sign/decrypt with the key, signature happens 'in place' */
|
50 | 111a38b0 | Robert Relyea | vcard_7816_status_t vcard_emul_rsa_op(VCard *card, VCardKey *key, |
51 | 111a38b0 | Robert Relyea | unsigned char *buffer, int buffer_size); |
52 | 111a38b0 | Robert Relyea | |
53 | 111a38b0 | Robert Relyea | void vcard_emul_reset(VCard *card, VCardPower power);
|
54 | 111a38b0 | Robert Relyea | void vcard_emul_get_atr(VCard *card, unsigned char *atr, int *atr_len); |
55 | 111a38b0 | Robert Relyea | |
56 | 111a38b0 | Robert Relyea | /* Re-insert of a card that has been removed by force removal */
|
57 | 111a38b0 | Robert Relyea | VCardEmulError vcard_emul_force_card_insert(VReader *vreader); |
58 | 111a38b0 | Robert Relyea | /* Force a card removal even if the card is not physically removed */
|
59 | 111a38b0 | Robert Relyea | VCardEmulError vcard_emul_force_card_remove(VReader *vreader); |
60 | 111a38b0 | Robert Relyea | |
61 | 111a38b0 | Robert Relyea | VCardEmulOptions *vcard_emul_options(const char *args); |
62 | 111a38b0 | Robert Relyea | VCardEmulError vcard_emul_init(const VCardEmulOptions *options);
|
63 | 111a38b0 | Robert Relyea | void vcard_emul_replay_insertion_events(void); |
64 | 111a38b0 | Robert Relyea | void vcard_emul_usage(void); |
65 | 111a38b0 | Robert Relyea | #endif |