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

RSA domain. More...

#include <givintrsa.h>

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

Public Types

typedef IntFactorDom< MyRandIter >::Element Element
 
typedef IntFactorDom< MyRandIter >::random_generator random_generator
 
using Self_t = IntegerDom
 
typedef Integer Rep
 
typedef GeneralRingRandIter< Self_tRandIter
 
typedef GeneralRingNonZeroRandIter< Self_tNonZeroRandIter
 
typedef ElementElement_ptr
 
typedef const Element ConstElement
 
typedef const ElementConstElement_ptr
 

Public Member Functions

Elementstrong_prime (random_generator &g, int64_t psize, Element &p) const
 Strong Primes. More...
 
int64_t log (const Element &n, const int64_t=10) const
 log[10] More...
 
std::ostream & ecriture_str (std::ostream &, const Element &) const
 Text conversions. More...
 
std::ostream & ecriture_str_last (std::ostream &, const Element &) const
 
std::ostream & ecriture_Int (std::ostream &, const Element &) const
 
Elementpoint_break (Element &u)
 Breaking codes : finding u knowing only m an k ... More...
 
Repfactor (Rep &r, const Rep &n, unsigned long loops=0) const
 
Repiffactorprime (Rep &r, const Rep &n, unsigned long loops=0) const
 
