Skip to content

Conversation

@bugadani
Copy link
Contributor

@bugadani bugadani commented Jan 6, 2026

These frontend types can be freely created, and they contain the partial result of their respective operation. They can be big, but there is no underlying reason to prevent cloning them, e.g. to branch off calculation after some common prefix has been processed.

ESP32 is again a special case, because we can't save SHA state on it. This means we can't clone a frontend that started operation using hardware, and that means we can't clone SHA context at all - conditionally failing would be a worse solution than just removing hardware acceleration altogether.

Closes #4707

@bugadani bugadani force-pushed the clone branch 2 times, most recently from 05092ca to bf230f0 Compare January 6, 2026 08:55
@bugadani bugadani marked this pull request as ready for review January 6, 2026 09:46
Copilot AI review requested due to automatic review settings January 6, 2026 09:46
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 implements the Clone trait for crypto frontend types (RsaContext, AesContext, and Sha<X>Context), allowing users to branch off calculations after processing a common prefix. ESP32 is excluded from SHA cloning because it cannot save/restore SHA hardware state.

  • Added Clone implementations for work queue infrastructure (WorkItem, WorkQueueFrontend)
  • Made crypto contexts cloneable: RsaContext, AesContext, and SHA contexts (except on ESP32)
  • Added test for SHA clone functionality

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
hil-test/src/bin/ecc_rsa_sha.rs Adds test verifying that cloned SHA contexts maintain independent state
esp-hal/src/work_queue.rs Implements Clone for WorkItem (manually) and WorkQueueFrontend (derived), resetting state for cloned items
esp-hal/src/sha.rs Conditionally derives Clone for SHA-related types, excluding ESP32 due to hardware limitations
esp-hal/src/rsa/mod.rs Derives Clone for RSA work item and context types
esp-hal/src/aes/mod.rs Implements Clone for AES operation (manually calling Key::copy()) and derives for AesContext
esp-hal/CHANGELOG.md Documents the new Clone implementations

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

@JurajSadel JurajSadel added this pull request to the merge queue Jan 6, 2026
Merged via the queue into esp-rs:main with commit 43755a3 Jan 6, 2026
31 checks passed
@bugadani bugadani deleted the clone branch January 6, 2026 12:54
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.

Implement Clone for esp_hal::sha::ShaXXXContext

2 participants