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