No data added into context
Performing hash operation on empty context might cause run-time errors
Since R2020a
Description
The defect occurs when you only update a message digest context with null data, or you perform a final step on a message digest context without performing any update step.
When you use message digest functions, you typically initialize a message digest context and perform at least one update step to add data into the context. You then sign, verify, or retrieve the data in the context as a final step.
The checker raises no defect if no information is available about the context. For instance, if the context is passed as an argument to the function that calls the hashing operation or if the context is declared outside the scope of the function. For example, no defect is raised in this code snippet.
void bar(unsigned char* src, int len, EVP_MD_CTX *ctx) { //ctx passed as argument of bar() EVP_DigestFinal(ctx, out_buf, &out_len); //no defect } EVP_MD_CTX glob_ctx; void foo(unsigned char* src, int len) { //glob_ctx declared outside scope of foo() EVP_DigestFinal(&glob_ctx, out_buf, &out_len); //no defect }
Risk
Performing an update step on a context with null data might result in a run-time error.
Performing a final step on a context with no data might result in unexpected behavior.
Fix
Perform at least one update operation with non-null data on a message digest context before you sign, verify, or retrieve the data in the context.
Examples
Result Information
Group: Cryptography |
Language: C | C++ |
Default: Off |
Command-Line Syntax:
CRYPTO_MD_NO_DATA |
Impact: Medium |
Version History
Introduced in R2020a
See Also
Find defects
(-checkers)
| Missing final step after hashing
update operation
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)