openssl/openssl

Partial record decryption

Closed

#21,685 opened on Aug 8, 2023

 (3 comments) (0 reactions) (0 assignees)C (11,262 forks)batch import
help wantedtriaged: feature

Repository metrics

Stars
 (30,157 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Consider the application of a network monitoring system.

The NMS intercepts TLS traffic and it is critical that it reacts immediately to the presence of certain application data on the wire. The NMS does not want to wait for full records to be available as it might be too late, so the problem to solve is decryption of partial records. I cannot rely on RFC6066 max_fragment_length or DTLS to improve granularity of reads because that requires the other peer to collaborate.

I understand that partial record decryption should be possible for all ciphers, as long as I attempt decryption at a multiple of the block size. Integrity is not important for this use case.

My intent is to:

  • Read into the underlying buffer before a full record is available with rl->funcs->read_n , where rl is the OSSL_RECORD_LAYER object, as done by tls_get_more_records via tls_default_read_n.
  • Make a copy of the cipher context with EVP_CIPHER_CTX_copy and decrypt as usual with the EVP apis (although I can see that not every cipher registers dupctx at the moment #20978).
  • If I see anything other than SSL3_RT_APPLICATION_DATA in the header type field, give up the partial read and let it be handled as usual.

Is this reasonable?

Contributor guide