Safeguard
Security Guides•

What key sizes should you use for AES and RSA in new applications?

Short answer: AES keys of at least 128 bits, ideally 256, and RSA keys of at least 2048 bits with proper padding. Why key size is rarely your weak point.

Safeguard Security Team
3 min read

For AES, use keys of at least 128 bits, ideally 256. For RSA, use at least 2048 bits and a proper padding scheme. Those are the OWASP minimums. In practice key size is rarely what fails: modes, nonces, and key storage cause far more incidents than a 128 versus 256 choice.

The numbers from OWASP

AlgorithmOWASP guidance
AESKey of at least 128 bits, ideally 256 bits, with a secure mode
RSAIf RSA must be used, key of at least 2048 bits
RSA encryptionUse RSAES-OAEP, and never RSA without a padding scheme
CertificatesRSA keys of at least 2048 bits, signed with SHA-256

OWASP's wording on RSA is "if RSA must be used", which signals a preference for other algorithms where you have the choice.

What key size does and does not buy

Size sets the work needed to guess a key by brute force. Past a threshold the number is large enough that guessing is not the attack anyone attempts. Attackers go around the cipher: they find the key in a repository, reuse a nonce, abuse a padding check, or steal the key from memory or a backup.

CWE-327 says to check for obsolescence periodically, since algorithms once considered strong can become unsafe, and it advises designing for crypto agility so one algorithm can be replaced by another in a future version.

Practical choices

  1. Default to AES-256 for new designs. The cost over 128 bits is small, and it avoids a later debate.
  2. Use an authenticated mode such as GCM, which OWASP names as a first preference.
  3. For RSA, use 2048 bits at the least, only where compatibility demands RSA, and use OAEP for encryption.
  4. Generate every key from a secure random source, not from a phrase. OWASP says keys should not come from common words or phrases.
  5. Make sure the key encrypting a key is as strong as the key it protects. OWASP says the KEK should be at least as strong as the DEK.

Quantum questions

You may be asked about quantum computers. That is a planning topic with its own timelines, and the right response is crypto agility and an inventory, not an abrupt key size change. See does quantum computing break AES-256 for that discussion.

Where size mistakes still happen

  • Old certificates and keys that predate your current policy.
  • Third party appliances with fixed small keys.
  • Test keys, short by design, that made it into production.
  • Derived keys, where a short password is stretched and the result looks long.

An inventory catches these. Search for key sizes below your floor and give each one an owner and a date.

Safeguard can generate an SBOM and scan your dependencies, so outdated cryptography libraries with known advisories show up in one inventory, and policies can gate a build on them. A free scan is at gold.safeguard.sh/scan.

Quick check

Is AES-128 acceptable?

OWASP lists at least 128 bits, so yes for the minimum. Many teams pick 256 to avoid reopening the question.

Does a bigger RSA key fix a bad padding choice?

No. Padding and key size solve different problems. Use OAEP for encryption regardless of size.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.