Poll-based encrypt/decrypt/sign API support in asynchronous and synchronous call

Open
#1,976 9 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
cryptography

Research direction

Start with the crypto/cipher/MessageDecrypter trait shown in the issue and review the related rustls crypto API documentation. Trace every encrypt/decrypt call site to determine the poll contract for synchronous and asynchronous callers, then verify that both usage modes are covered.

Written by the indexing model from the issue text.

Description

Checklist

Describe the solution you'd like
https://docs.rs/rustls/latest/rustls/crypto/cipher/trait.MessageDecrypter.html

convert crypto api to poll based

from

pub trait MessageDecrypter: Send + Sync {
    /// Decrypt the given TLS message `msg`, using the sequence number
    /// `seq` which can be used to derive a unique [`Nonce`].
    fn decrypt<'a>(
        &mut self,
        msg: InboundOpaqueMessage<'a>,
        seq: u64,
    ) -> Result<InboundPlainMessage<'a>, Error>;
}

to

pub trait MessageDecrypter: Send + Sync {
    /// Decrypt the given TLS message `msg`, using the sequence number
    /// `seq` which can be used to derive a unique [`Nonce`].
    fn decrypt<'a>(
        &mut self,
        cx: &mut Context<'a>,
        msg: InboundOpaqueMessage<'a>,
        seq: u64,
    ) -> Result<InboundPlainMessage<'a>, Error>;
}

so that we can call tokio#poll_read to make encrypt/decrypt async

every encrypt/decrypt should call through trait, so we can hack it

Additional context
rustls only support poll method. user decide whether sync or async. If sync, just do and return Poll::Ready

Dominant language
Rust
Stars
7.7k
Forks
947
Avg merge
3d 11h
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rustls/rustls

All issues in rustls/rustls

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.