From d0a8456e58ffe1428178e1b1757d004cc58996f0 Mon Sep 17 00:00:00 2001 From: Lucas PASCAL Date: Wed, 21 Feb 2024 16:24:45 +0100 Subject: [PATCH] [fix][#38] Capital characters frequently and randomly lowered --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ src/password_typing.c | 16 +++++++++++----- 2 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9f957aa --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,35 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.1.3] - 2024-??-?? + +### Fix + +- Bug #38: some applications were randomly lowering capital characters, leading passwords containing + capital characters to be almost always wrong. + +## [1.1.2] - 2023-10-12 (Stax only) + +### Fix + +- Updated porting to Stax SDK evolutions + +## [1.1.1] - 2023-04-25 (Stax only) + +### Fix + +- Derivation path changed, from `44'/1` to `5265220'` + +## [1.1.0] - 2023-04-12 (Stax only) + +### Add + +- Stax porting + +## [1.0.2] - 2022-03-02 + +Original Passwords application diff --git a/src/password_typing.c b/src/password_typing.c index 13e4840..47c3c6c 100644 --- a/src/password_typing.c +++ b/src/password_typing.c @@ -59,7 +59,7 @@ bool type_password(uint8_t *data, uint32_t led_status; uint8_t tmp[64]; uint8_t i; - uint8_t report[REPORT_SIZE]; + uint8_t report[REPORT_SIZE] = {0}; cx_hash_sha256(data, dataSize, tmp, sizeof(tmp)); derive[0] = DERIVE_PASSWORD_PATH; @@ -86,11 +86,10 @@ bool type_password(uint8_t *data, generate_password(&ctx, setMask, minFromSet, tmp, size); - memset(report, 0, sizeof(report)); - // Insert EMPTY_REPORT CAPS_REPORT EMPTY_REPORT to avoid undesired capital letter on KONSOLE led_status = G_led_status; - usb_write_wait((uint8_t *) EMPTY_REPORT); + // Insert EMPTY_REPORT CAPS_REPORT EMPTY_REPORT to avoid undesired capital letter on KONSOLE + usb_write_wait((uint8_t *) EMPTY_REPORT); usb_write_wait((uint8_t *) CAPS_REPORT); usb_write_wait((uint8_t *) EMPTY_REPORT); @@ -99,11 +98,17 @@ bool type_password(uint8_t *data, usb_write_wait((uint8_t *) CAPS_LOCK_REPORT); usb_write_wait((uint8_t *) EMPTY_REPORT); } + for (i = 0; i < size; i++) { // If keyboard layout not initialized, use the default map_char(N_storage.keyboard_layout, tmp[i], report); + usb_write_wait(report); - usb_write_wait((uint8_t *) EMPTY_REPORT); + if (report[0] & SHIFT_KEY) { + usb_write_wait((uint8_t *) CAPS_REPORT); + } else { + usb_write_wait((uint8_t *) EMPTY_REPORT); + } // for international keyboard, make sure to insert space after special symbols if (N_storage.keyboard_layout == HID_MAPPING_QWERTY_INTL) { @@ -120,6 +125,7 @@ bool type_password(uint8_t *data, } } } + usb_write_wait((uint8_t *) EMPTY_REPORT); // restore shift state if (led_status & 2) { usb_write_wait((uint8_t *) CAPS_LOCK_REPORT);