Givaro
Public Types | Public Member Functions | Data Fields | Protected Attributes
IntRSADom< RandIter > Class Template Reference

RSA domain. More...

#include <givintrsa.h>

+ Inheritance diagram for IntRSADom< RandIter >:
+ Collaboration diagram for IntRSADom< RandIter >:

Public Types

typedef IntFactorDom< RandIter >
::Element 
Element
typedef IntFactorDom< RandIter >
::random_generator 
random_generator
typedef Integer Rep

Public Member Functions

Element & strong_prime (random_generator &g, long psize, Element &p) const
 Strong Primes.
long log (const Element &n, const long=10) const
 log[10]
std::ostream & ecriture_str (std::ostream &, const Element &) const
 Text conversions.
std::ostream & ecriture_str_last (std::ostream &, const Element &) const
std::ostream & ecriture_Int (std::ostream &, const Element &) const
Element & point_break (Element &u)
 Breaking codes : finding u knowing only m an k ...
Rep & factor (Rep &r, const Rep &n, unsigned long loops=0) const
Rep & iffactorprime (Rep &r, const Rep &n, unsigned long loops=0) const
Rep & primefactor (Rep &r, const Rep &n) const
template<class Container1 , class Container2 >
bool set (Container1 &setint, Container2 &setpwd, const Rep &a, unsigned long loops=0) const
 Factors with primes.
template<class Container >
void set (Container &, const Rep &) const
template<class Container >
void Erathostene (Container &, const Rep &) const
Rep & Erathostene (Rep &, const Rep &p) const
 returns a small factor
