Skip to content

fix(aes): Fix AESParameters deserialization for AES-128-CBC and improve error handling for unsupported ciphers#4694

Open
sergei-boiko-trustwallet wants to merge 4 commits intomasterfrom
fix/aes-parameters-from-json
Open

fix(aes): Fix AESParameters deserialization for AES-128-CBC and improve error handling for unsupported ciphers#4694
sergei-boiko-trustwallet wants to merge 4 commits intomasterfrom
fix/aes-parameters-from-json

Conversation

@sergei-boiko-trustwallet
Copy link
Contributor

This pull request refactors the getCipher function in AESParameters.cpp to improve error handling and add support for an additional cipher. The most important changes include switching from chained else if statements to separate if blocks, adding support for the gAes128Cbc cipher, and throwing an exception for unsupported ciphers instead of defaulting.

Cipher support and error handling improvements:

  • Added support for the gAes128Cbc cipher in the getCipher function.
  • Changed error handling to throw a std::invalid_argument exception with a descriptive message when an unsupported cipher is provided, instead of defaulting to TWStoredKeyEncryptionAes128Ctr.

Code style refactoring:

  • Replaced chained else if statements with individual if statements for clarity and maintainability in the getCipher function.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors keystore AES cipher selection to recognize AES-128-CBC and to fail fast with a descriptive error when an unknown cipher string is encountered, instead of silently defaulting to AES-128-CTR.

Changes:

  • Added aes-128-cbc handling in getCipher().
  • Replaced the previous default-to-CTR behavior with a thrown std::invalid_argument for unsupported ciphers.
  • Refactored the conditional structure in getCipher() for readability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Binary size comparison

➡️ aarch64-apple-ios: 14.34 MB

➡️ aarch64-apple-ios-sim: 14.34 MB

➡️ aarch64-linux-android: 18.77 MB

➡️ armv7-linux-androideabi: 16.20 MB

➡️ wasm32-unknown-emscripten: 13.68 MB

@sergei-boiko-trustwallet sergei-boiko-trustwallet changed the title fix(aes): Add support for AES-128-CBC and improve error handling for unsupported ciphers fix(aes): Fix AESParameters deserialization for AES-128-CBC and improve error handling for unsupported ciphers Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants