]> err.no Git - yubikey-personalization/commitdiff
add support for SLOT_NDEF2
authorKlas Lindfors <klas@yubico.com>
Fri, 9 Nov 2012 12:29:45 +0000 (13:29 +0100)
committerKlas Lindfors <klas@yubico.com>
Fri, 9 Nov 2012 12:31:11 +0000 (13:31 +0100)
NEWS
configure.ac
libykpers-1.map
ykcore/ykcore.c
ykcore/ykcore.h
ykcore/ykdef.h
ykpers.c
ykpers4win.mk

diff --git a/NEWS b/NEWS
index e04377a832127f87c220c9f339d584d97d63189b..b5bdc57170a2a575d7f608e60ac0564ab5c3e5c8 100644 (file)
--- 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)
 
index 323a61ac7c804e99fdccde37dec4324418590650..bff703d544d3caddc67bea64bb61148a41f9eaec 100644 (file)
@@ -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])
index 741f85b491472c7b1b494859c6c98ecde746e629..6bdf7d24fcf8d4d7a478a4a67939e6e0a765ddb9 100644 (file)
@@ -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;
index f2f82b8a00ca3da2164661d69e1e63f0c1832710..c57d39413675da9d83b6844fb62ea8cb6193286d 100644 (file)
@@ -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.
index 736bae758bd0b14e672855c8cf2ded9032848655..216a475e737df1d0d1142375333848ed5a14206d 100644 (file)
@@ -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. */
index a81e9424afaaf052b4bba87c6428551e5d6b52b9..5e0cbb66a25ca96e8263257fd6532cbe1edcf96d 100644 (file)
@@ -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 */
 
index c29f69b2af1682995c2312416b976b1e55ad7232..52aee8238bebcf62b2734560818b4cbe2a26ba06 100644 (file)
--- 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 &&
index 56d81cf65093bec82c5f66fb57106e7a790238b3..408010c94ab4c5dc7f2a7ae5e1960f64fc84e1ec 100644 (file)
@@ -29,7 +29,7 @@
 LIBYUBIKEYVERSION=1.9
 PROJECT=yubikey-personalization
 PACKAGE=ykpers
-VERSION=1.9.1
+VERSION=1.10.0
 
 all: usage ykpers4win32 ykpers4win64