Missing cipher algorithm
An encryption or decryption algorithm is not associated with the cipher context
Description
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.
Risk
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.
Fix
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)
Examples
Result Information
Group: Cryptography |
Language: C | C++ |
Default: Off |
Command-Line Syntax: CRYPTO_CIPHER_NO_ALGORITHM |
Impact: Medium |
Version History
Introduced in R2017a
See Also
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)