Crypto++
5.6.3
Free C++ class library of cryptographic schemes
|
Interface for private keys. More...
Public Member Functions | |
virtual void | GenerateRandom (RandomNumberGenerator &rng, const NameValuePairs ¶ms=g_nullNameValuePairs) |
Generate a random key or crypto parameters. More... | |
void | GenerateRandomWithKeySize (RandomNumberGenerator &rng, unsigned int keySize) |
Generate a random key or crypto parameters. More... | |
virtual void | AssignFrom (const NameValuePairs &source)=0 |
Assign values to this object. More... | |
virtual bool | Validate (RandomNumberGenerator &rng, unsigned int level) const =0 |
Check this object for errors. More... | |
virtual void | ThrowIfInvalid (RandomNumberGenerator &rng, unsigned int level) const |
Check this object for errors. More... | |
virtual void | Save (BufferedTransformation &bt) const |
Saves a key to a BufferedTransformation. More... | |
virtual void | Load (BufferedTransformation &bt) |
Loads a key from a BufferedTransformation. More... | |
virtual bool | SupportsPrecomputation () const |
Determines whether the object supports precomputation. More... | |
virtual void | Precompute (unsigned int precomputationStorage) |
Perform precomputation. More... | |
virtual void | LoadPrecomputation (BufferedTransformation &storedPrecomputation) |
retrieve previously saved precomputation | |
virtual void | SavePrecomputation (BufferedTransformation &storedPrecomputation) const |
save precomputation for later use | |
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 > | |
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... | |
virtual bool | GetVoidValue (const char *name, const std::type_info &valueType, void *pValue) const =0 |
Get a named value. 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... | |
Interface for private keys.
Definition at line 2044 of file cryptlib.h.
|
inlinevirtualinherited |
Generate a random key or crypto parameters.
rng | a RandomNumberGenerator to produce keying material |
params | additional initialization parameters |
KeyingErr | if 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 in DL_PrivateKeyImpl< GP >, DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >, DL_GroupParameters_DSA, InvertibleRSAFunction, InvertibleLUCFunction, InvertibleESIGNFunction, InvertibleRWFunction, InvertibleRabinFunction, DL_GroupParameters_EC< EC >, and DL_GroupParameters_IntegerBased.
Definition at line 2018 of file cryptlib.h.
Referenced by TestDataNameValuePairs::GetVoidValue(), InvertibleRWFunction::Load(), and InvertibleRSAFunction::Save().
|
inherited |
Generate a random key or crypto parameters.
rng | a RandomNumberGenerator to produce keying material |
keySize | the size of the key, in bits |
KeyingErr | if 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().
|
pure virtualinherited |
Assign values to this object.
This function can be used to create a public key from a private key.
Implemented in DL_PublicKeyImpl< GP >, DL_PublicKeyImpl< DL_GroupParameters_EC< EC > >, DL_PrivateKeyImpl< GP >, DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >, DL_GroupParameters_IntegerBasedImpl< GROUP_PRECOMP, BASE_PRECOMP >, DL_GroupParameters_IntegerBasedImpl< DL_GroupPrecomputation_LUC, DL_BasePrecomputation_LUC >, DL_GroupParameters_IntegerBasedImpl< ModExpPrecomputation >, InvertibleRSAFunction, InvertibleLUCFunction, InvertibleESIGNFunction, InvertibleRWFunction, InvertibleRabinFunction, DL_GroupParameters_EC< EC >, DL_GroupParameters_IntegerBased, LUCFunction, RWFunction, RSAFunction, RabinFunction, ESIGNFunction, and XTR_DH.
Referenced by TestDataNameValuePairs::GetVoidValue(), InvertibleRWFunction::Load(), and InvertibleRSAFunction::Save().
|
pure virtualinherited |
Check this object for errors.
rng | a RandomNumberGenerator for objects which use randomized testing |
level | the level of thoroughness |
There are four levels of thoroughness:
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.
Implemented in DL_PublicKeyImpl< GP >, DL_PublicKeyImpl< DL_GroupParameters_EC< EC > >, DL_PrivateKeyImpl< GP >, DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >, DL_GroupParameters< T >, DL_GroupParameters< Integer >, DL_GroupParameters< typename EcPrecomputation< EC >::Element >, InvertibleRSAFunction, InvertibleLUCFunction, InvertibleESIGNFunction, InvertibleRWFunction, InvertibleRabinFunction, LUCFunction, RWFunction, RSAFunction, RabinFunction, ESIGNFunction, and XTR_DH.
Referenced by FixedRNG::GenerateBlock(), TestDataNameValuePairs::GetVoidValue(), InvertibleRWFunction::Load(), and InvertibleRSAFunction::Save().
|
inlinevirtualinherited |
Check this object for errors.
rng | a RandomNumberGenerator for objects which use randomized testing |
level | the level of thoroughness |
InvalidMaterial |
Internally, ThrowIfInvalid() calls Validate() and throws InvalidMaterial if validation fails.
Definition at line 1938 of file cryptlib.h.
|
inlinevirtualinherited |
Saves a key to a BufferedTransformation.
bt | the destination BufferedTransformation |
NotImplemented |
Save writes the material to a BufferedTransformation.
If the material is a key, then the key is written with ASN.1 DER encoding. The key includes an object identifier with an algorthm id, like a subjectPublicKeyInfo.
A "raw" key without the "key info" can be saved using a key's DEREncode method.
If a derived class does not override Save, then the base class throws NotImplemented.
Reimplemented in InvertibleRSAFunction, InvertibleRWFunction, and RWFunction.
Definition at line 1950 of file cryptlib.h.
Referenced by TestDataNameValuePairs::GetVoidValue().
|
inlinevirtualinherited |
Loads a key from a BufferedTransformation.
bt | the source BufferedTransformation |
KeyingErr |
Load attempts to read material from a BufferedTransformation. If the material is a key that was generated outside the library, then the following usually applies:
"key info" means the key should have an object identifier with an algorthm id, like a subjectPublicKeyInfo.
To read a "raw" key without the "key info", then call the key's BERDecode method.
Reimplemented in InvertibleRSAFunction, InvertibleRWFunction, and RWFunction.
Definition at line 1967 of file cryptlib.h.
Referenced by TestDataNameValuePairs::GetVoidValue().
|
inlinevirtualinherited |
Determines whether the object supports precomputation.
Reimplemented in DL_PublicKeyImpl< GP >, DL_PublicKeyImpl< DL_GroupParameters_EC< EC > >, DL_PrivateKeyImpl< GP >, DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >, DL_GroupParameters< T >, DL_GroupParameters< Integer >, and DL_GroupParameters< typename EcPrecomputation< EC >::Element >.
Definition at line 1972 of file cryptlib.h.
|
inlinevirtualinherited |
Perform precomputation.
precomputationStorage | the suggested number of objects for the precompute table |
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 in DL_PublicKeyImpl< GP >, DL_PublicKeyImpl< DL_GroupParameters_EC< EC > >, DL_PrivateKeyImpl< GP >, DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >, DL_GroupParameters< T >, DL_GroupParameters< Integer >, and DL_GroupParameters< typename EcPrecomputation< EC >::Element >.
Definition at line 1981 of file cryptlib.h.
|
inlineinherited |
Get a copy of this object or subobject.
T | class or type |
object | reference to a variable that receives the value |
Definition at line 297 of file cryptlib.h.
Referenced by DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >::GenerateRandom().
|
inlineinherited |
Get a pointer to this object.
T | class or type |
ptr | reference to a pointer to a variable that receives the value |
Definition at line 306 of file cryptlib.h.
|
inlineinherited |
Get a named value.
T | class or type |
name | the name of the object or value to retrieve |
value | reference to a variable that receives the value |
Definition at line 319 of file cryptlib.h.
Referenced by DL_GroupParameters_EC< EC >::AssignFrom(), KDF2_RNG::GenerateBlock(), DL_GroupParameters_IntegerBased::GenerateRandom(), InvertibleESIGNFunction::GenerateRandom(), DL_GroupParameters_DSA::GenerateRandom(), Store::GetNextMessage(), TestDataNameValuePairs::GetVoidValue(), FileSink::IsolatedInitialize(), Inflator::IsolatedInitialize(), Grouper::IsolatedInitialize(), StringSinkTemplate< T >::IsolatedInitialize(), ArraySink::IsolatedInitialize(), OAEP_Base::MaxUnpaddedLength(), and SimpleKeyingInterface::SetKeyWithIV().
|
inlineinherited |
Get a named value.
T | class or type |
name | the name of the object or value to retrieve |
defaultValue | the default value of the class or type if it does not exist |
Definition at line 332 of file cryptlib.h.
Referenced by DL_GroupParameters_EC< EC >::AssignFrom(), AuthenticatedDecryptionFilter::AuthenticatedDecryptionFilter(), KDF2_RNG::GenerateBlock(), DL_GroupParameters_IntegerBased::GenerateRandom(), InvertibleESIGNFunction::GenerateRandom(), InvertibleLUCFunction::GenerateRandom(), InvertibleRSAFunction::GenerateRandom(), DL_GroupParameters_DSA::GenerateRandom(), Redirector::Initialize(), Deflator::IsolatedInitialize(), FileSink::IsolatedInitialize(), Base64URLEncoder::IsolatedInitialize(), HashFilter::IsolatedInitialize(), SignerFilter::IsolatedInitialize(), CBC_CTS_Encryption::MinLastBlockSize(), HashFilter::Put2(), SignerFilter::Put2(), and ArrayXorSink::Put2().
|
inlineinherited |
Get a list of value names that can be retrieved.
the items in the list are delimited with a colon.
Definition at line 344 of file cryptlib.h.
Referenced by TestDataNameValuePairs::GetVoidValue().
|
inlineinherited |
Get a named value with type int.
name | the name of the value to retrieve |
value | the value retrieved upon success |
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)
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().
|
inlineinherited |
Get a named value with type int, with default.
name | the name of the value to retrieve |
defaultValue | the default value if the name does not exist |
Definition at line 364 of file cryptlib.h.
Referenced by DL_GroupParameters_IntegerBased::GenerateRandom(), TestDataNameValuePairs::GetVoidValue(), Redirector::Initialize(), ByteQueue::IsolatedInitialize(), Deflator::IsolatedInitialize(), Base64URLEncoder::IsolatedInitialize(), Grouper::IsolatedInitialize(), HashFilter::IsolatedInitialize(), HashFilter::Put2(), VariableRounds< 6, 2 >::StaticGetDefaultRounds(), SAFER::Base::UncheckedSetKey(), and VMAC_Base::UncheckedSetKey().
|
inlinestaticinherited |
Ensures an expected name and type is present.
name | the name of the value |
stored | the type that was stored for the name |
retrieving | the type that is being retrieved for the name |
ValueTypeMismatch |
ThrowIfTypeMismatch() effectively performs a type safety check. stored and retrieving are C++ mangled names for the type.
Definition at line 376 of file cryptlib.h.
Referenced by CombinedNameValuePairs::GetVoidValue().
|
inlineinherited |
Retrieves a required name/value pair.
T | class or type |
className | the name of the class |
name | the name of the value |
value | reference to a variable to receive the value |
InvalidArgument |
GetRequiredParameter() throws InvalidArgument if the name is not present or not of the expected type T.
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().
|
inlineinherited |
Retrieves a required name/value pair.
className | the name of the class |
name | the name of the value |
value | reference to a variable to receive the value |
InvalidArgument |
GetRequiredParameter() throws InvalidArgument if the name is not present or not of the expected type T.
Definition at line 405 of file cryptlib.h.
References g_nullNameValuePairs.
Referenced by StringStore::CopyRangeTo2(), and BaseN_Decoder::IsolatedInitialize().
|
pure virtualinherited |
Get a named value.
name | the name of the object or value to retrieve |
valueType | reference to a variable that receives the value |
pValue | void pointer to a variable that receives the value |
GetVoidValue() retrives the value of name if it exists.
Implemented in DL_PublicKeyImpl< GP >, DL_PublicKeyImpl< DL_GroupParameters_EC< EC > >, DL_PrivateKeyImpl< GP >, DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >, DL_GroupParameters< T >, DL_GroupParameters< Integer >, DL_GroupParameters< typename EcPrecomputation< EC >::Element >, AlgorithmParameters, DL_GroupParameters_LUC, TestDataNameValuePairs, DL_GroupParameters_GFP, DL_GroupParameters_IntegerBasedImpl< GROUP_PRECOMP, BASE_PRECOMP >, DL_GroupParameters_IntegerBasedImpl< DL_GroupPrecomputation_LUC, DL_BasePrecomputation_LUC >, DL_GroupParameters_IntegerBasedImpl< ModExpPrecomputation >, CombinedNameValuePairs, InvertibleRSAFunction, InvertibleLUCFunction, InvertibleESIGNFunction, InvertibleRWFunction, NullNameValuePairs, InvertibleRabinFunction, DL_GroupParameters_EC< EC >, DL_GroupParameters_IntegerBased, LUCFunction, RWFunction, RSAFunction, RabinFunction, ESIGNFunction, and XTR_DH.
Referenced by InvertibleRWFunction::Load(), and InvertibleRSAFunction::Save().