rtci-srtp 0.4.1

Sans-I/O SRTP and SRTCP (RFC 3711, RFC 7714 AES-GCM, RFC 9335 Cryptex) for WebRTC
Documentation
//! `CipherAeadAesGcm::new` refuses what it cannot build instead of panicking.

use super::cipher_aead_aes_gcm::CipherAeadAesGcm;
use crate::keying::KeyDerivationRate;
use crate::protection_profile::ProtectionProfile;
use shared::error::Error;

#[test]
fn test_aead_cipher_refuses_a_non_gcm_profile() {
    let provider = crypto::default_provider().unwrap();
    let profile = ProtectionProfile::Aes128CmHmacSha1_80;
    let result = CipherAeadAesGcm::new(
        profile,
        &vec![0u8; profile.key_len()],
        &vec![0u8; profile.salt_len()],
        provider.crypto(),
        KeyDerivationRate::ZERO,
        None,
    );
    assert!(matches!(result, Err(Error::ErrNoSuchSrtpProfile)));
}

#[test]
fn test_aead_cipher_refuses_a_wrong_salt_length() {
    let provider = crypto::default_provider().unwrap();
    let profile = ProtectionProfile::AeadAes128Gcm;
    let result = CipherAeadAesGcm::new(
        profile,
        &vec![0u8; profile.key_len()],
        &[0u8; 14],
        provider.crypto(),
        KeyDerivationRate::ZERO,
        None,
    );
    assert!(matches!(result, Err(Error::SrtpSaltLength(12, 14))));
}