Repprimefactor (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. More...
 
template<class Container >
void set (Container &, const Rep &) const
 
template<class Container >
void Erathostene (Container &, const Rep &) const
 
RepErathostene (Rep &, const Rep &p) const
 returns a small factor More...
 
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
 
RepPollard (const MyRandIter &, Rep &, const Rep &n, unsigned long threshold=0) const
 
RepLenstra (const MyRandIter &, 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 MyRandIter >
unsigned int Miller (MyRandIter &g, const Rep &n=5) const
 
template<class MyRandIter >
Reptest_Lehmann (MyRandIter &g, Rep &, const Rep &n=5) const
 
template<class MyRandIter >
int Lehmann (MyRandIter &g, const Rep &n=5) const
 
int isprime_Tabule (const int n) const
 
int isprime_Tabule2 (const int n) const
 
Repnextprime (Rep &, const Rep &, int r=5) const
 
Repprevprime (Rep &, const Rep &, int r=5) const
 
Repnextprimein (Rep &, int r=5) const
 
Repprevprimein (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
 
Repinit (Rep &a) const
 
Repinit (Rep &a, const Rep &b) const
 
Repread (Rep &a, const int64_t i) const
 
Repread (Rep &a, const uint64_t i) const
 
Repread (Rep &a, const int32_t i) const
 
Repread (Rep &a, const uint32_t i) const
 
std::istream & read (std::istream &i)
 
std::istream & read (std::istream &i, Rep &n) const
 
Repconvert (Rep &a, const Rep &b) const
 
template<class XXX >
XXX & convert (XXX &x, const Rep &a) const
 
Repassign (Rep &a, const Rep &b) const
 
const Repaccess (const Rep &a) const
 
Repmul (Rep &r, const Rep &a, const Rep &b) const
 
Repdiv (Rep &r, const Rep &a, const Rep &b) const
 
Repmod (Rep &r, const Rep &a, const Rep &b) const
 
Repadd (Rep &r, const Rep &a, const Rep &b) const
 
Repsub (Rep &r, const Rep &a, const Rep &b) const
 
Repdivmod (Rep &q, Rep &r, const Rep &a, const Rep &b) const
 
Repdivexact (Rep &q, const Rep &a, const Rep &b) const
 
Repmulin (Rep &r, const Rep &a) const
 
Repdivin (Rep &r, const Rep &a) const
 
Repmodin (Rep &r, const Rep &a) const
 
Repaddin (Rep &r, const Rep &a) const
 
Repsubin (Rep &r, const Rep &a) const
 
Repaxpy (Rep &r, const Rep &a, const Rep &b, const Rep &c) const
 
Repmaxpy (Rep &r, const Rep &a, const Rep &b, const Rep &c) const
 
Repmaxpyin (Rep &r, const Rep &a, const Rep &b) const
 
Repaxmy (Rep &r, const Rep &a, const Rep &b, const Rep &c) const
 
Repaxpyin (Rep &r, const Rep &a, const Rep &b) const
 
Repaxmyin (Rep &r, const Rep &a, const Rep &b) const
 
Repneg (Rep &r, const Rep &a) const
 
Repnegin (Rep &r) const
 
Repgcd (Rep &g, Rep &u, Rep &v, const Rep &a, const Rep &b) const
 
Repgcd (Rep &g, const Rep &a, const Rep &b) const
 
Replcm (Rep &l, const Rep &a, const Rep &b) const
 
Replcmin (Rep &l, const Rep &a) const
 
Repinv (Rep &u, const Rep &a, const Rep &b) const
 
Repinvin (Rep &u, const Rep &b) const
 
Reppow (Rep &r, const Rep &n, const int64_t l) const
 
Reppow (Rep &r, const Rep &n, const uint64_t l) const
 
Reppow (Rep &r, const Rep &n, const int32_t l) const
 
Reppow (Rep &r, const Rep &n, const uint32_t l) const
 
Repsqrt (Rep &s, const Rep &n) const
 
Repsqrt (Rep &s, Rep &r, const Rep &n) const
 
long logp (const Rep &a, const Rep &p) const
 
Reppowmod (Rep &r, const Rep &n, const int64_t e, const Rep &m) const
 
Reppowmod (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 isMOne (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 int64_t b, const Rep &a) const
 
bool isgeq (const Rep &a, const int64_t b) const
 
bool isleq (const Rep &a, const Rep &b) const
 
bool isleq (const int64_t b, const Rep &a) const
 
bool isleq (const Rep &a, const int64_t b) const
 
bool isgt (const Rep &a, const Rep &b) const
 
bool isgt (const int64_t b, const Rep &a) const
 
bool isgt (const Rep &a, const int64_t b) const
 
bool islt (const Rep &a, const Rep &b) const
 
bool islt (const int64_t b, const Rep &a) const
 
bool islt (const Rep &a, const int64_t b) const
 
template<class MyRandIter >
Reprandom (MyRandIter &, Rep &r, long s=1) const
 
template<class MyRandIter >
Reprandom (MyRandIter &, Rep &r, const Rep &b) const
 
template<class MyRandIter >
Repnonzerorandom (MyRandIter &, Rep &r, long s=1) const
 
template<class MyRandIter >
Repnonzerorandom (MyRandIter &, Rep &r, const Rep &b) const
 
 IntRSADom (bool fi=false, MyRandIter g=MyRandIter())
 Constructors. More...
 
 IntRSADom (const int64_t s, bool fi=false, MyRandIter g=MyRandIter())
 Constructors. More...
 
 IntRSADom (const int64_t p, const int64_t q, bool fi=false, MyRandIter g=MyRandIter())
 Constructors. More...
 
 IntRSADom (const Element &n, const Element &e, const Element &d)
 Constructors. More...
 
 IntRSADom (const Element &n, const Element &e)
 Constructors. More...
 
const Elementgetn () const
 Accesses. More...
 
const Elementgete () const
 Accesses. More...
 
const Elementgetd () const
 Accesses. More...
 
std::ostream & encipher (std::ostream &, std::istream &) const
 Text conversions. More...
 
std::ostream & decipher (std::ostream &, std::istream &)
 Text conversions. More...
 
void keys_gen (random_generator &g, int64_t psize, int64_t qsize, Element &n, Element &e, Element &d, Element &p, Element &q) const
 Key gen. More...
 
void keys_gen (random_generator &g, int64_t psize, int64_t qsize, Element &n, Element &e, Element &d) const
 Key gen. More...
 

Data Fields

const Integer one
 
const Integer mOne
 
const Integer zero
 

Protected Attributes

bool _fast_impl
 Fast implementation. More...
 
MyRandIter _g
 

Detailed Description

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

RSA domain.

Examples:
examples/Integer/givaro-ssh-keygen.C, 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<MyRandIter>::Element Element
using Self_t = IntegerDom
inherited
typedef Integer Rep
inherited
typedef GeneralRingRandIter<Self_t> RandIter
inherited
typedef Element* Element_ptr
inherited
typedef const Element ConstElement
inherited
typedef const Element* ConstElement_ptr
inherited

Constructor & Destructor Documentation

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

Constructors.

IntRSADom ( const int64_t  s,
bool  fi = false,
MyRandIter  g = MyRandIter() 
)
inline

Constructors.

IntRSADom ( const int64_t  p,
const int64_t  q,
bool  fi = false,
MyRandIter  g = MyRandIter() 
)
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< MyRandIter >::Element & strong_prime ( random_generator g,
int64_t  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,
int64_t  psize,
int64_t  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,
int64_t  psize,
int64_t  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)

int64_t log ( const Element n,
const int64_t  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< MyRandIter >::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< MyRandIter >::Rep & Pollard ( const MyRandIter &  gen,
Rep g,
const Rep n,
unsigned long  threshold = 0 
) const
inherited
IntFactorDom< MyRandIter >::Rep & Lenstra ( const MyRandIter &  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 ( MyRandIter &  g,
const Rep n = 5 
) const
inherited
IntPrimeDom::Rep & test_Lehmann ( MyRandIter &  g,
Rep r,
const Rep n = 5 
) const
inherited
int Lehmann ( MyRandIter &  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 ,
const Rep ,
int  r = 5 
) const
inherited
IntPrimeDom::Rep & prevprime ( Rep n,
const Rep p,
int  r = 5 
) const
inherited
IntPrimeDom::Rep & nextprimein ( Rep ,
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 int64_t  i 
) const
inlineinherited
Rep& read ( Rep a,
const uint64_t  i 
) const
inlineinherited
Rep& read ( Rep a,
const int32_t  i 
) const
inlineinherited
Rep& read ( Rep a,
const uint32_t  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
inlinevirtualinherited
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
inlinevirtualinherited
Rep& sub ( Rep r,
const Rep a,
const Rep b 
) const
inlinevirtualinherited
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
inlinevirtualinherited
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
inlinevirtualinherited
Rep& subin ( Rep r,
const Rep a 
) const
inlinevirtualinherited
Rep& axpy ( Rep r,
const Rep a,
const Rep b,
const Rep c 
) const
inlinevirtualinherited
Rep& maxpy ( Rep r,
const Rep a,
const Rep b,
const Rep c 
) const
inlinevirtualinherited
Rep& maxpyin ( Rep r,
const Rep a,
const Rep b 
) const
inlinevirtualinherited
Rep& axmy ( Rep r,
const Rep a,
const Rep b,
const Rep c 
) const
inlinevirtualinherited
Rep& axpyin ( Rep r,
const Rep a,
const Rep b 
) const
inlinevirtualinherited
Rep& axmyin ( Rep r,
const Rep a,
const Rep b 
) const
inlinevirtualinherited
Rep& neg ( Rep r,
const Rep a 
) const
inlinevirtualinherited
Rep& negin ( Rep r) const
inlinevirtualinherited
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 int64_t  l 
) const
inlineinherited
Rep& pow ( Rep r,
const Rep n,
const uint64_t  l 
) const
inlineinherited
Rep& pow ( Rep r,
const Rep n,
const int32_t  l 
) const
inlineinherited
Rep& pow ( Rep r,
const Rep n,
const uint32_t  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 int64_t  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
inlinevirtualinherited
bool isOne ( const Rep a) const
inlinevirtualinherited
bool isMOne ( const Rep a) const
inlinevirtualinherited
bool areEqual ( const Rep a,
const Rep b 
) const
inlinevirtualinherited
bool areNEqual ( const Rep a,
const Rep b 
) const
inlineinherited
bool isgeq ( const Rep a,
const Rep b 
) const
inlineinherited
bool isgeq ( const int64_t  b,
const Rep a 
) const
inlineinherited
bool isgeq ( const Rep a,
const int64_t  b 
) const
inlineinherited
bool isleq ( const Rep a,
const Rep b 
) const
inlineinherited
bool isleq ( const int64_t  b,
const Rep a 
) const
inlineinherited
bool isleq ( const Rep a,
const int64_t  b 
) const
inlineinherited
bool isgt ( const Rep a,
const Rep b 
) const
inlineinherited
bool isgt ( const int64_t  b,
const Rep a 
) const
inlineinherited
bool isgt ( const Rep a,
const int64_t  b 
) const
inlineinherited
bool islt ( const Rep a,
const Rep b 
) const
inlineinherited
bool islt ( const int64_t  b,
const Rep a 
) const
inlineinherited
bool islt ( const Rep a,
const int64_t  b 
) const
inlineinherited
Rep& random ( MyRandIter &  ,
Rep r,
long  s = 1 
) const
inlineinherited
Rep& random ( MyRandIter &  ,
Rep r,
const Rep b 
) const
inlineinherited
Rep& nonzerorandom ( MyRandIter &  ,
Rep r,
long  s = 1 
) const
inlineinherited
Rep& nonzerorandom ( MyRandIter &  ,
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 !
MyRandIter _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: