rtci-crypto
Provider-neutral cryptography interface of a sans-I/O WebRTC stack, with ring and aws-lc-rs providers. 4 public modules, 65 items at 0.5.0.
cargo add [email protected] · crates.io · docs.rs · README on GitHub· MSRV 1.89
README
rtci-crypto provides the provider-neutral cryptographic operations used by every crate of the rtci workspace. Applications can use a built-in Ring or AWS-LC-RS provider, or implement the public provider traits without registration or sealing.
The crate owns primitives and opaque keyed state. DTLS, SRTP, STUN, certificate policy, and wire-format composition remain in their protocol crates.
Enable test-support to run the reusable provider conformance suite from a downstream provider's tests.
#[test]
fn provider_conforms() {
let provider = MyProvider::new();
rtci_crypto::conformance::assert_provider(&provider);
}
The built-in providers are also run against 25 Project Wycheproof files (6,998 cases) through the same trait, in the repository's tests/wycheproof.rs (not in the published package).
Partial providers can invoke the public operation-family helpers that match their advertised capabilities. The feature adds no built-in backend, so a downstream provider can test with default-features = false, features = ["test-support"].
The crypto-ring (default) and crypto-aws-lc-rs features are additive. The ring provider is the default when enabled, including builds that enable both backends. With neither backend enabled, applications construct their own Arc<dyn RTCCryptoProvider> and default_provider() returns CryptoError::NoDefaultProvider.
openssl (and vendored-openssl) add an OpenSSL AES-CTR stream cipher for rtci-srtp's openssl feature. There is no I/O in the crate: providers are called with the data and keys their callers hold.
Licence
Licensed under either of the MIT licence or the Apache License, Version 2.0, at your option.
This crate is part of the rtci workspace, which descends from webrtc-rs/rtc and is developed independently; FORK.md lists what it carries over upstream. Upstream's licence and copyright notices are retained.
rtci_crypto
Provider-neutral cryptography for the webrtc-rs RTC stack.
- mod
conformancecfg(feature = "test-support")Reusable conformance assertions for built-in and application-provided crypto providers. - mod
providers - mod
rfc6979Deterministic ECDSA (RFC 6979) for a certificate's signing key. - struct
PublicKeyBorrowed public-key bytes with an explicit encoding. - struct
SecretVecfromsecret::SecretVecAn owned byte vector that zeroizes its allocation when dropped. - enum
AeadAlgorithmAuthenticated-encryption algorithms. - enum
BlockCipherAlgorithmSingle-block encryption algorithms. - enum
CbcAlgorithmCBC algorithms. - enum
CryptoAlgorithmA provider capability identifier. - enum
CryptoErrorfromerror::CryptoErrorA provider-neutral cryptographic failure. - enum
HashAlgorithmAlgorithms accepted bycrate::RTCCrypto::hash. - enum
HeaderMaskAlgorithmThe ciphers a record-number (header-protection) mask is made with: the block cipher or stream cipher underneath an AEAD, keyed separately (RFC 9147 section 4.2.3; the same construction as QUIC header protection, RFC 9001 section 5.4). - enum
HmacAlgorithmAlgorithms accepted by the HMAC operations. - enum
KeyExchangeAlgorithmEphemeral key-agreement algorithms. - enum
PublicKeyEncodingThe encoding of public-key bytes. - enum
SignatureSchemeSignature schemes currently used by DTLS. - enum
StreamCipherAlgorithmStream-cipher algorithms. - trait
ActiveKeyExchangeProvider-owned one-shot ephemeral key exchange. - trait
AeadCipherA keyed authenticated cipher with detached tags. - trait
CbcCipherA keyed CBC block cipher with a reusable expanded key. - trait
HeaderMaskA keyed generator of record-number masks. - trait
MacA keyed message authentication code with a reusable key schedule. - trait
RTCCryptoProvider-neutral cryptographic operations. - trait
RTCCryptoProviderA bundle of cryptographic operations and cryptographically secure randomness. - trait
RTCRandomA cryptographically secure random byte generator. - trait
SigningKeyA provider-owned signing key, including external or non-exportable keys. - trait
StreamCipherA keyed stream cipher with a reusable expanded key. - fn
constant_time_eqCompares equal-length byte strings without data-dependent early exit. - fn
default_providerfromprovider::default_providerConstructs the built-in default provider. - fn
hkdf_expandfromhkdf::hkdf_expandHKDF-Expand(PRK, info, L)(RFC 5869 section 2.3),infogiven in pieces. - fn
hkdf_expand_labelfromhkdf::hkdf_expand_labelHKDF-Expand-Label(Secret, Label, Context, Length)(RFC 8446 section 7.1): HKDF-Expand with theHkdfLabelstructure as info.prefixis what the label is prefixed with on the wire:"tls13 "for TLS 1.3 and"dtls13"for DTLS 1.3 (RFC 9147 section 5.9). - fn
hkdf_extractfromhkdf::hkdf_extractHKDF-Extract(salt, IKM)(RFC 5869 section 2.2): the pseudorandom key, one digest long. - fn
on_erased_stackfromerased_stack::on_erased_stackRunsworkand overwrites the stack it ran on. - fn
openssl_aes_ctrcfg(feature = "openssl")fromopenssl_ctr::openssl_aes_ctrBuilds an AES-128/192/256-CTRStreamCipherbacked by OpenSSL, keyed once. - fn
record_stack_erasurefromsecret::record_stack_erasureWhether the stack overwrite after each record ofset_record_stack_erasureis on. - fn
rsa_pkcs1_hashfromrsa_pkcs1::rsa_pkcs1_hashThe hash an RSASSA-PKCS1-v1_5 scheme signs with;Nonefor any other scheme. - fn
scrub_stackfromsecret::scrub_stackOverwrites the stack below the caller's frame (32 KiB of it in an optimised build, 128 KiB in an unoptimised one). - fn
set_record_stack_erasurefromsecret::set_record_stack_erasureTurns on or off, for the whole process, the stack overwrite after each record operation of the paths that leave key copies in dead stack frames of code the crate cannot change: the AWS-LC provider's AEAD (its AES-GCM leaves a GHASH table entry) and HMAC (each MAC is computed on a copy of the keyed context, HMAC-SHA1 for SRTP and the DTLS AES-CBC suites); the ring provider's ChaCha20-Poly1305 … - fn
verify_rsa_pkcs1_without_digest_parametersfromrsa_pkcs1::verify_rsa_pkcs1_without_digest_parametersVerifies an RSASSA-PKCS1-v1_5signatureover the message whosedigest(made withrsa_pkcs1_hashofscheme) is given, for the DigestInfo encoding WITHOUT the NULL parameters (RFC 5246 section 4.7).public_keyis the DERRSAPublicKey. The form with NULL parameters is the provider's (crate::RTCCrypto::verify_signature); this one accepts only the other. - const
HEADER_MASK_LENThe length of the mask aHeaderMaskreturns. - const
HEADER_MASK_SAMPLE_LENThe length of the ciphertext sample aHeaderMaskis computed from.
rtci_crypto::rfc6979
Deterministic ECDSA (RFC 6979) for a certificate's signing key.
- struct
DeterministicEcdsaKeycfg(feature = "ecdsa-rfc6979")fromimp::DeterministicEcdsaKeyA signing key whose ECDSA signatures follow RFC 6979; seedeterministic_ecdsa. - fn
deterministic_ecdsakey, made to sign its ECDSA scheme by RFC 6979 (section 3.2: the noncekderived from the private key and the message hash by HMAC_DRBG, no randomness). - const
DETERMINISTIC_ECDSAWhether this build signs ECDSA by RFC 6979 when asked to: theecdsa-rfc6979feature. - const
DETERMINISTIC_ECDSA_SCHEMESThe ECDSA schemesdeterministic_ecdsasigns by RFC 6979: P-256 with SHA-256 and P-384 with SHA-384 (TLS 1.3'secdsa_secp256r1_sha256andecdsa_secp384r1_sha384).
rtci_crypto::providers
- struct
AwsLcRsCryptocfg(feature = "crypto-aws-lc-rs")fromaws_lc_rs::AwsLcRsCryptoAWS-LC-RS-backed operations, with RustCrypto fallbacks for primitives that are not exposed by its stable high-level API: MD5, AES block/CTR/CBC, and AES-CCM. - struct
AwsLcRsProvidercfg(feature = "crypto-aws-lc-rs")fromaws_lc_rs::AwsLcRsProviderThe built-in AWS-LC-RS provider bundle. - struct
AwsLcRsRandomcfg(feature = "crypto-aws-lc-rs")fromaws_lc_rs::AwsLcRsRandomAWS-LC-RS's operating-system-backed secure random source. - struct
RingCryptocfg(feature = "crypto-ring")fromring::RingCryptoRing-backed cryptographic operations, with documented RustCrypto fallbacks for primitives Ring does not expose (MD5, AES block/CTR/CBC, and AES-CCM). - struct
RingProvidercfg(feature = "crypto-ring")fromring::RingProviderThe built-in Ring provider bundle. - struct
RingRandomcfg(feature = "crypto-ring")fromring::RingRandomRing's operating-system-backed secure random source.
rtci_crypto::conformancecfg(feature = "test-support")
Reusable conformance assertions for built-in and application-provided crypto providers.
- fn
assert_aeadChecks AEAD known-answer vectors, round trips, authentication failures, and malformed sizes. - fn
assert_block_and_stream_ciphersChecks AES block and stream-cipher known-answer vectors and malformed inputs. - fn
assert_cbcChecks AES-CBC known-answer vectors and malformed inputs. - fn
assert_hashes_and_hmacChecks hash and HMAC known-answer vectors and their error contract. - fn
assert_header_masksChecks the record-number masks against the header-protection samples of RFC 9001 appendix A, which are the computation RFC 9147 section 4.2.3 defines. - fn
assert_key_exchangeChecks every supported one-shot key exchange and malformed peer keys. - fn
assert_key_exchange_respondChecks the responder's side of a key exchange, and X25519MLKEM768 (draft-ietf-tls-ecdhe-mlkem) where the provider has it: the lengths of its shares and secret, agreement, and that malformed shares are refused. A provider without it says so. - fn
assert_providerExercises the complete initial RTC crypto contract implemented by the built-in providers. - fn
assert_randomChecks that a provider's secure random source returns fresh output. - fn
assert_random_failureChecks the provider-neutral failure returned by a deliberately failing random source. - fn
assert_rsa_pssChecks RSASSA-PSS verification (the TLS 1.3rsa_pss_rsaeschemes: MGF1 with the same hash, a salt as long as the digest) against signatures made with OpenSSL. - fn
assert_signaturesChecks signing, verification, key import/export, and invalid signatures and encodings. - fn
assert_tls13_key_scheduleChecks SHA-384, HMAC-SHA-384, HKDF and the TLS 1.3 key schedule against FIPS 180-4, RFC 4231, RFC 5869 and the RFC 8448 section 3 trace. - fn
assert_unsupported_hashChecks the default unsupported-operation behavior required for partial providers.
Generated from the sources of rtci-crypto 0.5.0 at its release tag. Items made by macros and methods are on docs.rs.