template<class Container , class Cont2 , class Cont3 >
Container & divisors (Container &L, const Cont2 &Lf, const Cont3 &Le) const
template<class Container >
Container & divisors (Container &, const Rep &) const
Rep & Pollard (const RandIter &, Rep &, const Rep &n, unsigned long threshold=0) const
Rep & Lenstra (const RandIter &, Rep &, const Rep &n, const Rep &B1=10000000, const unsigned long curves=30) const
std::ostream & write (std::ostream &o, const Rep &n) const
template<class Array >
std::ostream & write (std::ostream &o, Array &, const Rep &n) const
std::ostream & write (std::ostream &o) const
std::ostream & write (std::ostream &o, const Rep &n) const
int isprime (const Rep &n, int r=5) const
unsigned int isprimepower (Rep &, const Rep &) const
template<class RandIter >
unsigned int Miller (RandIter &g, const Rep &n=5) const
template<class RandIter >
Rep & test_Lehmann (RandIter &g, Rep &, const Rep &n=5) const
template<class RandIter >
int Lehmann (RandIter &g, const Rep &n=5) const
int isprime_Tabule (const int n) const
int isprime_Tabule2 (const int n) const
Rep & nextprime (Rep &, const Rep &, int r=5) const
Rep & prevprime (Rep &, const Rep &, int r=5) const
Rep & nextprimein (Rep &, int r=5) const
Rep & prevprimein (Rep &, int r=5) const
int local_prime (const Rep &n, int r=5) const
int operator== (const IntegerDom &) const
int operator!= (const IntegerDom &) const
Rep & init (Rep &a) const
Rep & init (Rep &a, const Rep &b) const
Rep & read (Rep &a, const long i) const
Rep & read (Rep &a, const unsigned long i) const
Rep & read (Rep &a, const int i) const
Rep & read (Rep &a, const unsigned int i) const
std::istream & read (std::istream &i)
std::istream & read (std::istream &i, Rep &n) const
Rep & convert (Rep &a, const Rep &b) const
template<class XXX >
XXX & convert (XXX &x, const Rep &a) const
Rep & assign (Rep &a, const Rep &b) const
const Rep & access (const Rep &a) const
Rep & mul (Rep &r, const Rep &a, const Rep &b) const
Rep & div (Rep &r, const Rep &a, const Rep &b) const
Rep & mod (Rep &r, const Rep &a, const Rep &b) const
Rep & add (Rep &r, const Rep &a, const Rep &b) const
Rep & sub (Rep &r, const Rep &a, const Rep &b) const
Rep & divmod (Rep &q, Rep &r, const Rep &a, const Rep &b) const
Rep & divexact (Rep &q, const Rep &a, const Rep &b) const
Rep & mulin (Rep &r, const Rep &a) const
Rep & divin (Rep &r, const Rep &a) const
Rep & modin (Rep &r, const Rep &a) const
Rep & addin (Rep &r, const Rep &a) const
Rep & subin (Rep &r, const Rep &a) const
Rep & axpy (Rep &r, const Rep &a, const Rep &b, const Rep &c) const
Rep & maxpy (Rep &r, const Rep &a, const Rep &b, const Rep &c) const
Rep & maxpyin (Rep &r, const Rep &a, const Rep &b) const
Rep & axmy (Rep &r, const Rep &a, const Rep &b, const Rep &c) const
Rep & axpyin (Rep &r, const Rep &a, const Rep &b) const
Rep & axmyin (Rep &r, const Rep &a, const Rep &b) const
Rep & neg (Rep &r, const Rep &a) const
Rep & negin (Rep &r) const
Rep & gcd (Rep &g, Rep &u, Rep &v, const Rep &a, const Rep &b) const
Rep & gcd (Rep &g, const Rep &a, const Rep &b) const
Rep & lcm (Rep &l, const Rep &a, const Rep &b) const
Rep & lcmin (Rep &l, const Rep &a) const
Rep & inv (Rep &u, const Rep &a, const Rep &b) const
Rep & invin (Rep &u, const Rep &b) const
Rep & pow (Rep &r, const Rep &n, const long l) const
Rep & pow (Rep &r, const Rep &n, const unsigned long l) const
Rep & pow (Rep &r, const Rep &n, const int l) const
Rep & pow (Rep &r, const Rep &n, const unsigned int l) const
Rep & sqrt (Rep &s, const Rep &n) const
Rep & sqrt (Rep &s, Rep &r, const Rep &n) const
long logp (const Rep &a, const Rep &p) const
Rep & powmod (Rep &r, const Rep &n, const long e, const Rep &m) const
Rep & powmod (Rep &r, const Rep &n, const Rep &e, const Rep &m) const
unsigned long length (const Rep &a) const
int sign (const Rep &a) const
bool isZero (const Rep &a) const
bool isOne (const Rep &a) const
bool areEqual (const Rep &a, const Rep &b) const
bool areNEqual (const Rep &a, const Rep &b) const
bool isgeq (const Rep &a, const Rep &b) const
bool isgeq (const long b, const Rep &a) const
bool isgeq (const Rep &a, const long b) const
bool isleq (const Rep &a, const Rep &b) const
bool isleq (const long b, const Rep &a) const
bool isleq (const Rep &a, const long b) const
bool isgt (const Rep &a, const Rep &b) const
bool isgt (const long b, const Rep &a) const
bool isgt (const Rep &a, const long b) const
bool islt (const Rep &a, const Rep &b) const
bool islt (const long b, const Rep &a) const
bool islt (const Rep &a, const long b) const
template<class RandIter >
Rep & random (RandIter &, Rep &r, long s=1) const
template<class RandIter >
Rep & random (RandIter &, Rep &r, const Rep &b) const
template<class RandIter >
Rep & nonzerorandom (RandIter &, Rep &r, long s=1) const
template<class RandIter >
Rep & nonzerorandom (RandIter &, Rep &r, const Rep &b) const
 IntRSADom (bool fi=false, RandIter g=RandIter())
 Constructors.
 IntRSADom (const long s, bool fi=false, RandIter g=RandIter())
 Constructors.
 IntRSADom (const long p, const long q, bool fi=false, RandIter g=RandIter())
 Constructors.
 IntRSADom (const Element &n, const Element &e, const Element &d)
 Constructors.
 IntRSADom (const Element &n, const Element &e)
 Constructors.
const Element & getn () const
 Accesses.
const Element & gete () const
 Accesses.
const Element & getd () const
 Accesses.
std::ostream & encipher (std::ostream &, std::istream &) const
 Text conversions.
std::ostream & decipher (std::ostream &, std::istream &)
 Text conversions.
