Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / August 2003

Tip: Looking for answers? Try searching our database.

RSA key size

Thread view: 
Sijo Mathew - 18 Aug 2003 07:46 GMT
Hi all,

The following program creates an RSA key pair and prints
the length of its public key modulus. Eventhough I have
initialized its size as 1024(128 bytes), the printed length is
129. What is behind this behavoiur..?

public static void main(String args[]){
   KeyPairGenerator kpg = null ;
   try{
       kpg = KeyPairGenerator.getInstance("RSA");
       kpg.initialize(1024);
   }catch(Exception e){
       e.printStackTrace();
   }
   KeyPair kp = kpg.genKeyPair();
   RSAPublicKey puKey = (RSAPublicKey)kp.getPublic();
   System.out.println("Key
Length:"+puKey.getModulus().toByteArray().length);
}

regards
Sijo
Roedy Green - 18 Aug 2003 22:35 GMT
> Eventhough I have
>initialized its size as 1024(128 bytes), the printed length is
>129. What is behind this behavoiur..?

is there simply a lead 0 byte? Perhaps it is there just to ensure the
number is treated as positive.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.