Skip to content

aead: object safety #70

Description

@tarcieri

Right now the Aead (and other) traits are not object safe, because of the encrypt method's use of impl Into<Payload> and encrypt_in_place method's use of impl Buffer.

I think I'd like to leave the impl Into<Payload> on encrypt as-is, but split Aead and AeadMut into two traits: one object safe, and one not.

Namely I propose we could have AeadInPlace and AeadMutInPlace which are object-safe. The impl Buffer can be replaced with a generic parameter on the trait itself, which would both permit object safety and allow for multiple impls (i.e. for alloc::vec::Vec and heapless::Vec). We could then have a blanket impl of Aead for AeadInPlace<Vec>, and AeadMut for AeadMutInPlace<Vec>.

This would also be helpful for AEAD provider crates who don't want to impl the in-place methods and just have allocating Vec-based APIs, which is the case for ursa: hyperledger-archives/ursa#91

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

    aeadAuthenticated Encryption with Associated Data (AEAD) crate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions