exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

rsa-keygen.html

rsa-keygen.html
Posted Dec 21, 1999

rsa-keygen.html

tags | encryption
SHA-256 | 1d90667889fea3ff54bdfd78afd95923ceca86decf8828ad533dd820acc54d8f

rsa-keygen.html

Change Mirror Download
<HTML>
<HEAD>
<TITLE>Generating RSA keys</TITLE>
</HEAD>
<BODY>

<H1>Generating RSA keys</H1>

Some C code kindly donated by Aggelos Keromitis
<A HREF="mailto:kermit@forthnet.gr"><kermit@forthnet.gr></A>

<HR>

<UL>
<LI> <A HREF="rsakg.c">rsakg.c</A> source listing

<LI> and the gmp-1.3.2.tar.gz GNU mp library (required, get from
gnu distribution site).
</UL>

<HR>

<H2>Compiling the gmp library</H2>

This is real easy to install just do:

<PRE>

% gzip -d gmp-1.3.2.tar.gz | tar xf
% cd gmp-1.3.2
% make

</PRE>

Thats it!

<H2>Compiling Aggelos rsakg.c</H2>

Copy the <A HREF="rsakg.c">rsakg.c</A> file into the gmp-1.3.2 directory.

<PRE>

% cd gmp-1.3.2
% cc -o rsakg rsakg.c -L./ -lgmp

</PRE>

Copy your rsakg binary to where ever you keep your binaries and add/or
it your search path.

<H2>Using Aggelos rsakg</H2>

It now takes key sizes in bits so to generate a 512 bit key you would
do:

<PRE>

% rsakg 512

</PRE>

It will generate 2 files pubkey.rsa and seckey.rsa (may take it a
minute or so depending on the speed of your machine) it should say:

<PRE>
Got one prime.
Got second prime.
written public key to "pubkey.rsa"
written secret key to "seckey.rsa"
</PRE>

as it runs.

<P>
then take a look at "pubkey.rsa":

<PRE>
e = 7f82b84bde3432563ea37745f9a01d859e41f0fb7eb9cf781f6f204266ec55087aaaa60dc4df6e50266b1957031515a08813fa0f1ee6aa377d915e352958eb5
n = ca870534aca46382c1f41530e526af108dcd6bf3d0a3e200b51c1844e315b5a73622b6129ffd9d2e299256a33f922961a702de46c584fc141204f74d8065b8d
</PRE>

and the "seckey.rsa":

<PRE>
d = 3fd15c1ec184d27bb5e692608b2526c627f5149ad269a443ba72e39ab0fd4114dbaceee8c385e64edbfd215d45267de6a81bf0f17b55abb293617a2910b602d
n = ca870534aca46382c1f41530e526af108dcd6bf3d0a3e200b51c1844e315b5a73622b6129ffd9d2e299256a33f922961a702de46c584fc141204f74d8065b8d
</PRE>

<P>

The e (public key exponent) and n (RSA modulus) numbers are your public key.

<P>

And the d (secret key exponent) number is your secret key, dont show
anyone your d number!

<P>

Okay to use with perl-rsa you just use the numbers like this (msg
being some data file you want to encrypt we encrypt the message
"squeamish ossifrage" here):

<PRE>
% echo squeamish ossifrage > msg
% rsa -k=[e] -n=[n] < msg > msg.rsa
</PRE>

Then to decrypt (to the screen):

<PRE>
% rsa -d -k=[d] -n=[n] < msg.rsa
</PRE>

Where [e] [n] and [d] are the huge numbers in seckey.rsa and
pubkey.rsa with those names, ie so you can cut and paste these into
your shell:

<p>
encrypt:

<PRE>
% echo squeamish ossifrage > msg
% rsa -k=7f82b84bde3432563ea37745f9a01d859e41f0fb7eb9cf781f6f204266ec55087aaaa60dc4df6e50266b1957031515a08813fa0f1ee6aa377d915e352958eb5 -n=ca870534aca46382c1f41530e526af108dcd6bf3d0a3e200b51c1844e315b5a73622b6129ffd9d2e299256a33f922961a702de46c584fc141204f74d8065b8d < msg > msg.rsa
</PRE>

<P>

decrypt:

<PRE>
% rsa -d -k=3fd15c1ec184d27bb5e692608b2526c627f5149ad269a443ba72e39ab0fd4114dbaceee8c385e64edbfd215d45267de6a81bf0f17b55abb293617a2910b602d -n=ca870534aca46382c1f41530e526af108dcd6bf3d0a3e200b51c1844e315b5a73622b6129ffd9d2e299256a33f922961a702de46c584fc141204f74d8065b8d < msg.rsa
</PRE>

<H2>Choosing small public key exponents</H2>

You may have noticed that some of the examples use a small number for
the public key exponent, PGP can do this because of the way it
combines RSA with IDEA but if you are interested in security you
shouldn't use small public exponents with pure RSA as it weakens the
security somewhat. If you want to do it anyway, just to play with the
numbers, or if you know what you're doing and are combining it with
something else then you can generate them like this.

<P>

Just give rsakg a second argument which is your choice of public
exponent. (This is usally quite small: PGP typically chooses 17 or
19, but you could choose 3 or 5 or whatever it's still going to work)

<PRE>
% rsakg 512 17
</PRE>

<HR>
<EM>
Comments, html bugs to me
(<A HREF="http://www.dcs.ex.ac.uk/~aba/">Adam Back</A>) at
<A HREF="mailto:aba@dcs.ex.ac.uk"><aba@dcs.ex.ac.uk></A>
</EM>
</BODY>
</HTML>
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close