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 6763439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:28:34+00:00 2026-05-26T14:28:34+00:00

Trying to generate an RSA Public Key given an APIs modulus and exponent. I’m

  • 0

Trying to generate an RSA Public Key given an APIs modulus and exponent. I’m using OpenSSL on iOS 4.2.

Generating the public key manually is an option (see below) however i’m not sure how to include the exponent logic in the modulus

-----BEGIN PUBLIC KEY-----
Modulus from API
-----END PUBLIC KEY-----

Based on @James comments, I am able to write public pem but getting blank private key. Here is my code:

char szModulus = "1162" ;
char *szExp = "827655" ;
RSA* rsa = RSA_new();
int ret = BN_hex2bn(&rsa->n,szModulus) ;
ret = BN_hex2bn(&rsa->d,szExp) ;
FILE *fp = fopen("/Users/ysi/Desktop/privateKey.pem", "wb"); 
PEM_write_RSAPrivateKey(fp, rsa, NULL, NULL, 0, 0, NULL);
  • 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-05-26T14:28:34+00:00Added an answer on May 26, 2026 at 2:28 pm

    To do this make sure you have the OpenSSL library linked (instructions here http://code.google.com/p/ios-static-libraries/)

    Once linked you’ll have access to several BIGNUM converters. I turned the modulus into hex using the BN_hex2bn method saving the hex string into ‘exponent’

    Then create the BIGNUM struct and encrypt using RSA_public_encrypt

    RSA *rsa = NULL;
    
    rsa->n = BN_new();
    BN_copy(rsa->n,modulus);   
    rsa->e = BN_new();
    BN_copy(rsa->e,exponent);     
    rsa->iqmp=NULL;
    rsa->d=NULL;
    rsa->p=NULL;
    rsa->q=NULL;
    

    Good Luck!

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

Sidebar

Related Questions

I've been trying for a while to generate an RSA keypair using PHP's openssl
I'm trying to read a RSA public key generated with openssl like this: Private
I am trying to create my public/private rsa key pair with msysgit I run
In .NET I have generated the following public key file: <RSAKeyValue> <Modulus>xTSiS4+I/x9awUXcF66Ffw7tracsQfGCn6g6k/hGkLquHYMFTCYk4mOB5NwLwqczwvl8HkQfDShGcvrm47XHKUzA8iadWdA5n4toBECzRxiCWCHm1KEg59LUD3fxTG5ogGiNxDj9wSguCIzFdUxBYq5ot2J4iLgGu0qShml5vwk=</Modulus> <Exponent>AQAB</Exponent> </RSAKeyValue>
I'm trying to generate RSA keypairs in Ruby, mostly using the examples from this
I'm trying to import an RSA public/private key pair generated with the Win32 Crypto
I am trying to implement OpenSSL RSA, following is my code for Key generation
I have the following code below to generate an OpenSSL RSA public and private
I'm trying to generate code coverage reports with EMMA using tests of which some
Im trying to generate a week view calendar using codeigniter's calendar library.. something like

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.