mirror of
https://github.com/LedgerHQ/openpgp-card-app
synced 2024-11-09 07:10:30 +00:00
Fixed use of deprecated os_ prefixed functions
This commit is contained in:
parent
19153d0c2c
commit
3c54f1d289
@ -37,7 +37,7 @@ int gpg_apdu_get_challenge() {
|
||||
unsigned char chain[32];
|
||||
unsigned char Sr[32];
|
||||
|
||||
os_memset(chain, 0, 32);
|
||||
memset(chain, 0, 32);
|
||||
path[0] = 0x80475047;
|
||||
path[1] = 0x0F0F0F0F;
|
||||
os_perso_derive_node_bip32(CX_CURVE_SECP256K1, path, 2, Sr, chain);
|
||||
|
@ -103,7 +103,7 @@ int gpg_apdu_get_data(unsigned int ref) {
|
||||
/* ----------------- aid, histo, ext_length, ... ----------------- */
|
||||
case 0x6E:
|
||||
gpg_io_insert_tlv(0x4F, 16, N_gpg_pstate->AID);
|
||||
os_memmove(G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset - 6, G_gpg_vstate.kslot->serial, 4);
|
||||
memmove(G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset - 6, G_gpg_vstate.kslot->serial, 4);
|
||||
gpg_io_insert_tlv(0x5F52, 15, N_gpg_pstate->histo);
|
||||
gpg_io_insert_tlv(0x7F66, sizeof(C_ext_length), C_ext_length);
|
||||
|
||||
@ -414,10 +414,10 @@ int gpg_apdu_put_data(unsigned int ref) {
|
||||
}
|
||||
p = G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset;
|
||||
q = p + len_p;
|
||||
os_memmove(pq + ksz - len_p, p, len_p);
|
||||
os_memset(pq, 0, ksz - len_p);
|
||||
os_memmove(pq + 2 * ksz - len_q, q, len_q);
|
||||
os_memset(pq + ksz, 0, ksz - len_q);
|
||||
memmove(pq + ksz - len_p, p, len_p);
|
||||
memset(pq, 0, ksz - len_p);
|
||||
memmove(pq + 2 * ksz - len_q, q, len_q);
|
||||
memset(pq + ksz, 0, ksz - len_q);
|
||||
|
||||
// regenerate RSA private key
|
||||
unsigned char _e[4];
|
||||
@ -450,7 +450,7 @@ int gpg_apdu_put_data(unsigned int ref) {
|
||||
if (ksz == len_p) {
|
||||
G_gpg_vstate.work.ecfp.private.curve = curve;
|
||||
G_gpg_vstate.work.ecfp.private.d_len = ksz;
|
||||
os_memmove(G_gpg_vstate.work.ecfp.private.d, G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, ksz);
|
||||
memmove(G_gpg_vstate.work.ecfp.private.d, G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, ksz);
|
||||
cx_ecfp_generate_pair(curve, &G_gpg_vstate.work.ecfp.public, &G_gpg_vstate.work.ecfp.private, 1);
|
||||
nvm_write(&keygpg->pub_key.ecfp, &G_gpg_vstate.work.ecfp.public, sizeof(cx_ecfp_public_key_t));
|
||||
nvm_write(&keygpg->priv_key.ecfp, &G_gpg_vstate.work.ecfp.private, sizeof(cx_ecfp_private_key_t));
|
||||
|
@ -26,7 +26,7 @@ void gpg_pso_derive_slot_seed(int slot, unsigned char *seed) {
|
||||
unsigned int path[2];
|
||||
unsigned char chain[32];
|
||||
|
||||
os_memset(chain, 0, 32);
|
||||
memset(chain, 0, 32);
|
||||
path[0] = 0x80475047;
|
||||
path[1] = slot + 1;
|
||||
os_perso_derive_node_bip32(CX_CURVE_SECP256K1, path, 2, seed, chain);
|
||||
@ -257,7 +257,7 @@ int gpg_apdu_gen() {
|
||||
gpg_io_mark();
|
||||
curve = gpg_oid2curve(keygpg->attributes.value + 1, keygpg->attributes.length - 1);
|
||||
if (curve == CX_CURVE_Ed25519) {
|
||||
os_memmove(G_gpg_vstate.work.io_buffer + 128, keygpg->pub_key.ecfp256.W, keygpg->pub_key.ecfp256.W_len);
|
||||
memmove(G_gpg_vstate.work.io_buffer + 128, keygpg->pub_key.ecfp256.W, keygpg->pub_key.ecfp256.W_len);
|
||||
cx_edward_compress_point(CX_CURVE_Ed25519, G_gpg_vstate.work.io_buffer + 128, 65);
|
||||
gpg_io_insert_tlv(0x86, 32, G_gpg_vstate.work.io_buffer + 129); // 129: discard 02
|
||||
} else if (curve == CX_CURVE_Curve25519) {
|
||||
|
@ -78,46 +78,46 @@ const unsigned char C_OID_cv25519[10] = {
|
||||
};
|
||||
|
||||
unsigned int gpg_oid2curve(unsigned char *oid, unsigned int len) {
|
||||
if ((len == sizeof(C_OID_SECP256R1)) && (os_memcmp(oid, C_OID_SECP256R1, len) == 0)) {
|
||||
if ((len == sizeof(C_OID_SECP256R1)) && (memcmp(oid, C_OID_SECP256R1, len) == 0)) {
|
||||
return CX_CURVE_SECP256R1;
|
||||
}
|
||||
/*
|
||||
if ( (len == sizeof(C_OID_SECP256K1)) && (os_memcmp(oid, C_OID_SECP256K1, len)==0) ) {
|
||||
if ( (len == sizeof(C_OID_SECP256K1)) && (memcmp(oid, C_OID_SECP256K1, len)==0) ) {
|
||||
return CX_CURVE_SECP256K1;
|
||||
}
|
||||
|
||||
if ( (len == sizeof(C_OID_SECP384R1)) && (os_memcmp(oid, C_OID_SECP384R1, len)==0) ) {
|
||||
if ( (len == sizeof(C_OID_SECP384R1)) && (memcmp(oid, C_OID_SECP384R1, len)==0) ) {
|
||||
return CX_CURVE_SECP384R1;
|
||||
}
|
||||
if ( (len == sizeof(C_OID_SECP521R1)) && (os_memcmp(oid, C_OID_SECP521R1, len)==0) ) {
|
||||
if ( (len == sizeof(C_OID_SECP521R1)) && (memcmp(oid, C_OID_SECP521R1, len)==0) ) {
|
||||
return CX_CURVE_SECP521R1;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if ( (len == sizeof(C_OID_BRAINPOOL256R1)) && (os_memcmp(oid, C_OID_BRAINPOOL256R1, len)==0) ) {
|
||||
if ( (len == sizeof(C_OID_BRAINPOOL256R1)) && (memcmp(oid, C_OID_BRAINPOOL256R1, len)==0) ) {
|
||||
return CX_CURVE_BrainPoolP256R1;
|
||||
}
|
||||
if ( (len == sizeof(C_OID_BRAINPOOL384R1)) && (os_memcmp(oid, C_OID_BRAINPOOL384R1, len)==0) ) {
|
||||
if ( (len == sizeof(C_OID_BRAINPOOL384R1)) && (memcmp(oid, C_OID_BRAINPOOL384R1, len)==0) ) {
|
||||
return CX_CURVE_BrainPoolP384R1;
|
||||
}
|
||||
if ( (len == sizeof(C_OID_BRAINPOOL512R1)) && (os_memcmp(oid, C_OID_BRAINPOOL512R1, len)==0) ) {
|
||||
if ( (len == sizeof(C_OID_BRAINPOOL512R1)) && (memcmp(oid, C_OID_BRAINPOOL512R1, len)==0) ) {
|
||||
return CX_CURVE_BrainPoolP512R1;
|
||||
}
|
||||
*/
|
||||
if ((len == sizeof(C_OID_Ed25519)) && (os_memcmp(oid, C_OID_Ed25519, len) == 0)) {
|
||||
if ((len == sizeof(C_OID_Ed25519)) && (memcmp(oid, C_OID_Ed25519, len) == 0)) {
|
||||
return CX_CURVE_Ed25519;
|
||||
}
|
||||
|
||||
if ((len == sizeof(C_OID_cv25519)) && (os_memcmp(oid, C_OID_cv25519, len) == 0)) {
|
||||
if ((len == sizeof(C_OID_cv25519)) && (memcmp(oid, C_OID_cv25519, len) == 0)) {
|
||||
return CX_CURVE_Curve25519;
|
||||
}
|
||||
|
||||
/*
|
||||
if ( (len == sizeof(C_OID_SECP256K1)) && (os_memcmp(oid, C_OID_SECP256K1, len)==0) ) {
|
||||
if ( (len == sizeof(C_OID_SECP256K1)) && (memcmp(oid, C_OID_SECP256K1, len)==0) ) {
|
||||
return CX_CURVE_256K1;
|
||||
}
|
||||
if ( (len == sizeof(C_OID_BRAINPOOL256T1)) && (os_memcmp(oid, C_OID_BRAINPOOL256T1, len)==0) ) {
|
||||
if ( (len == sizeof(C_OID_BRAINPOOL256T1)) && (memcmp(oid, C_OID_BRAINPOOL256T1, len)==0) ) {
|
||||
return CX_CURVE_BrainPoolP256T1;
|
||||
}
|
||||
*/
|
||||
@ -297,12 +297,12 @@ const unsigned char C_sha256_PW2[] = {
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
void gpg_init() {
|
||||
os_memset(&G_gpg_vstate, 0, sizeof(gpg_v_state_t));
|
||||
memset(&G_gpg_vstate, 0, sizeof(gpg_v_state_t));
|
||||
// first init ?
|
||||
if (os_memcmp((void *)(N_gpg_pstate->magic), (void *)C_MAGIC, sizeof(C_MAGIC)) != 0) {
|
||||
if (memcmp((void *)(N_gpg_pstate->magic), (void *)C_MAGIC, sizeof(C_MAGIC)) != 0) {
|
||||
gpg_install(STATE_ACTIVATE);
|
||||
gpg_nvm_write((void *)(N_gpg_pstate->magic), (void *)C_MAGIC, sizeof(C_MAGIC));
|
||||
os_memset(&G_gpg_vstate, 0, sizeof(gpg_v_state_t));
|
||||
memset(&G_gpg_vstate, 0, sizeof(gpg_v_state_t));
|
||||
}
|
||||
|
||||
// key conf
|
||||
@ -356,12 +356,12 @@ void gpg_install(unsigned char app_state) {
|
||||
gpg_nvm_write((void *)(N_gpg_pstate), NULL, sizeof(gpg_nv_state_t));
|
||||
|
||||
// historical bytes
|
||||
os_memmove(G_gpg_vstate.work.io_buffer, C_default_Histo, sizeof(C_default_Histo));
|
||||
memmove(G_gpg_vstate.work.io_buffer, C_default_Histo, sizeof(C_default_Histo));
|
||||
G_gpg_vstate.work.io_buffer[7] = app_state;
|
||||
gpg_nvm_write((void *)(N_gpg_pstate->histo), G_gpg_vstate.work.io_buffer, sizeof(C_default_Histo));
|
||||
|
||||
// AID
|
||||
os_memmove(G_gpg_vstate.work.io_buffer, C_default_AID, sizeof(C_default_AID));
|
||||
memmove(G_gpg_vstate.work.io_buffer, C_default_AID, sizeof(C_default_AID));
|
||||
gpg_nvm_write((void *)(N_gpg_pstate->AID), &G_gpg_vstate.work.io_buffer, sizeof(C_default_AID));
|
||||
|
||||
|
||||
@ -371,14 +371,14 @@ void gpg_install(unsigned char app_state) {
|
||||
gpg_nvm_write((void *)(&N_gpg_pstate->sex), G_gpg_vstate.work.io_buffer, 1);
|
||||
|
||||
// default PW1/PW2: 1 2 3 4 5 6
|
||||
os_memmove(pin.value, C_sha256_PW1, sizeof(C_sha256_PW1));
|
||||
memmove(pin.value, C_sha256_PW1, sizeof(C_sha256_PW1));
|
||||
pin.length = 6;
|
||||
pin.counter = 3;
|
||||
pin.ref = PIN_ID_PW1;
|
||||
gpg_nvm_write((void *)(&N_gpg_pstate->PW1), &pin, sizeof(gpg_pin_t));
|
||||
|
||||
// default PW3: 1 2 3 4 5 6 7 8
|
||||
os_memmove(pin.value, C_sha256_PW2, sizeof(C_sha256_PW2));
|
||||
memmove(pin.value, C_sha256_PW2, sizeof(C_sha256_PW2));
|
||||
pin.length = 8;
|
||||
pin.counter = 3;
|
||||
pin.ref = PIN_ID_PW3;
|
||||
|
16
src/gpg_io.c
16
src/gpg_io.c
@ -61,7 +61,7 @@ void gpg_io_discard(int clear) {
|
||||
}
|
||||
|
||||
void gpg_io_clear() {
|
||||
os_memset(G_gpg_vstate.work.io_buffer, 0, GPG_IO_BUFFER_LENGTH);
|
||||
memset(G_gpg_vstate.work.io_buffer, 0, GPG_IO_BUFFER_LENGTH);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
@ -73,14 +73,14 @@ void gpg_io_hole(unsigned int sz) {
|
||||
THROW(ERROR_IO_FULL);
|
||||
return;
|
||||
}
|
||||
os_memmove(G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset + sz,
|
||||
memmove(G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset + sz,
|
||||
G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, G_gpg_vstate.io_length - G_gpg_vstate.io_offset);
|
||||
G_gpg_vstate.io_length += sz;
|
||||
}
|
||||
|
||||
void gpg_io_insert(unsigned char const *buff, unsigned int len) {
|
||||
gpg_io_hole(len);
|
||||
os_memmove(G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, buff, len);
|
||||
memmove(G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, buff, len);
|
||||
G_gpg_vstate.io_offset += len;
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ int gpg_io_fetch_nv(unsigned char *buffer, int len) {
|
||||
}
|
||||
int gpg_io_fetch(unsigned char *buffer, int len) {
|
||||
if (buffer) {
|
||||
os_memmove(buffer, G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, len);
|
||||
memmove(buffer, G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, len);
|
||||
}
|
||||
G_gpg_vstate.io_offset += len;
|
||||
return len;
|
||||
@ -250,7 +250,7 @@ int gpg_io_do(unsigned int io_flags) {
|
||||
unsigned int tx, xx;
|
||||
// send chunk
|
||||
tx = MAX_OUT - 2;
|
||||
os_memmove(G_io_apdu_buffer, G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, tx);
|
||||
memmove(G_io_apdu_buffer, G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, tx);
|
||||
G_gpg_vstate.io_length -= tx;
|
||||
G_gpg_vstate.io_offset += tx;
|
||||
G_io_apdu_buffer[tx] = 0x61;
|
||||
@ -268,7 +268,7 @@ int gpg_io_do(unsigned int io_flags) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
os_memmove(G_io_apdu_buffer, G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, G_gpg_vstate.io_length);
|
||||
memmove(G_io_apdu_buffer, G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_offset, G_gpg_vstate.io_length);
|
||||
|
||||
if (io_flags & IO_RETURN_AFTER_TX) {
|
||||
rx = gpg_io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, G_gpg_vstate.io_length);
|
||||
@ -320,7 +320,7 @@ int gpg_io_do(unsigned int io_flags) {
|
||||
default:
|
||||
_default:
|
||||
G_gpg_vstate.io_lc = G_io_apdu_buffer[4];
|
||||
os_memmove(G_gpg_vstate.work.io_buffer, G_io_apdu_buffer + 5, G_gpg_vstate.io_lc);
|
||||
memmove(G_gpg_vstate.work.io_buffer, G_io_apdu_buffer + 5, G_gpg_vstate.io_lc);
|
||||
G_gpg_vstate.io_length = G_gpg_vstate.io_lc;
|
||||
break;
|
||||
}
|
||||
@ -345,7 +345,7 @@ int gpg_io_do(unsigned int io_flags) {
|
||||
if ((G_gpg_vstate.io_length + G_gpg_vstate.io_lc) > GPG_IO_BUFFER_LENGTH) {
|
||||
return 1;
|
||||
}
|
||||
os_memmove(G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_length, G_io_apdu_buffer + 5, G_gpg_vstate.io_lc);
|
||||
memmove(G_gpg_vstate.work.io_buffer + G_gpg_vstate.io_length, G_io_apdu_buffer + 5, G_gpg_vstate.io_lc);
|
||||
G_gpg_vstate.io_length += G_gpg_vstate.io_lc;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ static int gpg_pin_check_internal(gpg_pin_t *pin, unsigned char *pin_val, int pi
|
||||
cx_sha256_init(&G_gpg_vstate.work.md.sha256);
|
||||
cx_hash((cx_hash_t *)&G_gpg_vstate.work.md.sha256, CX_LAST, pin_val, pin_len, G_gpg_vstate.work.md.H,
|
||||
sizeof(G_gpg_vstate.work.md.H));
|
||||
if (os_memcmp(G_gpg_vstate.work.md.H, pin->value, 32)) {
|
||||
if (memcmp(G_gpg_vstate.work.md.H, pin->value, 32)) {
|
||||
return SW_SECURITY_STATUS_NOT_SATISFIED;
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,8 @@ static int gpg_sign(gpg_key_t *sigkey) {
|
||||
THROW(SW_WRONG_LENGTH);
|
||||
}
|
||||
l = ksz - G_gpg_vstate.io_length;
|
||||
os_memmove(G_gpg_vstate.work.io_buffer + l, G_gpg_vstate.work.io_buffer, G_gpg_vstate.io_length);
|
||||
os_memset(G_gpg_vstate.work.io_buffer, 0xFF, l);
|
||||
memmove(G_gpg_vstate.work.io_buffer + l, G_gpg_vstate.work.io_buffer, G_gpg_vstate.io_length);
|
||||
memset(G_gpg_vstate.work.io_buffer, 0xFF, l);
|
||||
G_gpg_vstate.work.io_buffer[0] = 0;
|
||||
G_gpg_vstate.work.io_buffer[1] = 1;
|
||||
G_gpg_vstate.work.io_buffer[l - 1] = 0;
|
||||
|
@ -24,13 +24,13 @@ int gpg_apdu_select() {
|
||||
int sw;
|
||||
|
||||
// MF
|
||||
if ((G_gpg_vstate.io_length == 2) && (os_memcmp(G_gpg_vstate.work.io_buffer, C_MF, G_gpg_vstate.io_length) == 0)) {
|
||||
if ((G_gpg_vstate.io_length == 2) && (memcmp(G_gpg_vstate.work.io_buffer, C_MF, G_gpg_vstate.io_length) == 0)) {
|
||||
gpg_io_discard(0);
|
||||
sw = SW_OK;
|
||||
}
|
||||
// AID APP
|
||||
else if ((G_gpg_vstate.io_length == 6) &&
|
||||
(os_memcmp(G_gpg_vstate.work.io_buffer, N_gpg_pstate->AID, G_gpg_vstate.io_length) == 0)) {
|
||||
(memcmp(G_gpg_vstate.work.io_buffer, N_gpg_pstate->AID, G_gpg_vstate.io_length) == 0)) {
|
||||
G_gpg_vstate.DO_current = 0;
|
||||
G_gpg_vstate.DO_reccord = 0;
|
||||
G_gpg_vstate.DO_offset = 0;
|
||||
|
@ -80,13 +80,13 @@ void ui_CCID_reset(void) {
|
||||
}
|
||||
|
||||
void ui_info(const char *msg1, const char *msg2, const void *menu_display, unsigned int value) {
|
||||
os_memset(&G_gpg_vstate.ui_dogsays[0], 0, sizeof(ux_menu_entry_t));
|
||||
memset(&G_gpg_vstate.ui_dogsays[0], 0, sizeof(ux_menu_entry_t));
|
||||
G_gpg_vstate.ui_dogsays[0].callback = menu_display;
|
||||
G_gpg_vstate.ui_dogsays[0].userid = value;
|
||||
G_gpg_vstate.ui_dogsays[0].line1 = msg1;
|
||||
G_gpg_vstate.ui_dogsays[0].line2 = msg2;
|
||||
|
||||
os_memset(&G_gpg_vstate.ui_dogsays[1], 0, sizeof(ux_menu_entry_t));
|
||||
memset(&G_gpg_vstate.ui_dogsays[1], 0, sizeof(ux_menu_entry_t));
|
||||
UX_MENU_DISPLAY(0, G_gpg_vstate.ui_dogsays, NULL);
|
||||
};
|
||||
|
||||
@ -283,7 +283,7 @@ static const char C_pin_digit[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
|
||||
|
||||
void ui_menu_pinentry_display(unsigned int value) {
|
||||
if (value == 0) {
|
||||
os_memset(G_gpg_vstate.ux_pinentry, 0, sizeof(G_gpg_vstate.ux_pinentry));
|
||||
memset(G_gpg_vstate.ux_pinentry, 0, sizeof(G_gpg_vstate.ux_pinentry));
|
||||
G_gpg_vstate.ux_pinentry[0] = 1;
|
||||
G_gpg_vstate.ux_pinentry[1] = 5;
|
||||
}
|
||||
@ -442,7 +442,7 @@ static unsigned int validate_pin() {
|
||||
offset = 1 + G_gpg_vstate.work.io_buffer[0];
|
||||
len = G_gpg_vstate.work.io_buffer[offset];
|
||||
if ((len != G_gpg_vstate.work.io_buffer[offset + 1 + len]) ||
|
||||
(os_memcmp(G_gpg_vstate.work.io_buffer + offset + 1, G_gpg_vstate.work.io_buffer + offset + 1 + len + 1,
|
||||
(memcmp(G_gpg_vstate.work.io_buffer + offset + 1, G_gpg_vstate.work.io_buffer + offset + 1 + len + 1,
|
||||
len) != 0)) {
|
||||
gpg_io_discard(1);
|
||||
gpg_io_insert_u16(SW_CONDITIONS_NOT_SATISFIED);
|
||||
@ -569,7 +569,7 @@ void ui_menu_tmpl_set_action(unsigned int value) {
|
||||
unsigned int oid_len;
|
||||
err = NULL;
|
||||
|
||||
os_memset(&attributes, 0, sizeof(attributes));
|
||||
memset(&attributes, 0, sizeof(attributes));
|
||||
switch (G_gpg_vstate.ux_type) {
|
||||
case 2048:
|
||||
case 3072:
|
||||
@ -596,18 +596,18 @@ void ui_menu_tmpl_set_action(unsigned int value) {
|
||||
attributes.value[0] = 19; // ecdsa
|
||||
}
|
||||
oid = gpg_curve2oid(G_gpg_vstate.ux_type, &oid_len);
|
||||
os_memmove(attributes.value + 1, oid, sizeof(oid_len));
|
||||
memmove(attributes.value + 1, oid, sizeof(oid_len));
|
||||
attributes.length = 1 + oid_len;
|
||||
break;
|
||||
|
||||
case CX_CURVE_Ed25519:
|
||||
if (G_gpg_vstate.ux_key == 2) {
|
||||
attributes.value[0] = 18; // ecdh
|
||||
os_memmove(attributes.value + 1, C_OID_cv25519, sizeof(C_OID_cv25519));
|
||||
memmove(attributes.value + 1, C_OID_cv25519, sizeof(C_OID_cv25519));
|
||||
attributes.length = 1 + sizeof(C_OID_cv25519);
|
||||
} else {
|
||||
attributes.value[0] = 22; // eddsa
|
||||
os_memmove(attributes.value + 1, C_OID_Ed25519, sizeof(C_OID_Ed25519));
|
||||
memmove(attributes.value + 1, C_OID_Ed25519, sizeof(C_OID_Ed25519));
|
||||
attributes.length = 1 + sizeof(C_OID_Ed25519);
|
||||
}
|
||||
break;
|
||||
@ -983,10 +983,10 @@ extern const uint8_t N_USBD_CfgDesc[];
|
||||
const bagl_element_t *ui_menu_main_preprocessor(const ux_menu_entry_t *entry, bagl_element_t *element) {
|
||||
if (entry == &ui_menu_main[0]) {
|
||||
if (element->component.userid == 0x21) {
|
||||
os_memset(G_gpg_vstate.menu, 0, sizeof(G_gpg_vstate.menu));
|
||||
os_memmove(G_gpg_vstate.menu, N_gpg_pstate->name.value, 12);
|
||||
memset(G_gpg_vstate.menu, 0, sizeof(G_gpg_vstate.menu));
|
||||
memmove(G_gpg_vstate.menu, N_gpg_pstate->name.value, 12);
|
||||
if (G_gpg_vstate.menu[0] == 0) {
|
||||
os_memmove(G_gpg_vstate.menu, "<No Name>", 9);
|
||||
memmove(G_gpg_vstate.menu, "<No Name>", 9);
|
||||
} else {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if (G_gpg_vstate.menu[i] == 0x3c) {
|
||||
@ -999,7 +999,7 @@ const bagl_element_t *ui_menu_main_preprocessor(const ux_menu_entry_t *entry, ba
|
||||
unsigned int serial;
|
||||
serial = (G_gpg_vstate.kslot->serial[0] << 24) | (G_gpg_vstate.kslot->serial[1] << 16) |
|
||||
(G_gpg_vstate.kslot->serial[2] << 8) | (G_gpg_vstate.kslot->serial[3]);
|
||||
os_memset(G_gpg_vstate.menu, 0, sizeof(G_gpg_vstate.menu));
|
||||
memset(G_gpg_vstate.menu, 0, sizeof(G_gpg_vstate.menu));
|
||||
#if GPG_MULTISLOT
|
||||
snprintf(G_gpg_vstate.menu, sizeof(G_gpg_vstate.menu), "ID: %x / %d", serial, G_gpg_vstate.slot + 1);
|
||||
#else
|
||||
|
@ -278,7 +278,7 @@ static const char C_pin_digit[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
|
||||
|
||||
void ui_menu_pinentry_display(unsigned int value) {
|
||||
if (value == 0) {
|
||||
os_memset(G_gpg_vstate.ux_pinentry, 0, sizeof(G_gpg_vstate.ux_pinentry));
|
||||
memset(G_gpg_vstate.ux_pinentry, 0, sizeof(G_gpg_vstate.ux_pinentry));
|
||||
G_gpg_vstate.ux_pinentry[0] = 1;
|
||||
G_gpg_vstate.ux_pinentry[1] = 5;
|
||||
}
|
||||
@ -437,7 +437,7 @@ static unsigned int validate_pin() {
|
||||
offset = 1 + G_gpg_vstate.work.io_buffer[0];
|
||||
len = G_gpg_vstate.work.io_buffer[offset];
|
||||
if ((len != G_gpg_vstate.work.io_buffer[offset + 1 + len]) ||
|
||||
(os_memcmp(G_gpg_vstate.work.io_buffer + offset + 1, G_gpg_vstate.work.io_buffer + offset + 1 + len + 1,
|
||||
(memcmp(G_gpg_vstate.work.io_buffer + offset + 1, G_gpg_vstate.work.io_buffer + offset + 1 + len + 1,
|
||||
len) != 0)) {
|
||||
gpg_io_discard(1);
|
||||
gpg_io_insert_u16(SW_CONDITIONS_NOT_SATISFIED);
|
||||
@ -603,7 +603,7 @@ void ui_menu_tmpl_set_action(unsigned int value) {
|
||||
unsigned int oid_len;
|
||||
err = NULL;
|
||||
|
||||
os_memset(&attributes, 0, sizeof(attributes));
|
||||
memset(&attributes, 0, sizeof(attributes));
|
||||
switch (G_gpg_vstate.ux_type) {
|
||||
case 2048:
|
||||
case 3072:
|
||||
@ -624,18 +624,18 @@ void ui_menu_tmpl_set_action(unsigned int value) {
|
||||
attributes.value[0] = 19; // ecdsa
|
||||
}
|
||||
oid = gpg_curve2oid(G_gpg_vstate.ux_type, &oid_len);
|
||||
os_memmove(attributes.value + 1, oid, sizeof(oid_len));
|
||||
memmove(attributes.value + 1, oid, sizeof(oid_len));
|
||||
attributes.length = 1 + oid_len;
|
||||
break;
|
||||
|
||||
case CX_CURVE_Ed25519:
|
||||
if (G_gpg_vstate.ux_key == 2) {
|
||||
attributes.value[0] = 18; // ecdh
|
||||
os_memmove(attributes.value + 1, C_OID_cv25519, sizeof(C_OID_cv25519));
|
||||
memmove(attributes.value + 1, C_OID_cv25519, sizeof(C_OID_cv25519));
|
||||
attributes.length = 1 + sizeof(C_OID_cv25519);
|
||||
} else {
|
||||
attributes.value[0] = 22; // eddsa
|
||||
os_memmove(attributes.value + 1, C_OID_Ed25519, sizeof(C_OID_Ed25519));
|
||||
memmove(attributes.value + 1, C_OID_Ed25519, sizeof(C_OID_Ed25519));
|
||||
attributes.length = 1 + sizeof(C_OID_Ed25519);
|
||||
}
|
||||
break;
|
||||
@ -1172,10 +1172,10 @@ UX_FLOW(ux_flow_main,
|
||||
&ux_menu_main_5_step);
|
||||
|
||||
void ui_menu_main_predisplay() {
|
||||
os_memset(G_gpg_vstate.ux_buff1, 0, sizeof(G_gpg_vstate.ux_buff1));
|
||||
os_memmove(G_gpg_vstate.ux_buff1, (void *)(N_gpg_pstate->name.value), 20);
|
||||
memset(G_gpg_vstate.ux_buff1, 0, sizeof(G_gpg_vstate.ux_buff1));
|
||||
memmove(G_gpg_vstate.ux_buff1, (void *)(N_gpg_pstate->name.value), 20);
|
||||
if (G_gpg_vstate.ux_buff1[0] == 0) {
|
||||
os_memmove(G_gpg_vstate.ux_buff1, "<No Name>", 9);
|
||||
memmove(G_gpg_vstate.ux_buff1, "<No Name>", 9);
|
||||
} else {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if (G_gpg_vstate.ux_buff1[i] == 0x3c) {
|
||||
@ -1187,7 +1187,7 @@ void ui_menu_main_predisplay() {
|
||||
unsigned int serial;
|
||||
serial = (G_gpg_vstate.kslot->serial[0] << 24) | (G_gpg_vstate.kslot->serial[1] << 16) |
|
||||
(G_gpg_vstate.kslot->serial[2] << 8) | (G_gpg_vstate.kslot->serial[3]);
|
||||
os_memset(G_gpg_vstate.ux_buff2, 0, sizeof(G_gpg_vstate.ux_buff2));
|
||||
memset(G_gpg_vstate.ux_buff2, 0, sizeof(G_gpg_vstate.ux_buff2));
|
||||
#if GPG_MULTISLOT
|
||||
snprintf(G_gpg_vstate.ux_buff2, sizeof(G_gpg_vstate.ux_buff2), "ID: %x / %d", serial, G_gpg_vstate.slot + 1);
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user