Added device option KEY_COUNTER_ALL.

When it is set, it enables the key usage counter for all keys when generated.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2022-06-03 20:10:53 +02:00
parent aca291da9e
commit 40efcd71c3
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3
2 changed files with 7 additions and 3 deletions

View file

@ -941,9 +941,12 @@ int find_and_store_meta_key(uint8_t key_id) {
}
}
if (lt[0] == 0 && pt[0] == NULL) {
lt[0] = 4;
pt[0] = t90;
meta_size += 6;
uint16_t opts = get_device_options();
if (opts & HSM_OPT_KEY_COUNTER_ALL) {
lt[0] = 4;
pt[0] = t90;
meta_size += 6;
}
}
if (meta_size) {
uint8_t *meta = (uint8_t *)calloc(1, meta_size), *m = meta;

View file

@ -56,6 +56,7 @@ extern const uint8_t sc_hsm_aid[];
#define HSM_OPT_COMBINED_AUTH 0x0010
#define HSM_OPT_RRC_RESET_ONLY 0x0020
#define HSM_OPT_BOOTSEL_BUTTON 0x0100
#define HSM_OPT_KEY_COUNTER_ALL 0x0200
#define PRKD_PREFIX 0xC4 /* Hi byte in file identifier for PKCS#15 PRKD objects */
#define CD_PREFIX 0xC8 /* Hi byte in file identifier for PKCS#15 CD objects */