Missing peer key
Context used for shared secret derivation is associated with NULL peer key or not associated with a peer key at all
Description
This defect occurs when you use a context object for shared secret derivation but you have not previously associated the object with a non-NULL peer key.
For instance, you initialize the context object, and then use the object for shared secret derivation without an intermediate step where the object is associated with a peer key:
EVP_PKEY_derive_init(ctx); /* Missing step for associating peer key with context */ ret = EVP_PKEY_derive(ctx, out_buf, &out_len);
The counterpart checker Missing private
key
checks for a private key in shared secret derivation.
Risk
Without a peer key, the shared secret derivation step does not occur. The redundant operation often indicates a coding error.
Fix
Check the placement of the shared secret derivation step. If the operation is intended, make sure that you have completed these steps prior to the operation:
Generate a non-NULL peer key.
For instance:
EVP_PKEY* peerkey = NULL; EVP_PKEY_keygen(EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL), &peerkey);
Associate a non-NULL context object with the peer key.
For instance:
EVP_PKEY_derive_set_peer(ctx,peerkey);
Examples
Result Information
Group: Cryptography |
Language: C | C++ |
Default: Off |
Command-Line Syntax:
CRYPTO_PKEY_NO_PEER |
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 private
key
| Missing public
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)