Skip to content

Commit

Permalink
Fixed CodeQL warnings
Browse files Browse the repository at this point in the history
- Sign check of bitwise operation
- Comparison result is always the same
  • Loading branch information
aido committed Nov 16, 2023
1 parent cd52f51 commit 2205003
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change log

## [1.5.3] - 2023-11-16
### Added
-

### Changed
-

### Fixed
- Fixed CodeQL warnings about sign check of a bitwise operation

## [1.5.2] - 2023-11-15
### Added
-
Expand All @@ -10,7 +20,6 @@
- Tidied up code that sets 'Processing' screen on Nano S devices
- Changed all Variable Length Arrays to a defined length


### Fixed
- Fix freezing at 'Processing' screen on Nano S devices

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ all: default
APPNAME = "Seed Tool"
APPVERSION_M = 1
APPVERSION_N = 5
APPVERSION_P = 2
APPVERSION_P = 3
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

APP_LOAD_PARAMS = --appFlags 0x10 $(COMMON_LOAD_PARAMS) --curve secp256k1 --path ""
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ The application uses [Sharded Secret Key Reconstruction (SSKR)](https://github.c
For more information about SSKR, see [SSKR for Users](https://github.com/BlockchainCommons/crypto-commons/blob/master/Docs/sskr-users.md).

> [!NOTE]
> Generated Shamir's Secret Shares may be cheaply and safely backed up to a steel wallet using the method described [here](https://blockmit.com/english/guides/diy/make-cold-wallet-washers/) or [here](https://jlopp.github.io/metal-bitcoin-storage-reviews/reviews/safu-ninja/). This will keep your backup safe in event of fire, flood or natural disaster.
> SSKR is non-deterministic. There is a random factor introduced when the shares are created, which means that every time you generate shares they will be different. This is an expected and correct result.
> [!TIP]
> Generated Shamir's Secret Shares may be cheaply and safely backed up to a steel wallet using the methods described [here](https://blockmit.com/english/guides/diy/make-cold-wallet-washers/), [here](https://jlopp.github.io/metal-bitcoin-storage-reviews/reviews/safu-ninja/) or [here](https://github.com/BlockchainCommons/crypto-commons/blob/master/Docs/sskr-cold-storage.md). This will keep your backup safe in event of fire, flood or natural disaster.
## Check Shamir's secret shares
The Ledger application also provides an option to confirm the onboarded seed against SSKR shares.
Expand Down
4 changes: 2 additions & 2 deletions src/bc-sskr/sskr.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ static int16_t combine_shards_internal(
// here, all of the shards are unpacked into member groups. Now we go through each
// group and recover the group secret, and then use the result to recover the
// master secret
uint8_t gx[SHAMIR_MAX_SHARE_COUNT];
const uint8_t *gy[SHAMIR_MAX_SHARE_COUNT];
uint8_t gx[SSKR_MAX_GROUP_COUNT];
const uint8_t *gy[SSKR_MAX_GROUP_COUNT];

// allocate enough space for the group shards and the encrypted master secret
uint8_t group_shares[SSKR_MAX_STRENGTH_BYTES * (SSKR_MAX_GROUP_COUNT + 1)];
Expand Down
2 changes: 1 addition & 1 deletion src/ux_common/onboarding_seed_bip39.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ unsigned int bolos_ux_bip39_mnemonic_encode(const uint8_t* seed,
idx = 0;
for (j = 0; j < 11; j++) {
idx <<= 1;
idx += (bits[(i * 11 + j) / 8] & (1 << (7 - ((i * 11 + j) % 8)))) > 0;
idx += (bits[(i * 11 + j) / 8] & (1 << (7 - ((i * 11 + j) % 8)))) != 0;
}
word_len = BIP39_WORDLIST_OFFSETS[idx + 1] - BIP39_WORDLIST_OFFSETS[idx];
if ((offset + word_len) > out_len) {
Expand Down
3 changes: 1 addition & 2 deletions src/ux_common/onboarding_seed_sskr.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ unsigned int bolos_ux_sskr_mnemonic_encode(unsigned char *input,

for (uint8_t i = 0; i < (uint8_t) input_len; i++) {
offset = SSKR_MNEMONIC_LENGTH * input[i];
if ((position + SSKR_MNEMONIC_LENGTH <= output_len) &&
(offset <= SSKR_WORDLIST_LENGTH - SSKR_MNEMONIC_LENGTH)) {
if (position + SSKR_MNEMONIC_LENGTH <= output_len) {
memcpy(output + position, SSKR_WORDLIST + offset, SSKR_MNEMONIC_LENGTH);
} else {
memzero(output, sizeof(output));
Expand Down

0 comments on commit 2205003

Please sign in to comment.