Skip to content

Intermediate IV exposing for save/restore APIs #5

Closed

Description

@zugzwang

Hello folks, would you accept a PR similar to block-ciphers/pull/227 as suggested by @newpavlov, allowing to serialize ciphers and continue operation later? Note that even without the exposure, the cryptor can recover the internal IV state at any moment, but this would require additional caching (one full ciphertext block for CFB, and one ciphertext block + one plaintext block + one xor for OFB). Perhaps we could implement the same IvState trait.

Regards

cc. @jethrogb

Activity

  1. tarcieri commented on Mar 22, 2021

    @tarcieri
    Member

    Sounds good to me. @newpavlov, what do you think?

  2. zugzwang commented on Mar 23, 2021

    @zugzwang
    Author

    One detail is that the IvState extends a BlockMode. In hindsight, I could have made it more general so that a stream cipher can implement it (IvState only needs Self::IvSize). Should I be change it? Or should the stream cipher have its own trait?

  3. tarcieri commented on Mar 23, 2021

    @tarcieri
    Member

    Unifying it into a single trait sounds good to me and follows the general course of what @newpavlov has been working on in the cipher crate

  4. newpavlov commented on Mar 24, 2021

    @newpavlov
    Member

    Sounds good to me as well, but, as you've noticed, it's blocked on introduction of a block-level trait for stream ciphers. Right now we have only slice-based traits which handle buffering internally, thus the IvState trait will not be a good fit here. If you need this functionality ASAP, then as a temporary solution we can add CTR to the block-modes crate. We already duplicate the two CFB modes, so I think it will be fine to duplicate CTR as well.

  5. jethrogb commented on Mar 24, 2021

    @jethrogb

    it's blocked on introduction of a block-level trait for stream ciphers

    I don't understand this part? The whole point is to use the byte-based interface.

  6. zugzwang commented on Mar 29, 2021

    @zugzwang
    Author

    I should have emphasized on the fact that we currently need this for CFB and OFB (for CTR, current_pos and seek do the job). We prefer to use CFB and OFB within the stream-ciphers crate, since as @jethrogb mentions, we want byte granularity. From what I see, they both define one internal block that would allow serialization and that the client could recover at any time hélas with some effort (Cfb.iv and Ofb.block).

  7. newpavlov commented on Feb 10, 2022

    @newpavlov
    Member

    I think #2 should resolve this issue. For performance reasons we store encrypted IV, so implementation of the IvState trait in the CFB case also requires BlockDecrypt bound.

    Also note that neither cfb, nor cipher crates include built-in buffering for async stream ciphers. We only provide consuming byte-level methods, so you may have to implement your own block buffering.

  8. cfal commented on Mar 12, 2022

    @cfal

    Also note that neither cfb, nor cipher crates include built-in buffering for async stream ciphers. We only provide consuming byte-level methods, so you may have to implement your own block buffering.

    did this used to be supported? AsyncStreamCipher took an &mut self which allowed it to be used in a streaming manner.. is there a replacement for this or another issue relating to this change?

  9. newpavlov commented on Mar 12, 2022

    @newpavlov
    Member

    @cfal
    Yes, it was. But I think that for most cases the current non-buffering approach is sufficient. It's still possible to build a buffering wrapper around the AsyncStreamCipher trait, but currently it's not included into cipher. If you need such wrapper, please open an issue in the traits repository.

  10. cfal commented on Mar 13, 2022

    @cfal
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