From: Klas Lindfors Date: Fri, 9 Nov 2012 12:29:45 +0000 (+0100) Subject: add support for SLOT_NDEF2 X-Git-Tag: v1.10.0~37 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f70b434fe7dff648632df825a95632adcd7ef5ac;p=yubikey-personalization add support for SLOT_NDEF2 --- diff --git a/NEWS b/NEWS index e04377a..b5bdc57 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ Yubikey-personalize NEWS -- History of user-visible changes. -*- outline -*- -* Version 1.9.1 (unreleased) +* Version 1.10.0 (unreleased) * Version 1.9.0 (released 2012-11-08) diff --git a/configure.ac b/configure.ac index 323a61a..bff703d 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -AC_INIT([yubikey-personalization], [1.9.1], +AC_INIT([yubikey-personalization], [1.10.0], [yubico-devel@googlegroups.com], [ykpers], [http://code.google.com/p/yubikey-personalization/]) AC_CONFIG_AUX_DIR([build-aux]) @@ -36,9 +36,9 @@ AC_CONFIG_MACRO_DIR([m4]) # Interfaces changed/added/removed: CURRENT++ REVISION=0 # Interfaces added: AGE++ # Interfaces removed: AGE=0 -AC_SUBST(LT_CURRENT, 10) -AC_SUBST(LT_REVISION, 1) -AC_SUBST(LT_AGE, 9) +AC_SUBST(LT_CURRENT, 11) +AC_SUBST(LT_REVISION, 0) +AC_SUBST(LT_AGE, 10) AM_INIT_AUTOMAKE([-Wall -Werror]) AM_SILENT_RULES([yes]) diff --git a/libykpers-1.map b/libykpers-1.map index 741f85b..6bdf7d2 100644 --- a/libykpers-1.map +++ b/libykpers-1.map @@ -161,3 +161,10 @@ LIBYKPERS_1.9 { yk_hmac_sha1; # Variables: } LIBYKPERS_1.8; + +LIBYKPERS_1.10 { + global: +# Functions: + yk_write_ndef2; +# Variables: +} LIBYKPERS_1.9; diff --git a/ykcore/ykcore.c b/ykcore/ykcore.c index f2f82b8..c57d394 100644 --- a/ykcore/ykcore.c +++ b/ykcore/ykcore.c @@ -251,10 +251,17 @@ int yk_write_config(YK_KEY *yk, YK_CONFIG *cfg, int confnum, } int yk_write_ndef(YK_KEY *yk, YK_NDEF *ndef) +{ + /* just wrap yk_write_ndef2() with confnum 1 */ + return yk_write_ndef2(yk, ndef, 1); +} + +int yk_write_ndef2(YK_KEY *yk, YK_NDEF *ndef, int confnum) { unsigned char buf[sizeof(YK_NDEF)]; YK_STATUS stat; int seq; + uint8_t command; /* Get current sequence # from status block */ @@ -263,13 +270,25 @@ int yk_write_ndef(YK_KEY *yk, YK_NDEF *ndef) seq = stat.pgmSeq; + switch(confnum) { + case 1: + command = SLOT_NDEF; + break; + case 2: + command = SLOT_NDEF2; + break; + default: + yk_errno = YK_EINVALIDCMD; + return 0; + } + /* Insert config block in buffer */ memset(buf, 0, sizeof(buf)); memcpy(buf, ndef, sizeof(YK_NDEF)); /* Write to Yubikey */ - if (!yk_write_to_key(yk, SLOT_NDEF, buf, sizeof(buf))) + if (!yk_write_to_key(yk, command, buf, sizeof(buf))) return 0; /* When the Yubikey clears the SLOT_WRITE_FLAG, it has processed the last write. diff --git a/ykcore/ykcore.h b/ykcore/ykcore.h index 736bae7..216a475 100644 --- a/ykcore/ykcore.h +++ b/ykcore/ykcore.h @@ -115,8 +115,10 @@ extern int yk_write_command(YK_KEY *k, YK_CONFIG *cfg, uint8_t command, /* wrapper function of yk_write_command */ extern int yk_write_config(YK_KEY *k, YK_CONFIG *cfg, int confnum, unsigned char *acc_code); -/* writes the given ndef to the key. */ +/* writes the given ndef to the key as SLOT_NDEF */ extern int yk_write_ndef(YK_KEY *yk, YK_NDEF *ndef); +/* writes the given ndef to the key. */ +extern int yk_write_ndef2(YK_KEY *yk, YK_NDEF *ndef, int confnum); /* 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); /* Do a challenge-response round with the key. */ diff --git a/ykcore/ykdef.h b/ykcore/ykdef.h index a81e942..5e0cbb6 100644 --- a/ykcore/ykdef.h +++ b/ykcore/ykdef.h @@ -38,6 +38,7 @@ #define SLOT_UPDATE2 5 /* Update slot 2 */ #define SLOT_SWAP 6 /* Swap slot 1 and 2 */ #define SLOT_NDEF 8 /* Write NDEF record */ +#define SLOT_NDEF2 9 /* Write NDEF record for slot 2 */ #define SLOT_DEVICE_SERIAL 0x10 /* Device serial number */ diff --git a/ykpers.c b/ykpers.c index c29f69b..52aee82 100644 --- a/ykpers.c +++ b/ykpers.c @@ -184,6 +184,11 @@ int ykp_configure_command(YKP_CONFIG *cfg, uint8_t command) return 0; } break; + case SLOT_NDEF2: + if (!(cfg->yk_major_version == 3)) { + ykp_errno = YKP_EYUBIKEYVER; + return 0; + } case SLOT_NDEF: /* NDEF is available for neo, thus within 2.1 from build 4 */ if (!((cfg->yk_major_version == 2 && cfg->yk_minor_version == 1 && diff --git a/ykpers4win.mk b/ykpers4win.mk index 56d81cf..408010c 100644 --- a/ykpers4win.mk +++ b/ykpers4win.mk @@ -29,7 +29,7 @@ LIBYUBIKEYVERSION=1.9 PROJECT=yubikey-personalization PACKAGE=ykpers -VERSION=1.9.1 +VERSION=1.10.0 all: usage ykpers4win32 ykpers4win64