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

[WIP] cipher: migrate to hybrid array #1357

Closed
wants to merge 2 commits into from
Closed

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Oct 8, 2023

Continuation of #1319

Replaces `generic-array` with `hybrid-array`, which is built on a
combination of `typenum` and const generics, providing a degree of
interoperability between the two systems.

`hybrid-array` is designed to be a largely drop-in replacement, and the
number of changes required to switch are relatively minimal aside from
some idiosyncracies.
block: InOut<'inp, 'out, Block<Self>>,
}

impl<'inp, 'out, BS: ArrayLength<u8>> BlockSizeUser for BlockCtx<'inp, 'out, BS> {
impl<'inp, 'out, BS: BlockSizes> BlockSizeUser for BlockCtx<'inp, 'out, BS> {
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a little confused how this worked before, but it seems necessary now, despite the bounds of ArrayLength<T> and ArraySize being otherwise identical (Unsigned):

error[E0277]: the trait bound `BS: Cmp<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>` is not satisfied
   --> cipher/src/block.rs:601:51
    |
601 | impl<'inp, 'out, BS: ArraySize> BlockSizeUser for BlockCtx<'inp, 'out, BS> {
    |                                                   ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Cmp<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>` is not implemented for `BS`
    |
    = note: required for `BS` to implement `IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>`
    = note: required for `BS` to implement `crypto_common::sealed::BlockSizes`
    = note: required for `BS` to implement `BlockSizes`
note: required by a bound in `BlockCtx`
   --> cipher/src/block.rs:597:33
    |
597 | struct BlockCtx<'inp, 'out, BS: BlockSizes> {
    |                                 ^^^^^^^^^^ required by this bound in `BlockCtx`
help: consider further restricting this bound
    |
601 | impl<'inp, 'out, BS: ArraySize + crypto_common::typenum::Cmp<crypto_common::typenum::UInt<crypto_common::typenum::UInt<crypto_common::typenum::UInt<crypto_common::typenum::UInt<crypto_common::typenum::UInt<crypto_common::typenum::UInt<crypto_common::typenum::UInt<crypto_common::typenum::UInt<crypto_common::typenum::UInt<crypto_common::typenum::UTerm, crypto_common::typenum::B1>, crypto_common::typenum::B0>, crypto_common::typenum::B0>, crypto_common::typenum::B0>, crypto_common::typenum::B0>, crypto_common::typenum::B0>, crypto_common::typenum::B0>, crypto_common::typenum::B0>, crypto_common::typenum::B0>>> BlockSizeUser for BlockCtx<'inp, 'out, BS> {
    |                                ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

@tarcieri
Copy link
Member Author

tarcieri commented Oct 8, 2023

Seems we'll need to update both cipher and digest at the same time or this is going to get really tricky

@tarcieri tarcieri closed this Oct 8, 2023
@tarcieri tarcieri deleted the cipher/hybrid-array branch October 8, 2023 21:23
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.

1 participant