From: levitte@gmail.com 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_0.97-1~36 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e17c94fc30808963e9b2a98fe8a537a41a3d5d6f;p=yubikey-personalization 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 --- 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); /************************************************************************* *