Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aes-gcm: Clarify CPU feature detection. #2106

Merged
merged 1 commit into from
Jun 23, 2024
Merged

Commits on Jun 21, 2024

  1. aes-gcm: Clarify CPU feature detection.

    Although every key has been represented with the same types
    `aes::AES_KEY` and `gcm::HTable` regardless of which implementation is
    used, in reality those types are polymorphic in ways that aren't
    captured by the type system currently. Thus, the
    `set_encrypt_key!` function must be matched with the corresponding
    `encrypt_block!` and/or `ctr32_encrypt_blocks!` function. Previously,
    we did CPU feature detection for each function call and assumed that
    CPU feature detection is idempotent. Now, we do CPU feature detection
    during key construction and make the lesser assumption that at least
    those same CPU features are available as long as the key exists.
    
    This is a step towards making further improvements in CPU-feature-based
    dispatching.
    
    This makes code coverage reporting a little clearer. For example, it
    became clearer that the x86 VPAES implementation wasn't being tested in
    CI; this will be rectified in another commit.
    
    One side-effect of this change is that GCM keys (and thus AES-GCM keys)
    are now much smaller on targets that don't support any assembly
    implementation, as they now just store a single `U128` instead of a
    whole `HTable`.
    
    Another nice effect is that the dead ctr32_encrypt_blocks
    implementation for aarch64 is no longer needed.
    
    ```
    git difftool HEAD^1:src/aead/aes.rs src/aead/aes/bs.rs
    git difftool HEAD^1:src/aead/aes.rs src/aead/aes/vp.rs
    ```
    briansmith committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    9ce7475 View commit details
    Browse the repository at this point in the history