bc rsa key gen vs. common rsa key gen

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

bc rsa key gen vs. common rsa key gen

Hérikz Nawarro
Hello everyone,

Whats the difference between bc rsa key gen (RSAKeyPairGenerator) and
a common a rsa key gen (like below)?

public void keyGen(int nbits){
     nb_bits=nbits;
     params=new Parameters(this.nb_bits);
     BigInteger p = getPrime((params.getNb_bits()/2),params.getPrg());
     BigInteger q = getPrime((params.getNb_bits()/2),params.getPrg());
     BigInteger n = p.multiply(q);
     BigInteger e = new BigInteger("65537");
     BigInteger totient =
p.subtract(BigInteger.ONE).multiply((q.subtract(BigInteger.ONE)));
     BigInteger d = e.modInverse(totient);

     PubKey pk = new PubKey(n,e);
     PrivKey sk = new PrivKey(d,p,q);
}

thanks.

Reply | Threaded
Open this post in threaded view
|

RE: bc rsa key gen vs. common rsa key gen

Eckenfels. Bernd
Hello,

For one it uses half a bit more keylength and some other safety constraints:

http://grepcode.com/file/repo1.maven.org/maven2/org.bouncycastle/bcprov-jdk15on/1.52/org/bouncycastle/crypto/generators/RSAKeyPairGenerator.java#28

41             int pbitlength = (strength + 1) / 2;
42             int qbitlength = strength - pbitlength;
43             int mindiffbits = strength / 3;
44             int minWeight = strength >> 2;

You might want to tell us why you ask.

Gruss
Bernd
--
http://www.seeburger.com
________________________________________
From: Hérikz Nawarro [[hidden email]]
Sent: Monday, June 05, 2017 19:07
To: [hidden email]
Subject: [dev-crypto] bc rsa key gen vs. common rsa key gen

Hello everyone,

Whats the difference between bc rsa key gen (RSAKeyPairGenerator) and
a common a rsa key gen (like below)?

public void keyGen(int nbits){
     nb_bits=nbits;
     params=new Parameters(this.nb_bits);
     BigInteger p = getPrime((params.getNb_bits()/2),params.getPrg());
     BigInteger q = getPrime((params.getNb_bits()/2),params.getPrg());
     BigInteger n = p.multiply(q);
     BigInteger e = new BigInteger("65537");
     BigInteger totient =
p.subtract(BigInteger.ONE).multiply((q.subtract(BigInteger.ONE)));
     BigInteger d = e.modInverse(totient);

     PubKey pk = new PubKey(n,e);
     PrivKey sk = new PrivKey(d,p,q);
}

thanks.








SEEBURGER AG            Vorstand/SEEBURGER Executive Board:
Sitz der Gesellschaft/Registered Office:                Axel Haas, Michael Kleeberg, Friedemann Heinz, Dr. Martin Kuntz, Matthias Feßenbecker
Edisonstr. 1
D-75015 Bretten         Vorsitzende des Aufsichtsrats/Chairperson of the SEEBURGER Supervisory Board:
Tel.: 07252 / 96 - 0            Prof. Dr. Simone Zeuchner
Fax: 07252 / 96 - 2222
Internet: http://www.seeburger.de               Registergericht/Commercial Register:
e-mail: [hidden email]               HRB 240708 Mannheim


Dieses E-Mail ist nur für den Empfänger bestimmt, an den es gerichtet ist und kann vertrauliches bzw. unter das Berufsgeheimnis fallendes Material enthalten. Jegliche darin enthaltene Ansicht oder Meinungsäußerung ist die des Autors und stellt nicht notwendigerweise die Ansicht oder Meinung der SEEBURGER AG dar. Sind Sie nicht der Empfänger, so haben Sie diese E-Mail irrtümlich erhalten und jegliche Verwendung, Veröffentlichung, Weiterleitung, Abschrift oder jeglicher Druck dieser E-Mail ist strengstens untersagt. Weder die SEEBURGER AG noch der Absender (Eckenfels. Bernd) übernehmen die Haftung für Viren; es obliegt Ihrer Verantwortung, die E-Mail und deren Anhänge auf Viren zu prüfen.


This email is intended only for the recipient(s) to whom it is addressed. This email may contain confidential material that may be protected by professional secrecy. Any fact or opinion contained, or expression of the material herein, does not necessarily reflect that of SEEBURGER AG. If you are not the addressee or if you have received this email in error, any use, publication or distribution including forwarding, copying or printing is strictly prohibited. Neither SEEBURGER AG, nor the sender (Eckenfels. Bernd) accept liability for viruses; it is your responsibility to check this email and its attachments for viruses.