Java RSA private key generation when public key is known











up vote
-6
down vote

favorite












Is there a way to generate a RSA private key in java, when the public key is known, say 3 ?



I can't find a way to do this with Class KeyPairGenerator, from java.security package...



my question is very simple, I'm not looking for info related to cryptography.
Just want to know, if I have the public exponent for RSA, is there a way in java to get the private exponent, for that public exponent, for a given modulus length , e.g. 2048?
This should shed some light on the topic:
https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Key_generation
https://en.wikipedia.org/wiki/65,537










share|improve this question
























  • what code have you tried so far ? why is it not working ? what have you searched for (libs ?)?
    – LoneWanderer
    Nov 11 at 23:15










  • An RSA public key consist and an exponent and a modulus.
    – James K Polk
    Nov 12 at 3:49

















up vote
-6
down vote

favorite












Is there a way to generate a RSA private key in java, when the public key is known, say 3 ?



I can't find a way to do this with Class KeyPairGenerator, from java.security package...



my question is very simple, I'm not looking for info related to cryptography.
Just want to know, if I have the public exponent for RSA, is there a way in java to get the private exponent, for that public exponent, for a given modulus length , e.g. 2048?
This should shed some light on the topic:
https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Key_generation
https://en.wikipedia.org/wiki/65,537










share|improve this question
























  • what code have you tried so far ? why is it not working ? what have you searched for (libs ?)?
    – LoneWanderer
    Nov 11 at 23:15










  • An RSA public key consist and an exponent and a modulus.
    – James K Polk
    Nov 12 at 3:49















up vote
-6
down vote

favorite









up vote
-6
down vote

favorite











Is there a way to generate a RSA private key in java, when the public key is known, say 3 ?



I can't find a way to do this with Class KeyPairGenerator, from java.security package...



my question is very simple, I'm not looking for info related to cryptography.
Just want to know, if I have the public exponent for RSA, is there a way in java to get the private exponent, for that public exponent, for a given modulus length , e.g. 2048?
This should shed some light on the topic:
https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Key_generation
https://en.wikipedia.org/wiki/65,537










share|improve this question















Is there a way to generate a RSA private key in java, when the public key is known, say 3 ?



I can't find a way to do this with Class KeyPairGenerator, from java.security package...



my question is very simple, I'm not looking for info related to cryptography.
Just want to know, if I have the public exponent for RSA, is there a way in java to get the private exponent, for that public exponent, for a given modulus length , e.g. 2048?
This should shed some light on the topic:
https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Key_generation
https://en.wikipedia.org/wiki/65,537







java rsa key-generator






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 14:31

























asked Nov 11 at 23:07









user2283315

12




12












  • what code have you tried so far ? why is it not working ? what have you searched for (libs ?)?
    – LoneWanderer
    Nov 11 at 23:15










  • An RSA public key consist and an exponent and a modulus.
    – James K Polk
    Nov 12 at 3:49




















  • what code have you tried so far ? why is it not working ? what have you searched for (libs ?)?
    – LoneWanderer
    Nov 11 at 23:15










  • An RSA public key consist and an exponent and a modulus.
    – James K Polk
    Nov 12 at 3:49


















what code have you tried so far ? why is it not working ? what have you searched for (libs ?)?
– LoneWanderer
Nov 11 at 23:15




what code have you tried so far ? why is it not working ? what have you searched for (libs ?)?
– LoneWanderer
Nov 11 at 23:15












An RSA public key consist and an exponent and a modulus.
– James K Polk
Nov 12 at 3:49






An RSA public key consist and an exponent and a modulus.
– James K Polk
Nov 12 at 3:49














2 Answers
2






active

oldest

votes

















up vote
4
down vote













The whole point of public-key cryptography is that the private key remains secret. If there would be a way to easily generate a private key from a public key the encryption schema would be broken.



Yes, you can probably brute-force the private key but it won't be easy:




The strength of a public key cryptography system relies on the computational effort (work factor in cryptography) required to find the private key from its paired public key. Effective security only requires keeping the private key private; the public key can be openly distributed without compromising security.







