rtciv0.5.0

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.

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.

  • modconformancecfg(feature = "test-support")Reusable conformance assertions for built-in and application-provided crypto providers.
  • modproviders
  • modrfc6979Deterministic ECDSA (RFC 6979) for a certificate's signing key.
  • structPublicKeyBorrowed public-key bytes with an explicit encoding.
  • structSecretVecfrom secret::SecretVecAn owned byte vector that zeroizes its allocation when dropped.
  • enumAeadAlgorithmAuthenticated-encryption algorithms.
  • enumBlockCipherAlgorithmSingle-block encryption algorithms.
  • enumCbcAlgorithmCBC algorithms.
  • enumCryptoAlgorithmA provider capability identifier.
  • enumCryptoErrorfrom error::CryptoErrorA provider-neutral cryptographic failure.
  • enumHashAlgorithmAlgorithms accepted by crate::RTCCrypto::hash.
  • enumHeaderMaskAlgorithmThe 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).
  • enumHmacAlgorithmAlgorithms accepted by the HMAC operations.
  • enumKeyExchangeAlgorithmEphemeral key-agreement algorithms.
  • enumPublicKeyEncodingThe encoding of public-key bytes.
  • enumSignatureSchemeSignature schemes currently used by DTLS.
  • enumStreamCipherAlgorithmStream-cipher algorithms.
  • traitActiveKeyExchangeProvider-owned one-shot ephemeral key exchange.
  • traitAeadCipherA keyed authenticated cipher with detached tags.
  • traitCbcCipherA keyed CBC block cipher with a reusable expanded key.
  • traitHeaderMaskA keyed generator of record-number masks.
  • traitMacA keyed message authentication code with a reusable key schedule.
  • traitRTCCryptoProvider-neutral cryptographic operations.
  • traitRTCCryptoProviderA bundle of cryptographic operations and cryptographically secure randomness.
  • traitRTCRandomA cryptographically secure random byte generator.
  • traitSigningKeyA provider-owned signing key, including external or non-exportable keys.
  • traitStreamCipherA keyed stream cipher with a reusable expanded key.
  • fnconstant_time_eqCompares equal-length byte strings without data-dependent early exit.
  • fndefault_providerfrom provider::default_providerConstructs the built-in default provider.
  • fnhkdf_expandfrom hkdf::hkdf_expandHKDF-Expand(PRK, info, L) (RFC 5869 section 2.3), info given in pieces.
  • fnhkdf_expand_labelfrom hkdf::hkdf_expand_labelHKDF-Expand-Label(Secret, Label, Context, Length) (RFC 8446 section 7.1): HKDF-Expand with the HkdfLabel structure as info. prefix is 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).
  • fnhkdf_extractfrom hkdf::hkdf_extractHKDF-Extract(salt, IKM) (RFC 5869 section 2.2): the pseudorandom key, one digest long.
  • fnon_erased_stackfrom erased_stack::on_erased_stackRuns work and overwrites the stack it ran on.
  • fnopenssl_aes_ctrcfg(feature = "openssl")from openssl_ctr::openssl_aes_ctrBuilds an AES-128/192/256-CTR StreamCipher backed by OpenSSL, keyed once.
  • fnrecord_stack_erasurefrom secret::record_stack_erasureWhether the stack overwrite after each record of set_record_stack_erasure is on.
  • fnrsa_pkcs1_hashfrom rsa_pkcs1::rsa_pkcs1_hashThe hash an RSASSA-PKCS1-v1_5 scheme signs with; None for any other scheme.
  • fnscrub_stackfrom secret::scrub_stackOverwrites the stack below the caller's frame (32 KiB of it in an optimised build, 128 KiB in an unoptimised one).
  • fnset_record_stack_erasurefrom secret::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 …
  • fnverify_rsa_pkcs1_without_digest_parametersfrom rsa_pkcs1::verify_rsa_pkcs1_without_digest_parametersVerifies an RSASSA-PKCS1-v1_5 signature over the message whose digest (made with rsa_pkcs1_hash of scheme) is given, for the DigestInfo encoding WITHOUT the NULL parameters (RFC 5246 section 4.7). public_key is the DER RSAPublicKey. The form with NULL parameters is the provider's (crate::RTCCrypto::verify_signature); this one accepts only the other.
  • constHEADER_MASK_LENThe length of the mask a HeaderMask returns.
  • constHEADER_MASK_SAMPLE_LENThe length of the ciphertext sample a HeaderMask is computed from.

rtci_crypto::rfc6979

Deterministic ECDSA (RFC 6979) for a certificate's signing key.

  • structDeterministicEcdsaKeycfg(feature = "ecdsa-rfc6979")from imp::DeterministicEcdsaKeyA signing key whose ECDSA signatures follow RFC 6979; see deterministic_ecdsa.
  • fndeterministic_ecdsakey, made to sign its ECDSA scheme by RFC 6979 (section 3.2: the nonce k derived from the private key and the message hash by HMAC_DRBG, no randomness).
  • constDETERMINISTIC_ECDSAWhether this build signs ECDSA by RFC 6979 when asked to: the ecdsa-rfc6979 feature.
  • constDETERMINISTIC_ECDSA_SCHEMESThe ECDSA schemes deterministic_ecdsa signs by RFC 6979: P-256 with SHA-256 and P-384 with SHA-384 (TLS 1.3's ecdsa_secp256r1_sha256 and ecdsa_secp384r1_sha384).

rtci_crypto::providers

  • structAwsLcRsCryptocfg(feature = "crypto-aws-lc-rs")from aws_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.
  • structAwsLcRsProvidercfg(feature = "crypto-aws-lc-rs")from aws_lc_rs::AwsLcRsProviderThe built-in AWS-LC-RS provider bundle.
  • structAwsLcRsRandomcfg(feature = "crypto-aws-lc-rs")from aws_lc_rs::AwsLcRsRandomAWS-LC-RS's operating-system-backed secure random source.
  • structRingCryptocfg(feature = "crypto-ring")from ring::RingCryptoRing-backed cryptographic operations, with documented RustCrypto fallbacks for primitives Ring does not expose (MD5, AES block/CTR/CBC, and AES-CCM).
  • structRingProvidercfg(feature = "crypto-ring")from ring::RingProviderThe built-in Ring provider bundle.
  • structRingRandomcfg(feature = "crypto-ring")from ring::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.

  • fnassert_aeadChecks AEAD known-answer vectors, round trips, authentication failures, and malformed sizes.
  • fnassert_block_and_stream_ciphersChecks AES block and stream-cipher known-answer vectors and malformed inputs.
  • fnassert_cbcChecks AES-CBC known-answer vectors and malformed inputs.
  • fnassert_hashes_and_hmacChecks hash and HMAC known-answer vectors and their error contract.
  • fnassert_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.
  • fnassert_key_exchangeChecks every supported one-shot key exchange and malformed peer keys.
  • fnassert_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.
  • fnassert_providerExercises the complete initial RTC crypto contract implemented by the built-in providers.
  • fnassert_randomChecks that a provider's secure random source returns fresh output.
  • fnassert_random_failureChecks the provider-neutral failure returned by a deliberately failing random source.
  • fnassert_rsa_pssChecks RSASSA-PSS verification (the TLS 1.3 rsa_pss_rsae schemes: MGF1 with the same hash, a salt as long as the digest) against signatures made with OpenSSL.
  • fnassert_signaturesChecks signing, verification, key import/export, and invalid signatures and encodings.
  • fnassert_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.
  • fnassert_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.