From bdd7ecdcd3dc16e752e32b57f8020ce88a91f366 Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Tue, 8 Mar 2011 20:29:47 +0100 Subject: [PATCH] Add new libykpers functions. --- libykpers-1.map | 1 + ykcore/ykcore.c | 7 +++++++ ykcore/ykcore.h | 13 +++++++++++++ 3 files changed, 21 insertions(+) diff --git a/libykpers-1.map b/libykpers-1.map index f18d42e..3fb110c 100644 --- a/libykpers-1.map +++ b/libykpers-1.map @@ -115,5 +115,6 @@ LIBYKPERS_1.5 { # Functions: yk_wait_for_key_status; yk_read_response_from_key; + yk_get_serial; # Variables: } LIBYKPERS_1.4; diff --git a/ykcore/ykcore.c b/ykcore/ykcore.c index ed2afd4..88aff0e 100644 --- a/ykcore/ykcore.c +++ b/ykcore/ykcore.c @@ -470,6 +470,13 @@ int yk_read_response_from_key(YK_KEY *yk, uint8_t slot, unsigned int flags, return 0; } +/* + * Send something to the YubiKey. The command, as well as the slot, is + * given in the 'slot' parameter (e.g. SLOT_CHAL_HMAC2 to send a HMAC-SHA1 + * challenge to slot 2). + * + * The slot parameter is here for future purposes only. + */ int yk_write_to_key(YK_KEY *yk, uint8_t slot, const void *buf, int bufcount) { YK_FRAME frame; diff --git a/ykcore/ykcore.h b/ykcore/ykcore.h index 305a9ec..1cb56b8 100644 --- a/ykcore/ykcore.h +++ b/ykcore/ykcore.h @@ -84,6 +84,17 @@ extern int yk_close_key(YK_KEY *k); /* closes a previously opened key */ extern int yk_get_status(YK_KEY *k, YK_STATUS *status /*, int forceUpdate */); /* checks that the firmware revision of the key is supported */ extern int yk_check_firmware_version(YK_KEY *k); +/* Read the factory set serial number from a YubiKey 2.0 or higher. */ +extern int yk_get_serial(YK_KEY *yk, uint8_t slot, unsigned int flags, unsigned int *serial); +/* Wait for the key to either set or clear bits in it's status byte */ +extern int yk_wait_for_key_status(YK_KEY *yk, uint8_t slot, unsigned int flags, + unsigned int max_time_ms, + bool logic_and, unsigned char mask, + unsigned char *last_data); +/* Read the response to a command from the YubiKey */ +extern int yk_read_response_from_key(YK_KEY *yk, uint8_t slot, unsigned int flags, + void *buf, unsigned int bufsize, unsigned int expect_bytes, + unsigned int *bytes_read); /************************************************************************* * @@ -96,6 +107,8 @@ extern int yk_check_firmware_version(YK_KEY *k); acc_code has to be provided of the key has a protecting access code. */ extern int yk_write_config(YK_KEY *k, YK_CONFIG *cfg, int confnum, unsigned char *acc_code); +/* Write something to the YubiKey (a command that is). */ +extern int yk_write_to_key(YK_KEY *yk, uint8_t slot, const void *buf, int bufcount); /************************************************************************* * -- 2.39.5