RSA keys shorter than 2,048 bits can be factored with modern hardware and cloud-scale compute, exposing encrypted data and signatures to recovery or forgery. NIST SP 800-57 recommends a minimum of 2,048 bits, with 3,072 or 4,096 bits preferred for data with long-term secrecy requirements. The min-length argument can be raised above the 2,048-bit default to enforce a stricter threshold. Values below 2,048 are clamped to the NIST minimum.
usersa::RsaPrivateKey;useopenssl::rsa::Rsa;userand::rngs::OsRng;fnok()-> Result<(),Box<dynstd::error::Error>>{letmutrng=OsRng;// `rsa` crate at the minimum
let_=RsaPrivateKey::new(&mutrng,2048)?;// Digit separator and type suffix — both >= 2048
let_=RsaPrivateKey::new(&mutrng,2_048)?;let_=RsaPrivateKey::new(&mutrng,4096usize)?;// Fully qualified path
let_=rsa::RsaPrivateKey::new(&mutrng,2048)?;// new_with_exp with sufficient bits
letexp=rsa::BoxedUint::from(65537u64);let_=rsa::RsaPrivateKey::new_with_exp(&mutrng,2048,exp)?;// `openssl` crate at or above the minimum
let_=Rsa::generate(2048)?;let_=openssl::rsa::Rsa::generate(4096)?;Ok(())}
원활한 통합. Datadog Code Security 사용해 보기
Datadog Code Security
이 규칙을 사용해 Datadog Code Security로 코드 분석해 보기
이 규칙의 사용법
1
2
rulesets:- rust-security # Rules to enforce Rust security.
리포지토리 루트에서 위의 콘텐츠를 사용해 static-analysis.datadog.yml 생성
Datadog의 무료 IDE Plugins를 사용하거나 Code Security 스캔을 CI 파이프라인에 추가