From: Richard Levitte Date: Mon, 24 Aug 2009 13:43:05 +0000 (+0000) Subject: Make it possible to write to more than one configuration slot X-Git-Tag: yubikey-personalisation_1.3.5-1~4^2~101 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87c1b6019405fbd44596f6b77eb985b8ad7582b6;p=yubikey-personalization Make it possible to write to more than one configuration slot --- 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); /************************************************************************* *