Fix EC templates on Stax

This commit is contained in:
Charles-Edouard de la Vergne 2024-02-26 11:05:34 +01:00
parent 285fbcfaf3
commit 4390142ffa
No known key found for this signature in database
GPG Key ID: F12296941B7BB9C6

View File

@ -280,14 +280,7 @@ static void template_key_cb(int token, uint8_t index) {
uint32_t size = 0;
uint8_t key_type = index + FIRST_USER_TOKEN;
switch (token) {
case TOKEN_TYPE_BACK:
break;
case TOKEN_TYPE_RSA2048:
case TOKEN_TYPE_RSA3072:
case TOKEN_TYPE_RSA4096:
case TOKEN_TYPE_SECP256K1:
case TOKEN_TYPE_Ed25519:
if (token != TOKEN_TYPE_BACK) {
memset(&attributes, 0, sizeof(attributes));
switch (key_type) {
case TOKEN_TYPE_RSA2048:
@ -320,7 +313,7 @@ static void template_key_cb(int token, uint8_t index) {
attributes.value[0] = KEY_ID_ECDSA;
}
oid = gpg_curve2oid(CX_CURVE_SECP256R1, &oid_len);
memmove(attributes.value + 1, oid, sizeof(oid_len));
memmove(attributes.value + 1, oid, oid_len);
attributes.length = 1 + oid_len;
break;
@ -332,7 +325,7 @@ static void template_key_cb(int token, uint8_t index) {
attributes.value[0] = KEY_ID_EDDSA;
oid = gpg_curve2oid(CX_CURVE_Ed25519, &oid_len);
}
memmove(attributes.value + 1, oid, sizeof(oid_len));
memmove(attributes.value + 1, oid, oid_len);
attributes.length = 1 + oid_len;
break;
}
@ -351,11 +344,9 @@ static void template_key_cb(int token, uint8_t index) {
if (dest && attributes.value[0] &&
memcmp(&dest->attributes, &attributes, sizeof(attributes)) != 0) {
PRINTF("TEMPLATE NVM_WRITE!!!!!\n");
nvm_write(dest, NULL, sizeof(gpg_key_t));
nvm_write(&dest->attributes, &attributes, sizeof(attributes));
}
break;
}
ui_settings_template();
}