Skip to content

Conversation

@baloo
Copy link
Member

@baloo baloo commented Sep 30, 2025

When a downstream crate enables the subtle feature in hybrid-array, the crate would fail to compile:

src/algorithms/pss.rs:375:31
    |
375 |     if (salt_valid & h0.ct_eq(h)).into() {
    |                         ----- ^ expected `&Array<u8, ...>`, found `&mut [u8]`
    |                         |
    |                         arguments to this method are incorrect
    |
    = note:      expected reference `&Array<u8, <D as OutputSizeUser>::OutputSize>`
            found mutable reference `&mut [u8]`

This is because the hybrid_array::Array was automatically deref'ed to a slice. Now Array implements subtle::ConstantTimeEq that automatic deref no longer happens.

This commit fixes that by converting one of the arguments of the conversion that brings back the auto-deref.

Thanks to @tarcieri for the help debugging: RustCrypto/formats#2049 (comment)

When a downstream crate enables the `subtle` feature in `hybrid-array`,
the crate would fail to compile:
```
src/algorithms/pss.rs:375:31
    |
375 |     if (salt_valid & h0.ct_eq(h)).into() {
    |                         ----- ^ expected `&Array<u8, ...>`, found `&mut [u8]`
    |                         |
    |                         arguments to this method are incorrect
    |
    = note:      expected reference `&Array<u8, <D as OutputSizeUser>::OutputSize>`
            found mutable reference `&mut [u8]`
```

This is because the `hybrid_array::Array` was automatically deref'ed to
a slice. Now `Array` implements `subtle::ConstantTimeEq` that automatic
deref no longer happens.

This commit fixes that by converting one of the arguments of the
conversion that brings back the auto-deref.
@tarcieri tarcieri merged commit 6e3e33e into RustCrypto:master Sep 30, 2025
12 checks passed
@baloo baloo deleted the baloo/fixup-subtle branch September 30, 2025 07:10
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