-2
OSSL_STORE_CTX *ctx = OSSL_STORE_open(tpm_key_path, nullptr, nullptr, nullptr, nullptr);

OSSL_STORE_INFO *info;

while (!OSSL_STORE_eof(ctx)) { if ((info = OSSL_STORE_load(ctx)) == nullptr) { printf("Failed in OSSL_STORE_load : %d",res); } if ((key = OSSL_STORE_INFO_get1_PKEY(info)) == nullptr) { printf("Failed in OSSL_STORE_INFO_get1_PKEY : %d",res); } break; }

if(key) { if (ctx) { EVP_PKEY_decrypt_init(ctx); EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, NULL) EVP_PKEY_CTX_set_rsa_padding(ctx, padding); } }

error: cannot convert ‘OSSL_STORE_CTX*’ {aka ‘ossl_store_ctx_st*’} to ‘EVP_PKEY_CTX*’ {aka ‘evp_pkey_ctx_st*’} 335 | EVP_PKEY_decrypt_init(ctx); | ^~~ | | | OSSL_STORE_CTX* {aka ossl_store_ctx_st*}

Mike
  • 4,041
  • 6
  • 20
  • 37
vidyadhar
  • 1
  • 1
  • Please fix your code formatting, this is impossible to read. (And it looks like you might have a semicolon missing, which makes me wonder if this is your actual code or not). – pmacfarlane May 12 '23 at 09:22

1 Answers1

0

You need to use EVP_PKEY_CTX_new to create a EVP_PKEY_CTX* from the EVP_PKEY* value.

e.g.

EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new(key, nullptr);
if (pctx)
{
    EVP_PKEY_decrypt_init(pctx);
Shane Powell
  • 13,698
  • 2
  • 49
  • 61