Driver: Replace xsalsa20poly1305 with crypto_secretbox (#198)
As of v0.9.1, `xsalsa20poly1305` has been deprecated. This is a mostly seamless replacement, as it appears to be the same crate authors / code / etc. Co-authored-by: Kyle Simpson <kyleandrew.simpson@gmail.com>
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
//! Encryption schemes supported by Discord's secure RTP negotiation.
|
||||
use byteorder::{NetworkEndian, WriteBytesExt};
|
||||
#[cfg(any(feature = "receive", test))]
|
||||
use crypto_secretbox::Tag;
|
||||
use crypto_secretbox::{
|
||||
aead::{AeadInPlace, Error as CryptoError},
|
||||
Nonce,
|
||||
SecretBox,
|
||||
XSalsa20Poly1305 as Cipher,
|
||||
};
|
||||
use discortp::{rtp::RtpPacket, MutablePacket};
|
||||
use rand::Rng;
|
||||
use std::num::Wrapping;
|
||||
#[cfg(any(feature = "receive", test))]
|
||||
use xsalsa20poly1305::Tag;
|
||||
use xsalsa20poly1305::{
|
||||
aead::{AeadInPlace, Error as CryptoError},
|
||||
Nonce,
|
||||
XSalsa20Poly1305 as Cipher,
|
||||
NONCE_SIZE,
|
||||
TAG_SIZE,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
pub const KEY_SIZE: usize = SecretBox::<()>::KEY_SIZE;
|
||||
pub const NONCE_SIZE: usize = SecretBox::<()>::NONCE_SIZE;
|
||||
pub const TAG_SIZE: usize = SecretBox::<()>::TAG_SIZE;
|
||||
|
||||
/// Variants of the `XSalsa20Poly1305` encryption scheme.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
@@ -253,8 +257,8 @@ impl CryptoState {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crypto_secretbox::KeyInit;
|
||||
use discortp::rtp::MutableRtpPacket;
|
||||
use xsalsa20poly1305::{KeyInit, KEY_SIZE, TAG_SIZE};
|
||||
|
||||
#[test]
|
||||
fn small_packet_decrypts_error() {
|
||||
|
||||
Reference in New Issue
Block a user