-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TLS Certificate Compression (RFC8879)
- Loading branch information
1 parent
9fe0521
commit 310088d
Showing
15 changed files
with
484 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//! Compression related operations | ||
|
||
use crate::msgs::enums::CertificateCompressionAlgorithm; | ||
use std::io::Result; | ||
|
||
/// A certificate compression algorithm described | ||
/// as a pair of compression and decompression | ||
/// functions used to compress and decompress a certificate | ||
pub struct CertificateCompression { | ||
/// compression algorithm | ||
pub alg: CertificateCompressionAlgorithm, | ||
|
||
/// compression function | ||
pub compress: CertificateCompress, | ||
|
||
/// decompression function | ||
pub decompress: CertificateDecompress, | ||
} | ||
|
||
type CompressionFn = Box<dyn (Fn(Vec<u8>, &[u8]) -> Result<Vec<u8>>) + Send + Sync>; | ||
|
||
/// A compression function which returns the compressed representation | ||
/// of the input | ||
pub struct CertificateCompress(CompressionFn); | ||
|
||
impl CertificateCompress { | ||
/// Create a new CertificateCompress | ||
pub fn new(compression_fn: CompressionFn) -> Self { | ||
Self(compression_fn) | ||
} | ||
|
||
/// Call the compression function | ||
pub(crate) fn compress(&self, writer: Vec<u8>, input: &[u8]) -> Result<Vec<u8>> { | ||
self.0(writer, input) | ||
} | ||
} | ||
|
||
type DecompressionFn = CompressionFn; | ||
|
||
/// A decompression function which returns the decompressed representation | ||
/// of the input. The input to this function is a pre-allocated vector | ||
/// of the expected length of the uncompressed input | ||
pub struct CertificateDecompress(DecompressionFn); | ||
|
||
impl CertificateDecompress { | ||
/// Create a new CertificateDecompress | ||
pub fn new(decompression_fn: DecompressionFn) -> Self { | ||
Self(decompression_fn) | ||
} | ||
|
||
/// Call the decompression function | ||
pub(crate) fn decompress(&self, writer: Vec<u8>, input: &[u8]) -> Result<Vec<u8>> { | ||
self.0(writer, input) | ||
} | ||
} |
Oops, something went wrong.