Skip to content

Conversation

@miyazakh
Copy link
Contributor

@miyazakh miyazakh commented Aug 22, 2025

Add unit test and benchmark for CTR and ECB as well

This comes from Issue#153

@miyazakh miyazakh assigned miyazakh and wolfSSL-Bot and unassigned miyazakh Aug 22, 2025
@dgarske dgarske requested review from bigbrett and billphipps August 22, 2025 14:59
@miyazakh miyazakh changed the title Add AES-CTR and AES-ECB Support AES-CTR and AES-ECB Aug 24, 2025
@bigbrett bigbrett requested a review from Copilot September 2, 2025 13:04
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 adds support for AES-CTR and AES-ECB cipher modes to wolfHSM, extending the existing AES implementation with these additional modes.

  • Implements AES-CTR (Counter) and AES-ECB (Electronic Codebook) modes for both client and server sides
  • Adds comprehensive unit tests for both cipher modes with client-side and HSM-side key operations
  • Includes benchmark implementations for performance testing of CTR and ECB modes

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
wolfhsm/wh_message_crypto.h Defines message structures and function prototypes for AES-CTR and AES-ECB operations
wolfhsm/wh_client_crypto.h Adds client-side function declarations for CTR and ECB modes
src/wh_message_crypto.c Implements message translation functions for CTR and ECB request/response structures
src/wh_client_crypto.c Implements client-side AES-CTR and AES-ECB functions with request/response handling
src/wh_client_cryptocb.c Adds crypto callback handlers for CTR and ECB cipher operations
src/wh_server_crypto.c Implements server-side handlers for processing CTR and ECB cipher requests
test/wh_test_crypto.c Adds unit tests for both CTR and ECB modes testing client and HSM key scenarios
benchmark/wh_bench_mod_aes.c Implements benchmark functions for CTR and ECB performance testing
Various user_settings.h files Enables WOLFSSL_AES_COUNTER flag across different configurations
Comments suppressed due to low confidence (1)

wolfhsm/wh_message_crypto.h:1

  • ECB mode does not use an IV (initialization vector), so including iv[AES_IV_SIZE] in the ECB request structure documentation is misleading. ECB operates on individual blocks without chaining.
/*

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@bigbrett bigbrett left a comment

Choose a reason for hiding this comment

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

Overall, looks great, just a few nits. I also flagged a point for discussion that I want @billphipps to look at.

Finally, @miyazakh can you please run git-clang-format main on this branch to run only your changed lines through clang-format? I think there were a few things that will be fixed.

@miyazakh
Copy link
Contributor Author

miyazakh commented Sep 3, 2025

Run git clang-format main

@miyazakh miyazakh force-pushed the add_aes_ctr branch 2 times, most recently from d2a4b92 to 1b6c7e9 Compare September 9, 2025 22:15
bigbrett
bigbrett previously approved these changes Sep 10, 2025
@bigbrett
Copy link
Contributor

@miyazakh needs rebase, we fixed an error in makefiles. SOrry!

@miyazakh
Copy link
Contributor Author

rebase and increase MAX_BENCH_OPS

@bigbrett bigbrett merged commit 0f52794 into wolfSSL:main Sep 12, 2025
6 checks passed
@miyazakh miyazakh deleted the add_aes_ctr branch November 14, 2025 21:55
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.

4 participants