For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/static_analysis/static_analysis_rules/rust-security/avoid-des.md. A documentation index is available at /llms.txt.

Avoid using the insecure DES or 3DES ciphers

This product is not supported for your selected Datadog site. ().

Metadata

ID: rust-security/avoid-des

Language: Rust

Severity: Warning

Category: Security

CWE: 327

Related CWEs:

Description

DES uses a 56-bit key that can be brute-forced in hours on modern hardware. Triple DES (3DES) is deprecated by NIST SP 800-131A and remains vulnerable to Sweet32 birthday attacks against its 64-bit block size. Use AES-256-GCM (via the aes-gcm crate) or another modern authenticated encryption algorithm instead.

Learn More

Non-Compliant Code Examples

use des;
use des::Des;
use des::{Des, TdesEde3};
use openssl::symm::Cipher;

fn invalid() {
    let key = [0u8; 8];

    // RustCrypto `des` crate — single DES and Triple DES variants
    let _ = des::Des::new_from_slice(&key);
    let _ = des::TdesEde3::new_from_slice(&key);

    // openssl/boring `Cipher::des_*()` builders
    let _ = Cipher::des_cbc();
    let _ = openssl::symm::Cipher::des_ede3_cbc();
}

Compliant Code Examples

use aes_gcm::{Aes256Gcm, KeyInit};

fn ok() {
    // Safe: AES-256-GCM instead of DES
    let key = [0u8; 32];
    let _ = Aes256Gcm::new(&key.into());
}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Security