File:  [Qemu by Fabrice Bellard] / qemu / libcacard / vcard_emul.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 19:03:08 2018 UTC (3 years, 7 months ago) by root
Branches: qemu, MAIN
CVS tags: qemu1101, qemu1001, qemu1000, qemu0151, HEAD
qemu 0.15.1

    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: 
   44: /*
   45:  * key functions
   46:  */
   47: /* delete a key */
   48: void vcard_emul_delete_key(VCardKey *key);
   49: /* RSA sign/decrypt with the key, signature happens 'in place' */
   50: vcard_7816_status_t vcard_emul_rsa_op(VCard *card, VCardKey *key,
   51:                                   unsigned char *buffer, int buffer_size);
   52: 
   53: void vcard_emul_reset(VCard *card, VCardPower power);
   54: void vcard_emul_get_atr(VCard *card, unsigned char *atr, int *atr_len);
   55: 
   56: /* Re-insert of a card that has been removed by force removal */
   57: VCardEmulError vcard_emul_force_card_insert(VReader *vreader);
   58: /* Force a card removal even if the card is not physically removed */
   59: VCardEmulError vcard_emul_force_card_remove(VReader *vreader);
   60: 
   61: VCardEmulOptions *vcard_emul_options(const char *args);
   62: VCardEmulError vcard_emul_init(const VCardEmulOptions *options);
   63: void vcard_emul_replay_insertion_events(void);
   64: void vcard_emul_usage(void);
   65: #endif

unix.superglobalmegacorp.com