openssl / openssl/openssl

d2i_KeyParams(EVP_PKEY_DHX, ...) should create provided pkeys instead of legacy pkeys

Open
#16,896 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

branch: master triaged: feature
Dominant language
C
Stars
30.8k
Forks
11.5k
Avg merge
10m
Merged PRs (30d)
1

Description

In the attached C program, d2i_KeyParams() is used to create a DHX key, and then we attempt to retrieve the p parameter with EVP_PKEY_get_bn_param().

This fails because (1) we are shunted into the legacy path by the lack of a keymgmt field in the returned key, and (2) there appears to be DH support but not DHX support in the legacy path. Setting the public key with EVP_PKEY_set1_encoded_public_key() also fails because dhx_pkey_ctrl() returns -2 on all inputs.

I did find an alternative way to read RFC 3279 DomainParameters which provides a functional EVP_PKEY: OSSL_DECODER_CTX_new_for_pkey(&pkey, "DER", "type-specific", "DHX", EVP_PKEY_KEY_PARAMETERS, NULL, NULL) and OSSL_DECODER_from_data(). But it seems like d2i_KeyParams() should also work.

minimal.c.txt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached minimal.c.txt and reproduce the d2i_KeyParams() failure when retrieving the DHX p parameter or setting the encoded public key. Compare that path with the working OSSL_DECODER_CTX_new_for_pkey() and OSSL_DECODER_from_data() route. Done means d2i_KeyParams() returns a usable DHX EVP_PKEY with parameter retrieval and public-key setting working.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cryptography
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.