diff --git a/Makefile b/Makefile index b867aef..da59afa 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ APPNAME = OpenPGP # Application version APPVERSION_M = 2 APPVERSION_N = 2 -APPVERSION_P = 0 +APPVERSION_P = 1 APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)" SPECVERSION:="3.3.1" diff --git a/src/gpg_pso.c b/src/gpg_pso.c index c792a88..82d4b24 100644 --- a/src/gpg_pso.c +++ b/src/gpg_pso.c @@ -321,15 +321,12 @@ int gpg_apdu_pso() { } key = &G_gpg_vstate.mse_dec->priv_key.ecfp; gpg_io_fetch_l(&l); - if (l != 37) { + gpg_io_fetch_tl(&t, &l); + if (t != 0x7f49) { return SW_WRONG_DATA; } gpg_io_fetch_tl(&t, &l); - if ((t != 0x7f49) || (l != 34)) { - return SW_WRONG_DATA; - } - gpg_io_fetch_tl(&t, &l); - if ((t != 0x86) || (l != 32)) { + if (t != 0x86) { return SW_WRONG_DATA; } diff --git a/src/gpg_ux.h b/src/gpg_ux.h index fc7a63d..38b56fe 100644 --- a/src/gpg_ux.h +++ b/src/gpg_ux.h @@ -29,6 +29,7 @@ #define LABEL_RSA2048 "RSA 2048" #define LABEL_RSA3072 "RSA 3072" #define LABEL_RSA4096 "RSA 4096" +#define LABEL_SECP256K1 "SECP 256K1" #define LABEL_SECP256R1 "SECP 256R1" #define LABEL_Ed25519 "Ed25519" diff --git a/src/gpg_ux_nanos.c b/src/gpg_ux_nanos.c index 87255d9..c26692b 100644 --- a/src/gpg_ux_nanos.c +++ b/src/gpg_ux_nanos.c @@ -535,6 +535,7 @@ const ux_menu_entry_t ui_menu_tmpl_type[] = { #ifdef WITH_SUPPORT_RSA4096 {NULL, ui_menu_tmpl_type_action, 4096, NULL, LABEL_RSA4096, NULL, 0, 0}, #endif + {NULL, ui_menu_tmpl_type_action, CX_CURVE_SECP256K1, NULL, LABEL_SECP256K1, NULL, 0, 0}, {NULL, ui_menu_tmpl_type_action, CX_CURVE_SECP256R1, NULL, LABEL_SECP256R1, NULL, 0, 0}, {NULL, ui_menu_tmpl_type_action, CX_CURVE_Ed25519, NULL, LABEL_Ed25519, NULL, 0, 0}, {ui_menu_template, NULL, 0, &C_icon_back, "Back", NULL, 61, 40}, @@ -573,6 +574,9 @@ const bagl_element_t *ui_menu_template_predisplay(const ux_menu_entry_t *entry, snprintf(G_gpg_vstate.menu, sizeof(G_gpg_vstate.menu), " %s", LABEL_RSA4096); break; #endif + case CX_CURVE_SECP256K1: + snprintf(G_gpg_vstate.menu, sizeof(G_gpg_vstate.menu), " %s", LABEL_SECP256K1); + break; case CX_CURVE_SECP256R1: snprintf(G_gpg_vstate.menu, sizeof(G_gpg_vstate.menu), " %s", LABEL_SECP256R1); break; @@ -615,6 +619,7 @@ void ui_menu_tmpl_set_action(unsigned int value) { attributes.length = 6; break; + case CX_CURVE_SECP256K1: case CX_CURVE_SECP256R1: if (G_gpg_vstate.ux_key == 2) { attributes.value[0] = KEY_ID_ECDH; diff --git a/src/gpg_ux_nanox.c b/src/gpg_ux_nanox.c index fec2006..c1c5f85 100644 --- a/src/gpg_ux_nanox.c +++ b/src/gpg_ux_nanox.c @@ -473,6 +473,7 @@ const char *const tmpl_type_getter_values[] = {LABEL_RSA2048, #ifdef WITH_SUPPORT_RSA4096 LABEL_RSA4096, #endif + LABEL_SECP256K1, LABEL_SECP256R1, LABEL_Ed25519}; @@ -481,6 +482,7 @@ const unsigned int tmpl_type_getter_values_map[] = {2048, #ifdef WITH_SUPPORT_RSA4096 4096, #endif + CX_CURVE_SECP256K1, CX_CURVE_SECP256R1, CX_CURVE_Ed25519}; @@ -572,6 +574,9 @@ void ui_menu_template_predisplay() { snprintf(KEY_TYPE, sizeof(KEY_TYPE), " %s", LABEL_RSA4096); break; #endif + case CX_CURVE_SECP256K1: + snprintf(KEY_TYPE, sizeof(KEY_TYPE), " %s", LABEL_SECP256K1); + break; case CX_CURVE_SECP256R1: snprintf(KEY_TYPE, sizeof(KEY_TYPE), " %s", LABEL_SECP256R1); break; @@ -610,6 +615,7 @@ void ui_menu_tmpl_set_action(unsigned int value) { attributes.length = 6; break; + case CX_CURVE_SECP256K1: case CX_CURVE_SECP256R1: oid = gpg_curve2oid(G_gpg_vstate.ux_type, &oid_len); if (oid == NULL) { diff --git a/src/gpg_ux_nbgl.c b/src/gpg_ux_nbgl.c index 1f7e9e1..2af475a 100644 --- a/src/gpg_ux_nbgl.c +++ b/src/gpg_ux_nbgl.c @@ -207,6 +207,7 @@ enum { #ifdef WITH_SUPPORT_RSA4096 TOKEN_TYPE_RSA4096, #endif + TOKEN_TYPE_SECP256K1, TOKEN_TYPE_SECP256R1, TOKEN_TYPE_Ed25519, TOKEN_TYPE_BACK @@ -217,12 +218,12 @@ static const char* const keyTypeTexts[] = {LABEL_RSA2048, #ifdef WITH_SUPPORT_RSA4096 LABEL_RSA4096, #endif + LABEL_SECP256K1, LABEL_SECP256R1, LABEL_Ed25519}; static uint32_t _getKeyType(const uint8_t key) { uint8_t* attributes = NULL; - uint32_t tag = 0; uint32_t token = 0; switch (key) { @@ -241,8 +242,7 @@ static uint32_t _getKeyType(const uint8_t key) { } switch (attributes[0]) { case KEY_ID_RSA: - tag = U2BE(attributes, 1); - switch (tag) { + switch (U2BE(attributes, 1)) { case 2048: token = TOKEN_TYPE_RSA2048; break; @@ -257,18 +257,31 @@ static uint32_t _getKeyType(const uint8_t key) { } break; case KEY_ID_ECDH: - tag = attributes[1]; - switch (tag) { + switch (attributes[1]) { case 0x2A: token = TOKEN_TYPE_SECP256R1; break; case 0x2B: - token = TOKEN_TYPE_Ed25519; + switch (attributes[2]) { + case 0x06: + token = TOKEN_TYPE_Ed25519; + break; + case 0x81: + token = TOKEN_TYPE_SECP256K1; + break; + } break; } break; case KEY_ID_ECDSA: - token = TOKEN_TYPE_SECP256R1; + switch (attributes[1]) { + case 0x2A: + token = TOKEN_TYPE_SECP256R1; + break; + case 0x2B: + token = TOKEN_TYPE_SECP256K1; + break; + } break; case KEY_ID_EDDSA: token = TOKEN_TYPE_Ed25519; @@ -315,6 +328,17 @@ static void template_key_cb(int token, uint8_t index) { oid_len = 6; break; + case TOKEN_TYPE_SECP256K1: + if (G_gpg_vstate.ux_key == TOKEN_TEMPLATE_DEC) { + attributes.value[0] = KEY_ID_ECDH; + } else { + attributes.value[0] = KEY_ID_ECDSA; + } + oid = gpg_curve2oid(CX_CURVE_SECP256K1, &oid_len); + memmove(attributes.value + 1, oid, oid_len); + attributes.length = 1 + oid_len; + break; + case TOKEN_TYPE_SECP256R1: if (G_gpg_vstate.ux_key == TOKEN_TEMPLATE_DEC) { attributes.value[0] = KEY_ID_ECDH; @@ -409,6 +433,9 @@ static void ui_settings_template(void) { bar.subText = PIC(LABEL_RSA4096); break; #endif + case TOKEN_TYPE_SECP256K1: + bar.subText = PIC(LABEL_SECP256K1); + break; case TOKEN_TYPE_SECP256R1: bar.subText = PIC(LABEL_SECP256R1); break; diff --git a/tests/snapshots/nanos/test_menu_settings/00006.png b/tests/snapshots/nanos/test_menu_settings/00006.png index 5304bfc..f434eb1 100644 Binary files a/tests/snapshots/nanos/test_menu_settings/00006.png and b/tests/snapshots/nanos/test_menu_settings/00006.png differ diff --git a/tests/snapshots/nanos/test_menu_settings/00007.png b/tests/snapshots/nanos/test_menu_settings/00007.png index 706365e..280b683 100644 Binary files a/tests/snapshots/nanos/test_menu_settings/00007.png and b/tests/snapshots/nanos/test_menu_settings/00007.png differ diff --git a/tests/snapshots/nanos/test_menu_settings/00008.png b/tests/snapshots/nanos/test_menu_settings/00008.png index c51842f..41bbb72 100644 Binary files a/tests/snapshots/nanos/test_menu_settings/00008.png and b/tests/snapshots/nanos/test_menu_settings/00008.png differ diff --git a/tests/snapshots/nanos/test_menu_settings/00009.png b/tests/snapshots/nanos/test_menu_settings/00009.png index 6dea62d..81ce431 100644 Binary files a/tests/snapshots/nanos/test_menu_settings/00009.png and b/tests/snapshots/nanos/test_menu_settings/00009.png differ diff --git a/tests/snapshots/nanos/test_menu_settings/00013.png b/tests/snapshots/nanos/test_menu_settings/00013.png index 6dea62d..81ce431 100644 Binary files a/tests/snapshots/nanos/test_menu_settings/00013.png and b/tests/snapshots/nanos/test_menu_settings/00013.png differ diff --git a/tests/snapshots/nanosp/test_menu_settings/00006.png b/tests/snapshots/nanosp/test_menu_settings/00006.png index 9fb6bea..99fc174 100644 Binary files a/tests/snapshots/nanosp/test_menu_settings/00006.png and b/tests/snapshots/nanosp/test_menu_settings/00006.png differ diff --git a/tests/snapshots/nanosp/test_menu_settings/00007.png b/tests/snapshots/nanosp/test_menu_settings/00007.png index c4df69f..3ad71f8 100644 Binary files a/tests/snapshots/nanosp/test_menu_settings/00007.png and b/tests/snapshots/nanosp/test_menu_settings/00007.png differ diff --git a/tests/snapshots/nanosp/test_menu_settings/00008.png b/tests/snapshots/nanosp/test_menu_settings/00008.png index 3d0298a..e678a83 100644 Binary files a/tests/snapshots/nanosp/test_menu_settings/00008.png and b/tests/snapshots/nanosp/test_menu_settings/00008.png differ diff --git a/tests/snapshots/nanosp/test_menu_settings/00009.png b/tests/snapshots/nanosp/test_menu_settings/00009.png index 3feeb0a..03a2ed8 100644 Binary files a/tests/snapshots/nanosp/test_menu_settings/00009.png and b/tests/snapshots/nanosp/test_menu_settings/00009.png differ diff --git a/tests/snapshots/nanosp/test_menu_settings/00010.png b/tests/snapshots/nanosp/test_menu_settings/00010.png index 2aa394d..ae682df 100644 Binary files a/tests/snapshots/nanosp/test_menu_settings/00010.png and b/tests/snapshots/nanosp/test_menu_settings/00010.png differ diff --git a/tests/snapshots/nanosp/test_menu_settings/00012.png b/tests/snapshots/nanosp/test_menu_settings/00012.png index 2aa394d..ae682df 100644 Binary files a/tests/snapshots/nanosp/test_menu_settings/00012.png and b/tests/snapshots/nanosp/test_menu_settings/00012.png differ diff --git a/tests/snapshots/nanox/test_menu_settings/00006.png b/tests/snapshots/nanox/test_menu_settings/00006.png index 9fb6bea..99fc174 100644 Binary files a/tests/snapshots/nanox/test_menu_settings/00006.png and b/tests/snapshots/nanox/test_menu_settings/00006.png differ diff --git a/tests/snapshots/nanox/test_menu_settings/00007.png b/tests/snapshots/nanox/test_menu_settings/00007.png index c4df69f..3ad71f8 100644 Binary files a/tests/snapshots/nanox/test_menu_settings/00007.png and b/tests/snapshots/nanox/test_menu_settings/00007.png differ diff --git a/tests/snapshots/nanox/test_menu_settings/00008.png b/tests/snapshots/nanox/test_menu_settings/00008.png index 3d0298a..e678a83 100644 Binary files a/tests/snapshots/nanox/test_menu_settings/00008.png and b/tests/snapshots/nanox/test_menu_settings/00008.png differ diff --git a/tests/snapshots/nanox/test_menu_settings/00009.png b/tests/snapshots/nanox/test_menu_settings/00009.png index 3feeb0a..03a2ed8 100644 Binary files a/tests/snapshots/nanox/test_menu_settings/00009.png and b/tests/snapshots/nanox/test_menu_settings/00009.png differ diff --git a/tests/snapshots/nanox/test_menu_settings/00010.png b/tests/snapshots/nanox/test_menu_settings/00010.png index 2aa394d..ae682df 100644 Binary files a/tests/snapshots/nanox/test_menu_settings/00010.png and b/tests/snapshots/nanox/test_menu_settings/00010.png differ diff --git a/tests/snapshots/nanox/test_menu_settings/00012.png b/tests/snapshots/nanox/test_menu_settings/00012.png index 2aa394d..ae682df 100644 Binary files a/tests/snapshots/nanox/test_menu_settings/00012.png and b/tests/snapshots/nanox/test_menu_settings/00012.png differ diff --git a/tests/snapshots/stax/test_menu_settings/00002.png b/tests/snapshots/stax/test_menu_settings/00002.png index a74d714..ac4f499 100644 Binary files a/tests/snapshots/stax/test_menu_settings/00002.png and b/tests/snapshots/stax/test_menu_settings/00002.png differ diff --git a/tests/snapshots/stax/test_menu_settings/00003.png b/tests/snapshots/stax/test_menu_settings/00003.png index f27f093..083b413 100644 Binary files a/tests/snapshots/stax/test_menu_settings/00003.png and b/tests/snapshots/stax/test_menu_settings/00003.png differ