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_PrivateKey_GFP< GP > Class Template Reference

DL private key (in GF(p) groups) More...

+ Inheritance diagram for DL_PrivateKey_GFP< GP >:

Public Types

typedef GP::Element Element
 
typedef GP GroupParameters
 

Public Member Functions

void Initialize (RandomNumberGenerator &rng, unsigned int modulusBits)
 
void Initialize (RandomNumberGenerator &rng, const Integer &p, const Integer &g)
 
void Initialize (RandomNumberGenerator &rng, const Integer &p, const Integer &q, const Integer &g)
 
void Initialize (const DL_GroupParameters_IntegerBased &params, const Integer &x)
 
void Initialize (const Integer &p, const Integer &g, const Integer &x)
 
void Initialize (const Integer &p, const Integer &q, const Integer &g, const Integer &x)
 
bool Validate (RandomNumberGenerator &rng, unsigned int level) const
 Check this object for errors. More...
 
bool GetVoidValue (const char *name, const std::type_info &valueType, void *pValue) const
 Get a named value. More...
 
void AssignFrom (const NameValuePairs &source)
 Assign values to this object. More...
 
void GenerateRandom (RandomNumberGenerator &rng, const NameValuePairs &params)
 Generate a random key or crypto parameters. 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
 
const DL_GroupParameters< Element > & GetAbstractGroupParameters () const
 
DL_GroupParameters< Element > & AccessAbstractGroupParameters ()
 
const IntegerGetPrivateExponent () const
 
void SetPrivateExponent (const Integer &x)
 
void BERDecodePrivateKey (BufferedTransformation &bt, bool, size_t)
 decode privateKey part of privateKeyInfo, without the OCTET STRING header
 
void DEREncodePrivateKey (BufferedTransformation &bt) const
 encode privateKey part of privateKeyInfo, without the OCTET STRING header
 
void MakePublicKey (DL_PublicKey< GP::Element > &pub) const
 
OID GetAlgorithmID () const
 
bool BERDecodeAlgorithmParameters (BufferedTransformation &bt)
 
bool DEREncodeAlgorithmParameters (BufferedTransformation &bt) const
 
const GP & GetGroupParameters () const
 
GP & AccessGroupParameters ()
 
void BERDecode (BufferedTransformation &bt)
 Decode this object from a BufferedTransformation. More...
 
void DEREncode (BufferedTransformation &bt) const
 Encode this object into a BufferedTransformation. More...
 
virtual void BERDecodeOptionalAttributes (BufferedTransformation &bt)
 decode optional attributes including context-specific tag More...
 
virtual void DEREncodeOptionalAttributes (BufferedTransformation &bt) const
 encode optional attributes including context-specific tag
 
void Save (BufferedTransformation &bt) const
 
void Load (BufferedTransformation &bt)
 
virtual void BEREncode (BufferedTransformation &bt) const
 Encode this object into a BufferedTransformation. More...
 
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 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

template<class GP>
class DL_PrivateKey_GFP< GP >

DL private key (in GF(p) groups)

Definition at line 275 of file gfpcrypt.h.

Member Function Documentation

template<class GP>
bool DL_PrivateKeyImpl< GP >::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 973 of file pubkey.h.

template<class GP>
bool DL_PrivateKeyImpl< GP >::GetVoidValue ( const char *  name,
const std::type_info &  valueType,
void *  pValue 
) const
inlinevirtualinherited

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()

Implements NameValuePairs.

Definition at line 986 of file pubkey.h.

template<class GP>
void DL_PrivateKeyImpl< GP >::AssignFrom ( const NameValuePairs source)
inlinevirtualinherited

Assign values to this object.

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

Implements CryptoMaterial.

Definition at line 991 of file pubkey.h.

template<class GP>
void DL_PrivateKeyImpl< GP >::GenerateRandom ( RandomNumberGenerator rng,
const NameValuePairs params 
)
inlinevirtualinherited

Generate a random key or crypto parameters.

Parameters
rnga RandomNumberGenerator to produce keying material
paramsadditional initialization parameters
Exceptions
KeyingErrif a key can't be generated or algorithm parameters are invalid

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

Reimplemented from GeneratableCryptoMaterial.

Definition at line 996 of file pubkey.h.

template<class GP>
bool DL_PrivateKeyImpl< GP >::SupportsPrecomputation ( ) const
inlinevirtualinherited

Determines whether the object supports precomputation.

Returns
true if the object supports precomputation, false otherwise

Reimplemented from CryptoMaterial.

Definition at line 1007 of file pubkey.h.

template<class GP>
void DL_PrivateKeyImpl< GP >::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 1009 of file pubkey.h.

void PKCS8PrivateKey::BERDecode ( BufferedTransformation bt)
virtualinherited

Decode this object from a BufferedTransformation.

Parameters
btBufferedTransformation object

Uses Basic Encoding Rules (BER)

Implements ASN1Object.

Reimplemented in InvertibleRSAFunction.

Definition at line 556 of file asn.cpp.

Referenced by InvertibleRSAFunction::BERDecode(), and InvertibleRSAFunction::Load().

void PKCS8PrivateKey::DEREncode ( BufferedTransformation bt) const
virtualinherited

Encode this object into a BufferedTransformation.

Parameters
btBufferedTransformation object

Uses Distinguished Encoding Rules (DER)

Implements ASN1Object.

Reimplemented in InvertibleRSAFunction.

Definition at line 576 of file asn.cpp.

Referenced by InvertibleRSAFunction::DEREncode(), and InvertibleRSAFunction::Save().

void PKCS8PrivateKey::BERDecodeOptionalAttributes ( BufferedTransformation bt)
virtualinherited

decode optional attributes including context-specific tag

/note default implementation stores attributes to be output in DEREncodeOptionalAttributes

Definition at line 594 of file asn.cpp.

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.

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 file: