An encryption or decryption algorithm is not associated with the cipher context
This defect occurs when you do not assign a cipher algorithm when setting up your cipher context.
You can initialize your cipher context without an algorithm. However, before you encrypt or decrypt your data, you must associate the cipher context with a cipher algorithm.
A missing cipher algorithm can lead to run-time errors or at least, non-secure ciphertext.
Before encryption or decryption, you set up a cipher context that has the information required for encryption: the cipher algorithm and mode, an encryption or decryption key and an initialization vector (for modes that require initialization vectors).
ret = EVP_EncryptInit(&ctx, EVP_aes_128_cbc(), key, iv)
EVP_aes_128_cbc() specifies that the Advanced
Encryption Standard (AES) algorithm must be used for encryption. The
function also specifies a block size of 128 bits and the Cipher Bloch
Chaining (CBC) mode.Instead of specifying the algorithm, you can use NULL in the initialization step. However, before using the cipher context for encryption or decryption, you must perform an additional initialization that associates an algorithm with the context. Otherwise, the update steps for encryption or decryption can lead to run-time errors.
Before your encryption or decryption steps
ret = EVP_EncryptUpdate(&ctx, out_buf, &out_len, src, len)
ctx with an algorithm.ret = EVP_EncryptInit(ctx, EVP_aes_128_cbc(), key, iv)
| Group: Cryptography |
| Language: C | C++ |
| Default: Off |
Command-Line Syntax: CRYPTO_CIPHER_NO_ALGORITHM |
| Impact: Medium |
| CWE ID: 310, 573 |