void keys_gen (random_generator &g, long psize, long qsize, Element &n, Element &e, Element &d, Element &p, Element &q) const
 Key gen.
void keys_gen (random_generator &g, long psize, long qsize, Element &n, Element &e, Element &d) const
 Key gen.

Data Fields

const Integer one
const Integer mOne
const Integer zero

Protected Attributes

bool _fast_impl
 Fast implementation.
RandIter _g

Detailed Description

template<class RandIter = GivRandom>
class Givaro::IntRSADom< RandIter >

RSA domain.

Examples:
examples/Integer/RSA_breaking.C, examples/Integer/RSA_decipher.C, examples/Integer/RSA_encipher.C, and examples/Integer/RSA_keys_generator.C.

Member Typedef Documentation

typedef IntFactorDom<RandIter>::Element Element

Reimplemented from IntegerDom.

Reimplemented from IntFactorDom< RandIter >.

typedef Integer Rep
inherited

Constructor & Destructor Documentation

IntRSADom ( bool  fi = false,
RandIter  g = RandIter() 
)
inline

Constructors.

IntRSADom ( const long  s,
bool  fi = false,
RandIter  g = RandIter() 
)
inline

Constructors.

IntRSADom ( const long  p,
const long  q,
bool  fi = false,
RandIter  g = RandIter() 
)
inline

Constructors.

IntRSADom ( const Element &  n,
const Element &  e,
const Element &  d 
)
inline

Constructors.

IntRSADom ( const Element &  n,
const Element &  e 
)
inline

Constructors.


Member Function Documentation

const Element& getn ( ) const
inline

Accesses.

const Element& gete ( ) const
inline

Accesses.

const Element& getd ( ) const
inline

Accesses.

std::ostream & encipher ( std::ostream &  o,
std::istream &  in 
) const

Text conversions.

std::ostream & decipher ( std::ostream &  o,
std::istream &  in 
)

Text conversions.

IntRSADom< RandIter >::Element & strong_prime ( random_generator &  g,
long  psize,
Element &  p 
) const

Strong Primes.

Bibliography:
  • J. Gordon, Strong Primes Are Easy to Find, EUROCRYPT'84, LNCS 209.
void keys_gen ( random_generator &  g,
long  psize,
long  qsize,
Element &  n,
Element &  e,
Element &  d,
Element &  p,
Element &  q 
) const

Key gen.

Here m = p*q p and q are prime numbers of respective sizes psize, qsize Moreover p-1 and q-1 have one prime factor of respective size 2/3 since k.u = 1 mod (p-1)(q-1)

void keys_gen ( random_generator &  g,
long  psize,
long  qsize,
Element &  n,
Element &  e,
Element &  d 
) const

Key gen.

Here m = p*q p and q are prime numbers of respective sizes psize, qsize Moreover p-1 and q-1 have one prime factor of respective size 2/3 since k.u = 1 mod (p-1)(q-1)

long log ( const Element &  n,
const long  b = 10 
) const

log[10]

std::ostream & ecriture_str ( std::ostream &  o,
const Element &  n 
) const

Text conversions.

std::ostream & ecriture_str_last ( std::ostream &  o,
const Element &  n 
) const
std::ostream & ecriture_Int ( std::ostream &  o,
const Element &  p 
) const
IntRSADom< RandIter >::Element & point_break ( Element &  u)

Breaking codes : finding u knowing only m an k ...

Rep& factor ( Rep &  r,
const Rep &  n,
unsigned long  loops = 0 
) const
inlineinherited
Rep& iffactorprime ( Rep &  r,
const Rep &  n,
unsigned long  loops = 0 
) const
inlineinherited
Rep& primefactor ( Rep &  r,
const Rep &  n 
) const
inlineinherited
bool set ( Container1 &  setint,
Container2 &  setpwd,
const Rep &  a,
unsigned long  loops = 0 
) const
inherited

Factors with primes.

void set ( Container &  Lf,
const Rep &  n 
) const
inherited
void Erathostene ( Container &  Lf,
const Rep &  p 
) const
inherited
Rep& Erathostene ( Rep &  ,
const Rep &  p 
) const
inherited

