Algorithm selection

From RedHatProductSecurity/prodsec-skills · View interactive version

Algorithm selection is an AI agent skill from the GitHub repository RedHatProductSecurity/prodsec-skills. Apply when selecting, reviewing, or configuring cryptographic algorithms, cipher suites, protocol versions, or key exchange mechanisms. Covers banned/deprecated/recommended algorithms, post-quantum readiness, key management, and OpenSSL API migration.

How to use this skill

Skill file

Cryptographic Algorithm Selection and Post-Quantum Readiness

Reference for which cryptographic algorithms to use, which to avoid, and how to prepare for post-quantum cryptography.

Banned (Insecure) Algorithms

NEVER use these algorithms. They are cryptographically broken.

| Type | Banned |

|------|--------|

| Hash | MD2, MD4, MD5, SHA-0 |

| Symmetric | RC2, RC4, Blowfish, DES, 3DES |

| Key Exchange | Static RSA, Anonymous Diffie-Hellman |

Deprecated (Legacy/Weak) Algorithms

Avoid in new designs. Prioritize migration away from these.

| Type | Deprecated | Issue |

|------|-----------|-------|

| Hash | SHA-1 | Collision attacks demonstrated |

| Symmetric | AES-CBC, AES-ECB | Unauthenticated; ECB leaks patterns |

| Signature | RSA with PKCS#1 v1.5 padding | Padding oracle attacks |

| Key Exchange | DHE with weak/common primes | Vulnerable to precomputation attacks |

Recommended and Post-Quantum Ready Algorithms

Symmetric Encryption

Key Exchange (KEM)

Signatures and Certificates

Protocol Versions

Secure Implementation Guidelines

General Best Practices

Deprecated OpenSSL APIs (C/C++)

Never use these deprecated functions. Use the EVP high-level APIs.

| Deprecated | Replacement |

|-----------|-------------|

| AES_encrypt(), AES_decrypt() | EVP_EncryptInit_ex() with EVP_aes_256_gcm() |

| RSA_new(), RSA_free(), RSA_get0_n() | EVP_PKEY_new(), EVP_PKEY_free() |

| SHA1_Init() | EVP_DigestInit_ex() with SHA-256 or stronger |

| HMAC() with SHA-1 | EVP_Q_MAC() with SHA-256 or stronger |

AES-256-GCM Example (C/OpenSSL)

EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
if (!ctx) handle_error();

if (EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, key, iv) != 1)
    handle_error();

int len, ciphertext_len;
if (EVP_EncryptUpdate(ctx, ciphertext, &len, plaintext, plaintext_len) != 1)
    handle_error();
ciphertext_len = len;

if (EVP_EncryptFinal_ex(ctx, ciphertext + len, &len) != 1)
    handle_error();
ciphertext_len += len;

EVP_CIPHER_CTX_free(ctx);

HMAC-SHA256 Example (C/OpenSSL)

EVP_Q_MAC(NULL, "HMAC", NULL, "SHA256", NULL,
          key, key_len, data, data_len,
          out, out_size, &out_len);

Implementation Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.