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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:21:31+00:00 2026-06-05T14:21:31+00:00

Using BounceCastle I have the following code working. It generates a keypair and return

  • 0

Using BounceCastle I have the following code working.
It generates a keypair and return the ASN.1 DER-encoded format.

//Generate new key
var generator = new RsaKeyPairGenerator ();
generator.Init (new KeyGenerationParameters (new SecureRandom (), 1024));
var keyPair = generator.GenerateKeyPair ();

//Save private key for later use
keyParameters = (RsaKeyParameters)keyPair.Private;

//Export ASN.1 DER-encoded
SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(keyPair.Public);
return info.GetEncoded ();

It has been tested and works with third party software.

My question is: how can I make the inverse of the above encoding.
Having the encoded public key, how do I get the public key into a RsaKeyParameters.

I guess I’m about to do something similar to this.

SubjectPublicKeyInfo s = new SubjectPublicKeyInfo(????, publicKeyBytes);
RsaKeyParameters key = (RsaKeyParameters)PublicKeyFactory.CreateKey(s);

So if this is close I need to know what to put in ????, it expects an object of type AlgorithmIdentifier.

  • 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-05T14:21:33+00:00Added an answer on June 5, 2026 at 2:21 pm

    Thanks to this answer I got the following code:

            AsymmetricKeyParameter asymmetricKeyParameter = PublicKeyFactory.CreateKey(req.PublicKey);
            RsaKeyParameters key = (RsaKeyParameters) asymmetricKeyParameter;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some (functional) AES encryption code using Java's built in encryption libraries,
I need a RSA public key encoded into DER format. The key-pair is generated
I'm trying to encrypt files using my private key (in ascii format) and any
using Org.BouncyCastle.Math; string p = E7A69EBDF105F2A6BBDEAD7E798F76A209AD73FB466431E2E7352ED262F8C558F10BEFEA977DE9E21DCEE9B04D245F300ECCBBA03E72630556D011023F9E857F; BigInteger P= new BigInteger(p); throwing Exception System.FormatException: Input
I create a certificate using BouncyCastle var keypairgen = new RsaKeyPairGenerator(); keypairgen.Init(new KeyGenerationParameters(new SecureRandom(new
Currently I'm using the BouncyCastle library to generate a certificate. Something like this: X509V3CertificateGenerator
I have a function that generates a BouncyCastle RSA key pair. I need to
I need to generate a PKCS12 file using Java. Actually, I need to automate
This is the code I'm currently using. It uses the BouncyCastle Provider. static {
I have a Problem with checking an XMLSignature using BouncyCastle for verifying Sigantures that

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.