returns a small factor

Container & divisors ( Container &  L,
const Cont2 &  Lf,
const Cont3 &  Le 
) const
inherited
Container & divisors ( Container &  L,
const Rep &  n 
) const
inherited
IntFactorDom< RandIter >::Rep & Pollard ( const RandIter &  gen,
Rep &  g,
const Rep &  n,
unsigned long  threshold = 0 
) const
inherited
IntFactorDom< RandIter >::Rep & Lenstra ( const RandIter &  gen,
Rep &  g,
const Rep &  n,
const Rep &  B1 = 10000000,
const unsigned long  curves = 30 
) const
inherited
std::ostream & write ( std::ostream &  o,
const Rep &  n 
) const
inherited
std::ostream & write ( std::ostream &  o,
Array &  Lf,
const Rep &  n 
) const
inherited
std::ostream& write ( std::ostream &  o) const
inlineinherited
std::ostream& write ( std::ostream &  o,
const Rep &  n 
) const
inlineinherited
int isprime ( const Rep &  n,
int  r = 5 
) const
inlineinherited
unsigned int isprimepower ( Rep &  q,
const Rep &  u 
) const
inherited
unsigned int Miller ( RandIter &  g,
const Rep &  n = 5 
) const
inherited
IntPrimeDom::Rep & test_Lehmann ( RandIter &  g,
Rep &  r,
const Rep &  n = 5 
) const
inherited
int Lehmann ( RandIter &  g,
const Rep &  n = 5 
) const
inherited
int isprime_Tabule ( const int  n) const
inherited
int isprime_Tabule2 ( const int  n) const
inherited
IntPrimeDom::Rep & nextprime ( Rep &  n,
const Rep &  p,
int  r = 5 
) const
inherited
IntPrimeDom::Rep & prevprime ( Rep &  n,
const Rep &  p,
int  r = 5 
) const
inherited
IntPrimeDom::Rep & nextprimein ( Rep &  n,
int  r = 5 
) const
inherited
IntPrimeDom::Rep & prevprimein ( Rep &  n,
int  r = 5 
) const
inherited
int local_prime ( const Rep &  n,
int  r = 5 
) const
inlineinherited
int operator== ( const IntegerDom &  ) const
inlineinherited
int operator!= ( const IntegerDom &  ) const
inlineinherited
Rep& init ( Rep &  a) const
inlineinherited
Rep& init ( Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& read ( Rep &  a,
const long  i 
) const
inlineinherited
Rep& read ( Rep &  a,
const unsigned long  i 
) const
inlineinherited
Rep& read ( Rep &  a,
const int  i 
) const
inlineinherited
Rep& read ( Rep &  a,
const unsigned int  i 
) const
inlineinherited
std::istream& read ( std::istream &  i)
inlineinherited
std::istream& read ( std::istream &  i,
Rep &  n 
) const
inlineinherited
Rep& convert ( Rep &  a,
const Rep &  b 
) const
inlineinherited
XXX& convert ( XXX &  x,
const Rep &  a 
) const
inlineinherited
Rep& assign ( Rep &  a,
const Rep &  b 
) const
inlineinherited
const Rep& access ( const Rep &  a) const
inlineinherited
Rep& mul ( Rep &  r,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& div ( Rep &  r,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& mod ( Rep &  r,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& add ( Rep &  r,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& sub ( Rep &  r,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& divmod ( Rep &  q,
Rep &  r,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& divexact ( Rep &  q,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& mulin ( Rep &  r,
const Rep &  a 
) const
inlineinherited
Rep& divin ( Rep &  r,
const Rep &  a 
) const
inlineinherited
Rep& modin ( Rep &  r,
const Rep &  a 
) const
inlineinherited
Rep& addin ( Rep &  r,
const Rep &  a 
) const
inlineinherited
Rep& subin ( Rep &  r,
const Rep &  a 
) const
inlineinherited
Rep& axpy ( Rep &  r,
const Rep &  a,
const Rep &  b,
const Rep &  c 
) const
inlineinherited
Rep& maxpy ( Rep &  r,
const Rep &  a,
const Rep &  b,
const Rep &  c 
) const
inlineinherited
Rep& maxpyin ( Rep &  r,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& axmy ( Rep &  r,
const Rep &  a,
const Rep &  b,
const Rep &  c 
) const
inlineinherited
Rep& axpyin ( Rep &  r,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& axmyin ( Rep &  r,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& neg ( Rep &  r,
const Rep &  a 
) const
inlineinherited
Rep& negin ( Rep &  r) const
inlineinherited
Rep& gcd ( Rep &  g,
Rep &  u,
Rep &  v,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& gcd ( Rep &  g,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& lcm ( Rep &  l,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& lcmin ( Rep &  l,
const Rep &  a 
) const
inlineinherited
Rep& inv ( Rep &  u,
const Rep &  a,
const Rep &  b 
) const
inlineinherited
Rep& invin ( Rep &  u,
const Rep &  b 
) const
inlineinherited
Rep& pow ( Rep &  r,
const Rep &  n,
const long  l 
) const
inlineinherited
Rep& pow ( Rep &  r,
const Rep &  n,
const unsigned long  l 
) const
inlineinherited
Rep& pow ( Rep &  r,
const Rep &  n,
const int  l 
) const
inlineinherited
Rep& pow ( Rep &  r,
const Rep &  n,
const unsigned int  l 
) const
inlineinherited
Rep& sqrt ( Rep &  s,
const Rep &  n 
) const
inlineinherited
Rep& sqrt ( Rep &  s,
Rep &  r,
const Rep &  n 
) const
inlineinherited
long logp ( const Rep &  a,
const Rep &  p 
) const
inlineinherited
Rep& powmod ( Rep &  r,
const Rep &  n,
const long  e,
const Rep &  m 
) const
inlineinherited
Rep& powmod ( Rep &  r,
const Rep &  n,
const Rep &  e,
const Rep &  m 
) const
inlineinherited
unsigned long length ( const Rep &  a) const
inlineinherited
int sign ( const Rep &  a) const
inlineinherited
bool isZero ( const Rep &  a) const
inlineinherited
bool isOne ( const Rep &  a) const
inlineinherited
bool areEqual ( const Rep &  a,
const Rep &  b 
) const
inlineinherited
bool areNEqual ( const Rep &  a,
const Rep &  b 
) const
inlineinherited
bool isgeq ( const Rep &  a,
const Rep &  b 
) const
inlineinherited
bool isgeq ( const long  b,
const Rep &  a 
) const
inlineinherited
bool isgeq ( const Rep &  a,
const long  b 
) const
inlineinherited
bool isleq ( const Rep &  a,
const Rep &  b 
) const
inlineinherited
bool isleq ( const long  b,
const Rep &  a 
) const
inlineinherited
bool isleq ( const Rep &  a,
const long  b 
) const
inlineinherited
bool isgt ( const Rep &  a,
const Rep &  b 
) const
inlineinherited
bool isgt ( const long  b,
const Rep &  a 
) const
inlineinherited
bool isgt ( const Rep &  a,
const long  b 
) const
inlineinherited
bool islt ( const Rep &  a,
const Rep &  b 
) const
inlineinherited
bool islt ( const long  b,
const Rep &  a 
) const
inlineinherited
bool islt ( const Rep &  a,
const long  b 
) const
inlineinherited
Rep& random ( RandIter &  ,
Rep &  r,
long  s = 1 
) const
inlineinherited
Rep& random ( RandIter &  ,
Rep &  r,
const Rep &  b 
) const
inlineinherited
Rep& nonzerorandom ( RandIter &  ,
Rep &  r,
long  s = 1 
) const
inlineinherited
Rep& nonzerorandom ( RandIter &  ,
Rep &  r,
const Rep &  b 
) const
inlineinherited

Field Documentation

bool _fast_impl
protected

Fast implementation.

Means simple enciphering key, and deciphering via chinese remaindering.

Warning:
this means less security !
RandIter _g
protectedinherited
const Integer one
inherited
const Integer mOne
inherited
const Integer zero
inherited

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