mirror of
https://github.com/LedgerHQ/openpgp-card-app
synced 2024-11-09 07:10:30 +00:00
custo & formatting
This commit is contained in:
parent
1e23ef7b13
commit
f49c574428
@ -395,7 +395,6 @@ int gpg_apdu_put_data(unsigned int ref) {
|
||||
break;
|
||||
}
|
||||
|
||||
// --- RSA KEY ---
|
||||
if (keygpg->attributes.value[0] == KEY_ID_RSA) {
|
||||
unsigned int e = 0;
|
||||
unsigned char *p, *q, *pq;
|
||||
@ -476,14 +475,13 @@ int gpg_apdu_put_data(unsigned int ref) {
|
||||
}
|
||||
sw = SW_OK;
|
||||
}
|
||||
// --- ECC KEY ---
|
||||
else if ((keygpg->attributes.value[0] == KEY_ID_ECDH) ||
|
||||
(keygpg->attributes.value[0] == KEY_ID_ECDSA) ||
|
||||
(keygpg->attributes.value[0] == KEY_ID_EDDSA)) {
|
||||
unsigned int curve;
|
||||
|
||||
curve = gpg_oid2curve(&keygpg->attributes.value[1], keygpg->attributes.length - 1);
|
||||
if (curve == 0) {
|
||||
if (curve == CX_CURVE_NONE) {
|
||||
sw = SW_WRONG_DATA;
|
||||
break;
|
||||
}
|
||||
@ -801,8 +799,8 @@ end:
|
||||
// cmd
|
||||
// resp TID API COMPAT len_pub len_priv priv
|
||||
int gpg_apdu_get_key_data(unsigned int ref) {
|
||||
cx_aes_key_t keyenc;
|
||||
gpg_key_t *keygpg;
|
||||
cx_aes_key_t keyenc = {0};
|
||||
gpg_key_t *keygpg = NULL;
|
||||
unsigned int len = 0;
|
||||
cx_err_t error = CX_INTERNAL_ERROR;
|
||||
int sw = SW_UNKNOWN;
|
||||
@ -832,7 +830,7 @@ int gpg_apdu_get_key_data(unsigned int ref) {
|
||||
|
||||
// encrypted part
|
||||
switch (keygpg->attributes.value[0]) {
|
||||
case KEY_ID_RSA: // RSA
|
||||
case KEY_ID_RSA:
|
||||
// insert pubkey
|
||||
gpg_io_insert_u32(4);
|
||||
gpg_io_insert(keygpg->pub_key.rsa, 4);
|
||||
@ -853,7 +851,7 @@ int gpg_apdu_get_key_data(unsigned int ref) {
|
||||
sw = SW_OK;
|
||||
break;
|
||||
|
||||
case KEY_ID_ECDH: // ECC
|
||||
case KEY_ID_ECDH:
|
||||
case KEY_ID_ECDSA:
|
||||
case KEY_ID_EDDSA:
|
||||
// insert pubkey
|
||||
@ -889,10 +887,9 @@ end:
|
||||
// cmd TID API COMPAT len_pub len_priv priv
|
||||
// resp -
|
||||
int gpg_apdu_put_key_data(unsigned int ref) {
|
||||
cx_aes_key_t keyenc;
|
||||
gpg_key_t *keygpg;
|
||||
unsigned int len;
|
||||
unsigned int offset;
|
||||
cx_aes_key_t keyenc = {0};
|
||||
gpg_key_t *keygpg = NULL;
|
||||
unsigned int len = 0;
|
||||
cx_err_t error = CX_INTERNAL_ERROR;
|
||||
int sw = SW_UNKNOWN;
|
||||
|
||||
@ -920,7 +917,6 @@ int gpg_apdu_put_key_data(unsigned int ref) {
|
||||
gpg_io_fetch_u32();
|
||||
|
||||
switch (keygpg->attributes.value[0]) {
|
||||
// RSA
|
||||
case KEY_ID_RSA:
|
||||
// insert pubkey
|
||||
len = gpg_io_fetch_u32();
|
||||
@ -955,8 +951,7 @@ int gpg_apdu_put_key_data(unsigned int ref) {
|
||||
sw = SW_OK;
|
||||
break;
|
||||
|
||||
// ECC
|
||||
case KEY_ID_ECDH: // ECC
|
||||
case KEY_ID_ECDH:
|
||||
case KEY_ID_ECDSA:
|
||||
case KEY_ID_EDDSA:
|
||||
// insert pubkey
|
||||
|
@ -304,7 +304,6 @@ int gpg_apdu_gen() {
|
||||
case GEN_ASYM_KEY_SEED:
|
||||
|
||||
if (keygpg->attributes.value[0] == KEY_ID_RSA) {
|
||||
// RSA
|
||||
sw = gpg_gen_rsa_kyey(keygpg, name);
|
||||
if (sw != SW_OK) {
|
||||
break;
|
||||
@ -312,7 +311,6 @@ int gpg_apdu_gen() {
|
||||
} else if ((keygpg->attributes.value[0] == KEY_ID_ECDH) ||
|
||||
(keygpg->attributes.value[0] == KEY_ID_ECDSA) ||
|
||||
(keygpg->attributes.value[0] == KEY_ID_EDDSA)) {
|
||||
// ECC
|
||||
sw = gpg_gen_ecc_kyey(keygpg, name);
|
||||
if (sw != SW_OK) {
|
||||
break;
|
||||
@ -323,12 +321,10 @@ int gpg_apdu_gen() {
|
||||
// --- read pubkey ---
|
||||
case READ_ASYM_KEY:
|
||||
if (keygpg->attributes.value[0] == KEY_ID_RSA) {
|
||||
// read RSA
|
||||
sw = gpg_read_rsa_kyey(keygpg);
|
||||
} else if ((keygpg->attributes.value[0] == KEY_ID_ECDH) ||
|
||||
(keygpg->attributes.value[0] == KEY_ID_ECDSA) ||
|
||||
(keygpg->attributes.value[0] == KEY_ID_EDDSA)) {
|
||||
// read ECC
|
||||
sw = gpg_read_ecc_kyey(keygpg);
|
||||
}
|
||||
l = G_gpg_vstate.io_length;
|
||||
|
@ -56,7 +56,7 @@ const unsigned char C_OID_BRAINPOOL256T1[9] = {
|
||||
const unsigned char C_OID_BRAINPOOL256R1[9] = {
|
||||
0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x08
|
||||
};
|
||||
//brainpool 284r1: 1.3.36.3.3.2.8.1.1.11
|
||||
//brainpool 384r1: 1.3.36.3.3.2.8.1.1.11
|
||||
const unsigned char C_OID_BRAINPOOL384R1[9] = {
|
||||
0x2B, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0B
|
||||
};
|
||||
@ -66,7 +66,7 @@ const unsigned char C_OID_BRAINPOOL512R1[9] = {
|
||||
};
|
||||
*/
|
||||
|
||||
// Ed25519/curve25519: 1.3.6.1.4.1.11591.15.1
|
||||
// "twisted" curve25519 for Ed25519: 1.3.6.1.4.1.11591.15.1
|
||||
const unsigned char C_OID_Ed25519[9] = {
|
||||
0x2B,
|
||||
0x06,
|
||||
@ -79,7 +79,7 @@ const unsigned char C_OID_Ed25519[9] = {
|
||||
0x01,
|
||||
};
|
||||
|
||||
// Ed25519/curve25519: 1.3.6.1.4.1.11591.15.1
|
||||
// "Montgomery" curve25519 for X25519: 1.3.6.1.4.1.11591.1.5.1
|
||||
const unsigned char C_OID_cv25519[10] = {
|
||||
0x2B,
|
||||
0x06,
|
||||
|
@ -65,7 +65,6 @@ static void gpg_pso_reset_PW1() {
|
||||
}
|
||||
|
||||
static int gpg_sign(gpg_key_t *sigkey) {
|
||||
// --- RSA
|
||||
cx_err_t error = CX_INTERNAL_ERROR;
|
||||
if (sigkey->attributes.value[0] == KEY_ID_RSA) {
|
||||
cx_rsa_private_key_t *key = NULL;
|
||||
@ -113,7 +112,6 @@ static int gpg_sign(gpg_key_t *sigkey) {
|
||||
gpg_pso_reset_PW1();
|
||||
return SW_OK;
|
||||
}
|
||||
// --- ECDSA/EdDSA
|
||||
if ((sigkey->attributes.value[0] == KEY_ID_ECDSA) ||
|
||||
(sigkey->attributes.value[0] == KEY_ID_EDDSA)) {
|
||||
cx_ecfp_private_key_t *key;
|
||||
@ -223,7 +221,7 @@ int gpg_apdu_pso() {
|
||||
// --- PSO:ENC ---
|
||||
case PSO_ENC: {
|
||||
unsigned int msg_len;
|
||||
cx_aes_key_t *key;
|
||||
cx_aes_key_t *key = NULL;
|
||||
key = &G_gpg_vstate.kslot->AES_dec;
|
||||
if (!(key->size != 16)) {
|
||||
return SW_CONDITIONS_NOT_SATISFIED;
|
||||
@ -252,7 +250,7 @@ int gpg_apdu_pso() {
|
||||
switch (pad_byte) {
|
||||
// --- PSO:DEC:RSA
|
||||
case 0x00: {
|
||||
cx_rsa_private_key_t *key;
|
||||
cx_rsa_private_key_t *key = NULL;
|
||||
if (G_gpg_vstate.mse_dec->attributes.value[0] != KEY_ID_RSA) {
|
||||
return SW_CONDITIONS_NOT_SATISFIED;
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ void ui_menu_tmpl_set_action(unsigned int value) {
|
||||
UNUSED(value);
|
||||
LV(attributes, GPG_KEY_ATTRIBUTES_LENGTH);
|
||||
gpg_key_t *dest = NULL;
|
||||
const unsigned char *oid;
|
||||
const unsigned char *oid = NULL;
|
||||
unsigned int oid_len;
|
||||
|
||||
memset(&attributes, 0, sizeof(attributes));
|
||||
|
@ -237,7 +237,6 @@ static uint32_t _getKeyType(const uint8_t key) {
|
||||
}
|
||||
switch (attributes[0]) {
|
||||
case KEY_ID_RSA:
|
||||
// RSA
|
||||
tag = U2BE(attributes, 1);
|
||||
switch (tag) {
|
||||
case 2048:
|
||||
|
Loading…
Reference in New Issue
Block a user