share|improve this answer




























    up vote
    0
    down vote



    accepted










    Sort answer is "no".



    Long answer is to use sunrsasign Provider, which implements RSAKeyPairGenerator such that the public exponent is 65537:
    *"/**
    * RSA keypair generation. Standard algorithm, minimum key length 512 bit.
    * We generate two random primes until we find two where phi is relative
    * prime to the public exponent. Default exponent is 65537. It has only bit 0
    * and bit 4 set, which makes it particularly efficient.
    **/*



    if you want a different public exponent you need to create your own provider and integrate it with JCA.






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254147%2fjava-rsa-private-key-generation-when-public-key-is-known%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      4
      down vote













      The whole point of public-key cryptography is that the private key remains secret. If there would be a way to easily generate a private key from a public key the encryption schema would be broken.



      Yes, you can probably brute-force the private key but it won't be easy:




      The strength of a public key cryptography system relies on the computational effort (work factor in cryptography) required to find the private key from its paired public key. Effective security only requires keeping the private key private; the public key can be openly distributed without compromising security.







      share|improve this answer

























        up vote
        4
        down vote













        The whole point of public-key cryptography is that the private key remains secret. If there would be a way to easily generate a private key from a public key the encryption schema would be broken.



        Yes, you can probably brute-force the private key but it won't be easy:




        The strength of a public key cryptography system relies on the computational effort (work factor in cryptography) required to find the private key from its paired public key. Effective security only requires keeping the private key private; the public key can be openly distributed without compromising security.







        share|improve this answer























          up vote
          4
          down vote










          up vote
          4
          down vote









          The whole point of public-key cryptography is that the private key remains secret. If there would be a way to easily generate a private key from a public key the encryption schema would be broken.



          Yes, you can probably brute-force the private key but it won't be easy:




          The strength of a public key cryptography system relies on the computational effort (work factor in cryptography) required to find the private key from its paired public key. Effective security only requires keeping the private key private; the public key can be openly distributed without compromising security.







          share|improve this answer












          The whole point of public-key cryptography is that the private key remains secret. If there would be a way to easily generate a private key from a public key the encryption schema would be broken.



          Yes, you can probably brute-force the private key but it won't be easy:




          The strength of a public key cryptography system relies on the computational effort (work factor in cryptography) required to find the private key from its paired public key. Effective security only requires keeping the private key private; the public key can be openly distributed without compromising security.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 at 23:21









          Karol Dowbecki

          15.3k82747




          15.3k82747
























              up vote
              0
              down vote



              accepted










              Sort answer is "no".



              Long answer is to use sunrsasign Provider, which implements RSAKeyPairGenerator such that the public exponent is 65537:
              *"/**
              * RSA keypair generation. Standard algorithm, minimum key length 512 bit.
              * We generate two random primes until we find two where phi is relative
              * prime to the public exponent. Default exponent is 65537. It has only bit 0
              * and bit 4 set, which makes it particularly efficient.
              **/*



              if you want a different public exponent you need to create your own provider and integrate it with JCA.






              share|improve this answer

























                up vote
                0
                down vote



                accepted










                Sort answer is "no".



                Long answer is to use sunrsasign Provider, which implements RSAKeyPairGenerator such that the public exponent is 65537:
                *"/**
                * RSA keypair generation. Standard algorithm, minimum key length 512 bit.
                * We generate two random primes until we find two where phi is relative
                * prime to the public exponent. Default exponent is 65537. It has only bit 0
                * and bit 4 set, which makes it particularly efficient.
                **/*



                if you want a different public exponent you need to create your own provider and integrate it with JCA.






                share|improve this answer























                  up vote
                  0
                  down vote



                  accepted







                  up vote
                  0
                  down vote



                  accepted






                  Sort answer is "no".



                  Long answer is to use sunrsasign Provider, which implements RSAKeyPairGenerator such that the public exponent is 65537:
                  *"/**
                  * RSA keypair generation. Standard algorithm, minimum key length 512 bit.
                  * We generate two random primes until we find two where phi is relative
                  * prime to the public exponent. Default exponent is 65537. It has only bit 0
                  * and bit 4 set, which makes it particularly efficient.
                  **/*



                  if you want a different public exponent you need to create your own provider and integrate it with JCA.






                  share|improve this answer












                  Sort answer is "no".



                  Long answer is to use sunrsasign Provider, which implements RSAKeyPairGenerator such that the public exponent is 65537:
                  *"/**
                  * RSA keypair generation. Standard algorithm, minimum key length 512 bit.
                  * We generate two random primes until we find two where phi is relative
                  * prime to the public exponent. Default exponent is 65537. It has only bit 0
                  * and bit 4 set, which makes it particularly efficient.
                  **/*



                  if you want a different public exponent you need to create your own provider and integrate it with JCA.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 19 at 12:54









                  user2283315

                  12




                  12






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254147%2fjava-rsa-private-key-generation-when-public-key-is-known%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Florida Star v. B. J. F.

                      Error while running script in elastic search , gateway timeout

                      Adding quotations to stringified JSON object values