diff options
author | Robert Relyea <rrelyea@redhat.com> | 2010-07-28 20:09:28 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2010-07-28 20:09:28 +0300 |
commit | f8d3142a14d79ed183ba970419f188d35f62e9cc (patch) | |
tree | 0a5a8f960498c5d8e28dba91293c149564445c6f /vcard_emul.h |
initial
Diffstat (limited to 'vcard_emul.h')
-rw-r--r-- | vcard_emul.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/vcard_emul.h b/vcard_emul.h new file mode 100644 index 0000000..c3465a3 --- /dev/null +++ b/vcard_emul.h @@ -0,0 +1,67 @@ +/* + * This is the actual card emulator. + * + * These functions can be implemented in different ways on different platforms using + * the underlying system primitives. For Linux it uses NSS, though direct to PKCS #11, + * openssl+pkcs11, or even gnu crypto libraries+pkcs #11 could be used. On Windows + * CAPI could be used. + */ + +#ifndef VCARD_EMUL_H +#define VCARD_EMUL_H 1 + +#include "card_7816t.h" +#include "vcard.h" + +/* + * types + */ +typedef enum { + VCARD_EMUL_NONE =0, + VCARD_EMUL_CAC +} VCardEmulType; + +typedef enum { + VCARD_EMUL_OK =0, + VCARD_EMUL_FAIL +} VCardEmulError; + +typedef struct VirtualReaderOptionsStruct VirtualReaderOptions; + +struct VirtualReaderOptionsStruct { + char *name; + VCardEmulType card_type; + char **cert_name; + int cert_count; +}; + +typedef struct VCardEmulOptionsStruct VCardEmulOptions; +struct VCardEmulOptionsStruct { + void *nss_db; + VirtualReaderOptions *vreader; + int vreader_count; + VCardEmulType hw_card_type; +}; + +/* + * Login functions + */ +/* return the number of login attempts still possible on the card. if unknown, return -1 */ +int vcard_emul_get_login_count(VCard *card); +/* login into the card, return the 7816 status word (sw2 || sw1) */ +VCard7816Status vcard_emul_login(VCard *card, unsigned char *pin, int pin_len); + +/* + * key functions + */ +/* delete a key */ +void vcard_emul_delete_key(VCardKey *key); +/* RSA sign/decrypt with the key, signature happens 'in place' */ +VCard7816Status vcard_emul_rsa_op(VCard *card, VCardKey *key, + unsigned char *buffer, int buffer_size); + +void vcard_emul_reset(VCard *card, VCardPower power); +void vcard_emul_get_atr(VCard *card, unsigned char *atr, int *atr_len); + +VCardEmulError vcard_emul_init(const VCardEmulOptions *options); +#endif |