Crypto++  5.6.3
Free C++ class library of cryptographic schemes
Public Types | Public Member Functions | Static Public Member Functions | List of all members
DL_GroupParameters_GFP Class Referenceabstract

GF(p) group parameters. More...

+ Inheritance diagram for DL_GroupParameters_GFP:

Public Types

typedef ModExpPrecomputation::Element Element
 
typedef ModExpPrecomputation GroupPrecomputation
 
typedef DL_FixedBasePrecomputationImpl< typename ModExpPrecomputation::Element > BasePrecomputation
 

Public Member Functions

bool IsIdentity (const Integer &element) const
 
void SimultaneousExponentiate (Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const
 
bool GetVoidValue (const char *name, const std::type_info &valueType, void *pValue) const
 Get a named value. More...
 
Element MultiplyElements (const Element &a, const Element &b) const
 
Element CascadeExponentiate (const Element &element1, const Integer &exponent1, const Element &element2, const Integer &exponent2) const
 
void AssignFrom (const NameValuePairs &source)
 Assign values to this object. More...
 
const DL_FixedBasePrecomputation< Element > & GetBasePrecomputation () const
 
DL_FixedBasePrecomputation< Element > & AccessBasePrecomputation ()
 
const IntegerGetModulus () const
 
const IntegerGetGenerator () const
 
void SetModulusAndSubgroupGenerator (const Integer &p, const Integer &g)
 
bool operator== (const DL_GroupParameters_IntegerBasedImpl< ModExpPrecomputation, DL_FixedBasePrecomputationImpl< typename ModExpPrecomputation::Element > > &rhs) const
 
bool operator!= (const DL_GroupParameters_IntegerBasedImpl< ModExpPrecomputation, DL_FixedBasePrecomputationImpl< typename ModExpPrecomputation::Element > > &rhs) const
 
const DL_GroupPrecomputation< Element > & GetGroupPrecomputation () const
 
void Initialize (const DL_GroupParameters_IntegerBased &params)
 
void Initialize (RandomNumberGenerator &rng, unsigned int pbits)
 
void Initialize (const Integer &p, const Integer &g)
 
void Initialize (const Integer &p, const Integer &q, const Integer &g)
 
void BERDecode (BufferedTransformation &bt)
 Decode this object from a BufferedTransformation. More...
 
void DEREncode (BufferedTransformation &bt) const
 Encode this object into a BufferedTransformation. More...
 
void GenerateRandom (RandomNumberGenerator &rng, const NameValuePairs &alg)
 
const IntegerGetSubgroupOrder () const
 
Integer GetGroupOrder () const
 
bool ValidateGroup (RandomNumberGenerator &rng, unsigned int level) const
 
bool ValidateElement (unsigned int level, const Integer &element, const DL_FixedBasePrecomputation< Integer > *precomp) const
 
bool FastSubgroupCheckAvailable () const
 
void EncodeElement (bool reversible, const Element &element, byte *encoded) const
 
unsigned int GetEncodedElementSize (bool reversible) const
 
Integer DecodeElement (const byte *encoded, bool checkForGroupMembership) const
 
Integer ConvertElementToInteger (const Element &element) const
 
Integer GetMaxExponent () const
 
OID GetAlgorithmID () const
 
void SetSubgroupOrder (const Integer &q)
 
void Save (BufferedTransformation &bt) const
 
void Load (BufferedTransformation &bt)
 
virtual void BEREncode (BufferedTransformation &bt) const
 Encode this object into a BufferedTransformation. More...
 
bool Validate (RandomNumberGenerator &rng, unsigned int level) const
 Check this object for errors. More...
 
bool SupportsPrecomputation () const
 Determines whether the object supports precomputation. More...
 
void Precompute (unsigned int precomputationStorage=16)
 Perform precomputation. More...
 
void LoadPrecomputation (BufferedTransformation &storedPrecomputation)
 retrieve previously saved precomputation
 
void SavePrecomputation (BufferedTransformation &storedPrecomputation) const
 save precomputation for later use
 
virtual const Element & GetSubgroupGenerator () const
 
virtual void SetSubgroupGenerator (const Element &base)
 
virtual Element ExponentiateBase (const Integer &exponent) const
 
virtual Element ExponentiateElement (const Element &base, const Integer &exponent) const
 
virtual Integer GetCofactor () const
 
virtual void SimultaneousExponentiate (Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const =0
 
void GenerateRandomWithKeySize (RandomNumberGenerator &rng, unsigned int keySize)
 Generate a random key or crypto parameters. More...
 
virtual void ThrowIfInvalid (RandomNumberGenerator &rng, unsigned int level) const
 Check this object for errors. More...
 
void DoQuickSanityCheck () const
 
template<class T >
bool GetThisObject (T &object) const
 Get a copy of this object or subobject. More...
 
template<class T >
bool GetThisPointer (T *&ptr) const
 Get a pointer to this object. More...
 
template<class T >
bool GetValue (const char *name, T &value) const
 Get a named value. More...
 
template<class T >
GetValueWithDefault (const char *name, T defaultValue) const
 Get a named value. More...
 
std::string GetValueNames () const
 Get a list of value names that can be retrieved. More...
 
bool GetIntValue (const char *name, int &value) const
 Get a named value with type int. More...
 
int GetIntValueWithDefault (const char *name, int defaultValue) const
 Get a named value with type int, with default. More...
 
template<class T >
void GetRequiredParameter (const char *className, const char *name, T &value) const
 Retrieves a required name/value pair. More...
 
void GetRequiredIntParameter (const char *className, const char *name, int &value) const
 Retrieves a required name/value pair. More...
 

Static Public Member Functions

static std::string StaticAlgorithmNamePrefix ()
 
static void ThrowIfTypeMismatch (const char *name, const std::type_info &stored, const std::type_info &retrieving)
 Ensures an expected name and type is present. More...
 

Detailed Description

GF(p) group parameters.

Definition at line 144 of file gfpcrypt.h.

Member Function Documentation

bool DL_GroupParameters_GFP::GetVoidValue ( const char *  name,
const std::type_info &  valueType,
void *  pValue 
) const
inlinevirtual

Get a named value.

Parameters
namethe name of the object or value to retrieve
valueTypereference to a variable that receives the value
pValuevoid pointer to a variable that receives the value
Returns
true if the value was retrieved, false otherwise

GetVoidValue() retrives the value of name if it exists.

Note
GetVoidValue() is an internal function and should be implemented by derived classes. Users should use one of the other functions instead.
See also
GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Reimplemented from DL_GroupParameters_IntegerBased.

Definition at line 152 of file gfpcrypt.h.

void DL_GroupParameters_IntegerBasedImpl< ModExpPrecomputation , DL_FixedBasePrecomputationImpl< typename ModExpPrecomputation ::Element> >::AssignFrom ( const NameValuePairs source)
inlinevirtualinherited

Assign values to this object.

This function can be used to create a public key from a private key.

Reimplemented from DL_GroupParameters_IntegerBased.

Definition at line 116 of file gfpcrypt.h.

void DL_GroupParameters_IntegerBased::BERDecode ( BufferedTransformation bt)
virtualinherited

Decode this object from a BufferedTransformation.

Parameters
btBufferedTransformation object

Uses Basic Encoding Rules (BER)

Implements ASN1Object.

Definition at line 230 of file gfpcrypt.cpp.

References Integer::BERDecode().

void DL_GroupParameters_IntegerBased::DEREncode ( BufferedTransformation bt) const
virtualinherited

Encode this object into a BufferedTransformation.

Parameters
btBufferedTransformation object

Uses Distinguished Encoding Rules (DER)

Implements ASN1Object.

Definition at line 249 of file gfpcrypt.cpp.

References Integer::DEREncode().

void DL_GroupParameters_IntegerBased::GenerateRandom ( RandomNumberGenerator rng,
const NameValuePairs alg 
)
virtualinherited
virtual void ASN1Object::BEREncode ( BufferedTransformation bt) const
inlinevirtualinherited

Encode this object into a BufferedTransformation.

Parameters
btBufferedTransformation object

Uses Basic Encoding Rules (BER).

This may be useful if DEREncode() would be too inefficient.

Definition at line 2647 of file cryptlib.h.

bool DL_GroupParameters< Integer >::Validate ( RandomNumberGenerator rng,
unsigned int  level 
) const
inlinevirtualinherited

Check this object for errors.

Parameters
rnga RandomNumberGenerator for objects which use randomized testing
levelthe level of thoroughness
Returns
true if the tests succeed, false otherwise

There are four levels of thoroughness:

  • 0 - using this object won't cause a crash or exception
  • 1 - this object will probably function, and encrypt, sign, other operations correctly
  • 2 - ensure this object will function correctly, and perform reasonable security checks
  • 3 - perform reasonable security checks, and do checks that may take a long time

Level 0 does not require a RandomNumberGenerator. A NullRNG() can be used for level 0.

Level 1 may not check for weak keys and such.

Levels 2 and 3 are recommended.

Implements CryptoMaterial.

Definition at line 732 of file pubkey.h.

bool DL_GroupParameters< Integer >::SupportsPrecomputation ( ) const
inlinevirtualinherited

Determines whether the object supports precomputation.

Returns
true if the object supports precomputation, false otherwise

Reimplemented from CryptoMaterial.

Definition at line 756 of file pubkey.h.

void DL_GroupParameters< Integer >::Precompute ( unsigned int  precomputationStorage = 16)
inlinevirtualinherited

Perform precomputation.

Parameters
precomputationStoragethe suggested number of objects for the precompute table
Exceptions
NotImplemented

The exact semantics of Precompute() varies, but it typically means calculate a table of n objects that can be used later to speed up computation.

If a derived class does not override Precompute, then the base class throws NotImplemented.

Reimplemented from CryptoMaterial.

Definition at line 758 of file pubkey.h.

void GeneratableCryptoMaterial::GenerateRandomWithKeySize ( RandomNumberGenerator rng,
unsigned int  keySize 
)
inherited

Generate a random key or crypto parameters.

Parameters
rnga RandomNumberGenerator to produce keying material
keySizethe size of the key, in bits
Exceptions
KeyingErrif a key can't be generated or algorithm parameters are invalid

GenerateRandomWithKeySize calls GenerateRandom with a NameValuePairs object with only "KeySize"

Definition at line 771 of file cryptlib.cpp.

References MakeParameters().

Referenced by FixedRNG::GenerateBlock().

virtual void CryptoMaterial::ThrowIfInvalid ( RandomNumberGenerator rng,
unsigned int  level 
) const
inlinevirtualinherited

Check this object for errors.

Parameters
rnga RandomNumberGenerator for objects which use randomized testing
levelthe level of thoroughness
Exceptions
InvalidMaterial

Internally, ThrowIfInvalid() calls Validate() and throws InvalidMaterial if validation fails.

Definition at line 1938 of file cryptlib.h.

template<class T >
bool NameValuePairs::GetThisObject ( T &  object) const
inlineinherited

Get a copy of this object or subobject.

Template Parameters
Tclass or type
Parameters
objectreference to a variable that receives the value

Definition at line 297 of file cryptlib.h.

Referenced by DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >::GenerateRandom().

template<class T >
bool NameValuePairs::GetThisPointer ( T *&  ptr) const
inlineinherited

Get a pointer to this object.

Template Parameters
Tclass or type
Parameters
ptrreference to a pointer to a variable that receives the value

Definition at line 306 of file cryptlib.h.

template<class T >
bool NameValuePairs::GetValue ( const char *  name,
T &  value 
) const
inlineinherited
template<class T >
T NameValuePairs::GetValueWithDefault ( const char *  name,
defaultValue 
) const
inlineinherited
std::string NameValuePairs::GetValueNames ( ) const
inlineinherited

Get a list of value names that can be retrieved.

Returns
a list of names available to retrieve

the items in the list are delimited with a colon.

Definition at line 344 of file cryptlib.h.

Referenced by TestDataNameValuePairs::GetVoidValue().

bool NameValuePairs::GetIntValue ( const char *  name,
int &  value 
) const
inlineinherited

Get a named value with type int.

Parameters
namethe name of the value to retrieve
valuethe value retrieved upon success
Returns
true if an int value was retrieved, false otherwise

GetIntValue() is used to ensure we don't accidentally try to get an unsigned int or some other type when we mean int (which is the most common case)

See also
GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 355 of file cryptlib.h.

Referenced by KDF2_RNG::GenerateBlock(), DL_GroupParameters_IntegerBased::GenerateRandom(), InvertibleRabinFunction::GenerateRandom(), InvertibleRWFunction::GenerateRandom(), InvertibleESIGNFunction::GenerateRandom(), InvertibleLUCFunction::GenerateRandom(), InvertibleRSAFunction::GenerateRandom(), and DL_GroupParameters_DSA::GenerateRandom().

int NameValuePairs::GetIntValueWithDefault ( const char *  name,
int  defaultValue 
) const
inlineinherited
static void NameValuePairs::ThrowIfTypeMismatch ( const char *  name,
const std::type_info &  stored,
const std::type_info &  retrieving 
)
inlinestaticinherited

Ensures an expected name and type is present.

Parameters
namethe name of the value
storedthe type that was stored for the name
retrievingthe type that is being retrieved for the name
Exceptions
ValueTypeMismatch

ThrowIfTypeMismatch() effectively performs a type safety check. stored and retrieving are C++ mangled names for the type.

See also
GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 376 of file cryptlib.h.

Referenced by CombinedNameValuePairs::GetVoidValue().

template<class T >
void NameValuePairs::GetRequiredParameter ( const char *  className,
const char *  name,
T &  value 
) const
inlineinherited

Retrieves a required name/value pair.

Template Parameters
Tclass or type
Parameters
classNamethe name of the class
namethe name of the value
valuereference to a variable to receive the value
Exceptions
InvalidArgument

GetRequiredParameter() throws InvalidArgument if the name is not present or not of the expected type T.

See also
GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 390 of file cryptlib.h.

Referenced by DL_GroupParameters_EC< EC >::AssignFrom(), StringStore::CopyRangeTo2(), BaseN_Decoder::IsolatedInitialize(), Grouper::IsolatedInitialize(), and RandomNumberSink::IsolatedInitialize().

void NameValuePairs::GetRequiredIntParameter ( const char *  className,
const char *  name,
int &  value 
) const
inlineinherited

Retrieves a required name/value pair.

Parameters
classNamethe name of the class
namethe name of the value
valuereference to a variable to receive the value
Exceptions
InvalidArgument

GetRequiredParameter() throws InvalidArgument if the name is not present or not of the expected type T.

See also
GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Definition at line 405 of file cryptlib.h.

References g_nullNameValuePairs.

Referenced by StringStore::CopyRangeTo2(), and BaseN_Decoder::IsolatedInitialize().


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