Skip to content

crypto-common: potential future of KeyIvInit for T: InnerInit where T::Inner: KeyIvInit #2271

Description

@tarcieri

Moving this commented out code from the crypto-common source to a tracking issue:

Unfortunately this blanket impl is impossible without mutually exclusive traits, see:
rust-lang/rfcs#1053

or at the very least without:
rust-lang/rust#20400

impl<T> KeyIvInit for T
where
    T: InnerInit,
    T::Inner: KeyIvInit,
{
    #[inline]
    fn new(key: &Key<Self>, iv: &Iv<Self>) -> Self {
        Self::inner_init(T::Inner::new(key, iv))
    }

    #[inline]
    fn new_from_slices(key: &[u8], iv: &[u8]) -> Result<Self, InvalidLength> {
        T::Inner::new_from_slice(key)
            .map_err(|_| InvalidLength)
            .map(Self::inner_init)
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions