]> err.no Git - yubikey-personalization.old/commitdiff
Make it possible to write to more than one configuration slot
authorRichard Levitte <levitte@lp.se>
Mon, 24 Aug 2009 13:43:05 +0000 (13:43 +0000)
committerRichard Levitte <levitte@lp.se>
Mon, 24 Aug 2009 13:43:05 +0000 (13:43 +0000)
ykcore/ykcore.c
ykcore/ykcore.h

index a16f734c261cec1e9a6116e127f957da0eef0b44..1e32e6a50791117237763fc4aa84f2b7482bd9b5 100644 (file)
@@ -102,7 +102,8 @@ int yk_get_status(YK_KEY *k, YK_STATUS *status)
        return 1;
 }
 
-int yk_write_config(YK_KEY *yk, YK_CONFIG *cfg, unsigned char *acc_code)
+int yk_write_config(YK_KEY *yk, YK_CONFIG *cfg, int confnum,
+                   unsigned char *acc_code)
 {
        unsigned char buf[sizeof(YK_CONFIG) + ACC_CODE_SIZE];
        YK_STATUS stat;
@@ -133,8 +134,16 @@ int yk_write_config(YK_KEY *yk, YK_CONFIG *cfg, unsigned char *acc_code)
 
        /* Write to Yubikey */
 
-       if (!yk_write_to_key(yk, SLOT_CONFIG, buf, sizeof(buf)))
-               return 0;
+       switch(confnum) {
+       case 1:
+               if (!yk_write_to_key(yk, SLOT_CONFIG, buf, sizeof(buf)))
+                       return 0;
+               break;
+       case 2:
+               if (!yk_write_to_key(yk, SLOT_CONFIG2, buf, sizeof(buf)))
+                       return 0;
+               break;
+       }
 
        /* Verify update */
 
index 3fd121eea052d21235e682bb692848f06a143dc4..01f4fac076b5975d052c24f7bc47b317f9be7110 100644 (file)
@@ -91,7 +91,8 @@ extern int yk_get_status(YK_KEY *k, YK_STATUS *status /*, int forceUpdate */);
 /* writes the given configuration to the key.  If the configuration is NULL,
    zap the key configuration.
    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, unsigned char *acc_code);
+extern int yk_write_config(YK_KEY *k, YK_CONFIG *cfg, int confnum,
+                          unsigned char *acc_code);
 
 /*************************************************************************
  *