Skip to content

Reset key and iv prior to aes decryption in crypto demo#288

Draft
AlexLanzano wants to merge 1 commit intowolfSSL:mainfrom
AlexLanzano:demo-fix
Draft

Reset key and iv prior to aes decryption in crypto demo#288
AlexLanzano wants to merge 1 commit intowolfSSL:mainfrom
AlexLanzano:demo-fix

Conversation

@AlexLanzano
Copy link
Member

fixes #287

Fix AES CBC decryption in the crypto demo by using wc_AesSetKey instead of wc_AesSetIV to properly reset both the key schedule for decryption and the IV before decryptin

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

This PR fixes a bug in the AES CBC demo where decryption produces incorrect results when using client-side crypto (device ID -2) rather than HSM server callbacks. The issue occurs because CBC mode requires different key schedules for encryption vs decryption, and the previous code only reset the IV without resetting the key schedule.

Changes:

  • Updated wh_DemoClient_CryptoAesCbc to call wc_AesSetKey with AES_DECRYPTION flag instead of wc_AesSetIV before decryption
  • Updated the comment and error message to accurately reflect the change

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

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.

Bug: wh_demo_client_crypto AES CBC decryption produces incorrect result if the device is changed to invalid

1 participant

Comments