Missing public key
Context used for cryptography operation is associated with NULL public key or not associated with a public key at all
Description
This defect occurs when you use a context object for encryption or signature authentication but you have not previously associated the object with a non-NULL public key.
For instance, you initialize the context object with a NULL public key and use the object for encryption later.
ctx = EVP_PKEY_CTX_new(pkey, NULL); ... ret = EVP_PKEY_encrypt_init(ctx); ... ret = EVP_PKEY_encrypt(ctx, out, &out_len, in, in_len);
The counterpart checker Missing private
key
checks for a private key in decryption and signature
operations.
Risk
Without a public key, the encryption or signature authentication step does not happen. The redundant operation often indicates a coding error.
Fix
Check the placement of the operation (encryption or signature authentication). If the operation is intended to happen, make sure you have done these steps prior to the operation:
You generated a non-NULL public key.
For instance:
EVP_PKEY *pkey = NULL; kctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL); EVP_PKEY_keygen_init(kctx); EVP_PKEY_CTX_set_rsa_keygen_bits(kctx, RSA_2048BITS); EVP_PKEY_keygen(kctx, &pkey);
You associated a non-NULL context object with the public key.
For instance:
ctx = EVP_PKEY_CTX_new(pkey, NULL);
Note: If you use
EVP_PKEY_CTX_new_id
instead ofEVP_PKEY_CTX_new
, you are not associating the context object with a public key.
Examples
Result Information
Group: Cryptography |
Language: C | C++ |
Default: Off |
Command-Line Syntax:
CRYPTO_PKEY_NO_PUBLIC_KEY |
Impact: Medium |
Version History
Introduced in R2018a
See Also
Context
initialized incorrectly for cryptographic operation
| Incorrect key for
cryptographic algorithm
| Missing data for
encryption, decryption or signing
| Missing
parameters for key generation
| Missing peer
key
| Missing private
key
| Nonsecure
parameters for key generation
| Find defects (-checkers)
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)