From b602436a6e776ed9e2e868c351150bf693233669 Mon Sep 17 00:00:00 2001 From: "Aaron Tulino (Aaronjamt)" Date: Mon, 8 Dec 2025 04:14:44 -0700 Subject: [PATCH 1/2] [hf seos] Carry when incrementing --- client/src/cmdhfseos.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/cmdhfseos.c b/client/src/cmdhfseos.c index 259f22f415..4caa70879b 100644 --- a/client/src/cmdhfseos.c +++ b/client/src/cmdhfseos.c @@ -163,7 +163,10 @@ static int decrypt_cryptogram(uint8_t *key, uint8_t *input, uint8_t *out, int in } static void increment_command_wrapper(uint8_t *input, int input_len) { - input[input_len - 1]++; // Increment the last element of the header by 1 + // Increment the end of the header by 1 + uint32_t value = MemBeToUint4byte(&input[input_len - sizeof(uint32_t)]); + value++; + Uint4byteToMemBe(&input[input_len - sizeof(uint32_t)], value); } static void padToBlockSize(const uint8_t *input, int *inputSize, int blockSize, uint8_t *output) { From 8a929015c9110fc2aa4aaa6a70641e501c8426d0 Mon Sep 17 00:00:00 2001 From: Aaron Tulino Date: Thu, 11 Dec 2025 02:53:54 -0700 Subject: [PATCH 2/2] Make PR more readable --- client/src/cmdhfseos.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhfseos.c b/client/src/cmdhfseos.c index 4caa70879b..e9eeb94127 100644 --- a/client/src/cmdhfseos.c +++ b/client/src/cmdhfseos.c @@ -164,9 +164,10 @@ static int decrypt_cryptogram(uint8_t *key, uint8_t *input, uint8_t *out, int in static void increment_command_wrapper(uint8_t *input, int input_len) { // Increment the end of the header by 1 - uint32_t value = MemBeToUint4byte(&input[input_len - sizeof(uint32_t)]); + uint8_t* offset = &input[input_len - sizeof(uint32_t)]; + uint32_t value = MemBeToUint4byte(offset); value++; - Uint4byteToMemBe(&input[input_len - sizeof(uint32_t)], value); + Uint4byteToMemBe(offset, value); } static void padToBlockSize(const uint8_t *input, int *inputSize, int blockSize, uint8_t *output) {