miku-ktls 7.0.0-rc.4

Configures kTLS for tokio-rustls client and server connections.
Documentation
//! Crate error type

use rustls::SupportedCipherSuite;

#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("failed to enable TLS ULP (upper level protocol): {0}")]
    UlpError(#[source] std::io::Error),

    #[error("kTLS compatibility error: {0}")]
    KtlsCompatibility(#[from] KtlsCompatibilityError),

    #[error("failed to export secrets")]
    ExportSecrets(#[source] rustls::Error),

    #[error("failed to configure tx/rx (unsupported cipher?): {0}")]
    TlsCryptoInfoError(#[source] std::io::Error),

    #[error("an I/O occured while draining the rustls stream: {0}")]
    DrainError(#[source] std::io::Error),

    #[error("no negotiated cipher suite: call config_ktls_* only /after/ the handshake")]
    NoNegotiatedCipherSuite,

    #[error("reuse after kTLS has been successfully setup")]
    ReuseAfterKtlsSetup,
}

#[allow(dead_code)]
#[derive(Debug, thiserror::Error)]
pub enum CipherSuiteError {
    #[error("TLS 1.2 support not built in")]
    Tls12NotBuiltIn,

    #[error("unsupported cipher suite")]
    UnsupportedCipherSuite(SupportedCipherSuite),
}

#[derive(Debug, thiserror::Error)]
pub enum KtlsCompatibilityError {
    #[error("cipher suite not supported with kTLS: {0:?}")]
    UnsupportedCipherSuite(SupportedCipherSuite),

    #[error("wrong size key")]
    WrongSizeKey,

    #[error("wrong size iv")]
    WrongSizeIv,
}