Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:44:16+00:00 2026-06-01T23:44:16+00:00

For using openSSL API for public key encryption, how is the key (public &

  • 0

For using openSSL API for public key encryption, how is the key (public & private) initialized in a C program, given private key in *.key file format, and public key in *.pem file format:

 EVP_PKEY *key;
 /* How is key initialized ?
  */
  ctx = EVP_PKEY_CTX_new(key);

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:44:18+00:00Added an answer on June 1, 2026 at 11:44 pm

    try this:

            EVP_PKEY *pkey;
            FILE *f = fopen("<path for your PEM or DER encoded key>", "rb");
            if (f == NULL){
                    // error handling...
            }
        //if your key is PEM encoded use this
            pkey = PEM_read_PUBKEY(f, NULL, NULL, NULL); // pkey now contains the pubKey. 
        //We are passing NULL to the others parameters because we dont need password to read a public key
    
        //if your key is DER encoded use this
            pkey = d2i_PUBKEY_fp(f, NULL);
    
            if (pkey == NULL){
                    // error handling...
            }
    

    I didnt test but should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I could susscessfuly genearte pkcs7 signature using PEM(private key)file in Openssl. But, how do
I'm planning to write some software using SFTP with public/private key authentication to upload
I need to create a private key using openssl in Qt and then use
I'm using OpenSSL in a program that decrypts a text file and then re-encrypts
I generate key/cert using openssl openssl.exe req -x509 -days 1000 -newkey rsa:1024 -keyout key.pem
I'm using OpenSSL's EVP_* API to implement AES encryption in CBC mode. I'm trying
I have generated using openssl mycert.pem which contents the certificate. And I converted the
I'm looking for an example of using OpenSSL's AES CCM encryption. Apparently, this is
I am trying to take an AES HMAC of a file using the openssl
I have a DSA private key exported using the DSACryptoServiceProvider.ToXmlString , and I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.