From e17c94fc30808963e9b2a98fe8a537a41a3d5d6f Mon Sep 17 00:00:00 2001 From: "levitte@gmail.com" Date: Mon, 24 Aug 2009 13:43:05 +0000 Subject: [PATCH] Make it possible to write to more than one configuration slot git-svn-id: https://yubikey-personalization.googlecode.com/svn/trunk@144 b62f149e-849f-11dd-9899-c7ba65f7c4c7 --- ykcore/ykcore.c | 15 ++++++++++++--- ykcore/ykcore.h | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ykcore/ykcore.c b/ykcore/ykcore.c index a16f734..1e32e6a 100644 --- a/ykcore/ykcore.c +++ b/ykcore/ykcore.c @@ -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 */ diff --git a/ykcore/ykcore.h b/ykcore/ykcore.h index 3fd121e..01f4fac 100644 --- a/ykcore/ykcore.h +++ b/ykcore/ykcore.h @@ -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); /************************************************************************* * -- 2.39.5