proj home

Files   Classes   Functions   Hierarchy  

rsaGenKey Class Reference

Key Generation. More...

#include <rsa.h>

Collaboration diagram for rsaGenKey:

List of all members.

Public Member Functions

 rsaGenKey (uintc _nbits)
 Randomly generate key.
 rsaGenKey (uintc _nbits, string const &_p, string const &_q)
 Sequentially generate key.
void print () const
 Prints the state, for debug purposes.

Public Attributes

uintc nbits
 The number of bits.
uint blocksize
 The block size.
ZZ p
 The secret factor p.
ZZ q
 The secret factor q.
ZZ e
 The public exponent e.
ZZ n
 The public product p*q.
ZZ n2
 The secret (p-1)*(q-1).


Detailed Description

Key Generation.

There are two ways to generate keys, these are accessed by two different constructor calls.

The result is two files generated, encrypt.txt and decrypt.txt . The encrypt.txt sould be public, but the decrypt.txt must be private because it contains the key.

Definition at line 77 of file rsa.h.


Constructor & Destructor Documentation

rsaGenKey::rsaGenKey ( uintc  _nbits  ) 

Randomly generate key.

Definition at line 112 of file rsa.cpp.

References largePrimeGenerator::findprime_randomly(), nbits, and p.

00113   : nbits(_nbits)
00114 {
00115   assert(nbits>10);  // Really want large primes!
00116 
00117   lpg.findprime_randomly(p,nbits);
00118   lpg.findprime_randomly(q,nbits);
00119  
00120   genkey();
00121 }

rsaGenKey::rsaGenKey ( uintc  _nbits,
string const &  _p,
string const &  _q 
)

Sequentially generate key.

Definition at line 67 of file rsa.cpp.

00072   : nbits(_nbits)
00073 {
00074   conv(p,_p.c_str());
00075   conv(q,_q.c_str());
00076 
00077   lpg.findprime_sequentially(p,nbits);
00078   lpg.findprime_sequentially(q,nbits);
00079 
00080   genkey();
00081 }


Member Function Documentation

void rsaGenKey::print (  )  const

Prints the state, for debug purposes.

Definition at line 123 of file rsa.cpp.

References blocksize, e, n, n2, nbits, p, and SHOW.

00124 {
00125   cout << SHOW(p) << endl;
00126   cout << SHOW(q) << endl;
00127   cout << SHOW(e) << endl;
00128   cout << SHOW(n) << endl;
00129   cout << SHOW(n2) << endl;
00130   cout << SHOW(nbits) << endl;
00131   cout << SHOW(blocksize) << endl;
00132 }


Member Data Documentation

The block size.

Definition at line 104 of file rsa.h.

Referenced by print().

The public exponent e.

Definition at line 111 of file rsa.h.

Referenced by print().

The public product p*q.

Definition at line 113 of file rsa.h.

Referenced by print().

The secret (p-1)*(q-1).

Definition at line 115 of file rsa.h.

Referenced by print().

The number of bits.

Definition at line 101 of file rsa.h.

Referenced by print(), and rsaGenKey().

The secret factor p.

Definition at line 107 of file rsa.h.

Referenced by print(), and rsaGenKey().

The secret factor q.

Definition at line 109 of file rsa.h.


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:16 2011 for Chelton Evans Source by  doxygen 1.5.8