EC private key. More...
Public Types | |
typedef EC::Point | Element |
typedef EC::Point | Element |
typedef DL_GroupParameters_EC< EC > | GroupParameters |
Public Member Functions | |
void | Initialize (const DL_GroupParameters_EC< EC > ¶ms, const Integer &x) |
void | Initialize (const EC &ec, const Element &G, const Integer &n, const Integer &x) |
void | Initialize (RandomNumberGenerator &rng, const DL_GroupParameters_EC< EC > ¶ms) |
void | Initialize (RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n) |
void | BERDecodePrivateKey (BufferedTransformation &bt, bool parametersPresent, size_t size) |
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 | Initialize (const DL_GroupParameters_EC< EC > ¶ms, const Integer &x) |
void | Initialize (const EC &ec, const Element &G, const Integer &n, const Integer &x) |
void | Initialize (RandomNumberGenerator &rng, const DL_GroupParameters_EC< EC > ¶ms) |
void | Initialize (RandomNumberGenerator &rng, const EC &ec, const Element &G, const Integer &n) |
void | BERDecodePrivateKey (BufferedTransformation &bt, bool parametersPresent, size_t size) |
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 | |
bool | Validate (RandomNumberGenerator &rng, unsigned int level) const |
Check this object for errors. | |
bool | GetVoidValue (const char *name, const std::type_info &valueType, void *pValue) const |
void | AssignFrom (const NameValuePairs &source) |
void | GenerateRandom (RandomNumberGenerator &rng, const NameValuePairs ¶ms) |
Generate a random key or crypto parameters. | |
bool | SupportsPrecomputation () const |
Determines whether the object supports precomputation. | |
void | Precompute (unsigned int precomputationStorage=16) |
Perform precomputation. | |
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 Integer & | GetPrivateExponent () const |
void | SetPrivateExponent (const Integer &x) |
void | MakePublicKey (DL_PublicKey< DL_GroupParameters_EC< EC >::Element > &pub) const |
OID | GetAlgorithmID () const |
bool | BERDecodeAlgorithmParameters (BufferedTransformation &bt) |
bool | DEREncodeAlgorithmParameters (BufferedTransformation &bt) const |
const DL_GroupParameters_EC< EC > & | GetGroupParameters () const |
DL_GroupParameters_EC< EC > & | AccessGroupParameters () |
void | BERDecode (BufferedTransformation &bt) |
Decode this object from a BufferedTransformation. | |
void | DEREncode (BufferedTransformation &bt) const |
Encode this object into a BufferedTransformation. | |
virtual void | BERDecodeOptionalAttributes (BufferedTransformation &bt) |
decode optional attributes including context-specific tag | |
virtual void | DEREncodeOptionalAttributes (BufferedTransformation &bt) const |
encode optional attributes including context-specific tag | |
void | Save (BufferedTransformation &bt) const |
Saves a key to a BufferedTransformation. | |
void | Load (BufferedTransformation &bt) |
Loads a key from a BufferedTransformation. | |
virtual void | BEREncode (BufferedTransformation &bt) const |
Encode this object into a BufferedTransformation. | |
void | GenerateRandomWithKeySize (RandomNumberGenerator &rng, unsigned int keySize) |
Generate a random key or crypto parameters. | |
virtual void | ThrowIfInvalid (RandomNumberGenerator &rng, unsigned int level) const |
Check this object for errors. | |
void | DoQuickSanityCheck () const |
template<class T > | |
bool | GetThisObject (T &object) const |
Get a copy of this object or subobject. | |
template<class T > | |
bool | GetThisPointer (T *&ptr) const |
Get a pointer to this object. | |
template<class T > | |
bool | GetValue (const char *name, T &value) const |
Get a named value. | |
template<class T > | |
T | GetValueWithDefault (const char *name, T defaultValue) const |
Get a named value. | |
std::string | GetValueNames () const |
Get a list of value names that can be retrieved. | |
bool | GetIntValue (const char *name, int &value) const |
Get a named value with type int. | |
int | GetIntValueWithDefault (const char *name, int defaultValue) const |
Get a named value with type int, with default. | |
template<class T > | |
void | GetRequiredParameter (const char *className, const char *name, T &value) const |
Retrieves a required name/value pair. | |
void | GetRequiredIntParameter (const char *className, const char *name, int &value) const |
Retrieves a required name/value pair. | |
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. | |
Protected Attributes | |
ByteQueue | m_optionalAttributes |
EC private key.
Definition at line 171 of file eccrypto.h.
bool DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >::Validate | ( | RandomNumberGenerator & | rng, | |
unsigned int | level | |||
) | const [inline, virtual, inherited] |
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.
Implements CryptoMaterial.
Definition at line 973 of file pubkey.h.
References Integer::Gcd(), and Integer::One().
void DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >::GenerateRandom | ( | RandomNumberGenerator & | rng, | |
const NameValuePairs & | params | |||
) | [inline, virtual, inherited] |
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 from GeneratableCryptoMaterial.
Definition at line 996 of file pubkey.h.
References NameValuePairs::GetThisObject(), and Integer::One().
bool DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >::SupportsPrecomputation | ( | ) | const [inline, virtual, inherited] |
Determines whether the object supports precomputation.
Reimplemented from CryptoMaterial.
void DL_PrivateKeyImpl< DL_GroupParameters_EC< EC > >::Precompute | ( | unsigned int | precomputationStorage = 16 |
) | [inline, virtual, inherited] |
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 from CryptoMaterial.
void PKCS8PrivateKey::BERDecode | ( | BufferedTransformation & | bt | ) | [virtual, inherited] |
Decode this object from a BufferedTransformation.
bt | BufferedTransformation object |
Uses Basic Encoding Rules (BER)
Implements ASN1Object.
Reimplemented in InvertibleRSAFunction.
Definition at line 556 of file asn.cpp.
References PKCS8PrivateKey::BERDecodeOptionalAttributes(), and PKCS8PrivateKey::BERDecodePrivateKey().
Referenced by InvertibleRSAFunction::BERDecode(), and InvertibleRSAFunction::Load().
void PKCS8PrivateKey::DEREncode | ( | BufferedTransformation & | bt | ) | const [virtual, inherited] |
Encode this object into a BufferedTransformation.
bt | BufferedTransformation object |
Uses Distinguished Encoding Rules (DER)
Implements ASN1Object.
Reimplemented in InvertibleRSAFunction.
Definition at line 576 of file asn.cpp.
References PKCS8PrivateKey::DEREncodeOptionalAttributes(), and PKCS8PrivateKey::DEREncodePrivateKey().
Referenced by InvertibleRSAFunction::DEREncode(), and InvertibleRSAFunction::Save().
void PKCS8PrivateKey::BERDecodeOptionalAttributes | ( | BufferedTransformation & | bt | ) | [virtual, inherited] |
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.
Referenced by PKCS8PrivateKey::BERDecode().
void ASN1CryptoMaterial< PrivateKey >::Save | ( | BufferedTransformation & | bt | ) | const [inline, virtual, inherited] |
Reimplemented from CryptoMaterial.
Reimplemented in InvertibleRSAFunction.
void ASN1CryptoMaterial< PrivateKey >::Load | ( | BufferedTransformation & | bt | ) | [inline, virtual, inherited] |
Reimplemented from CryptoMaterial.
Reimplemented in InvertibleRSAFunction.
virtual void ASN1Object::BEREncode | ( | BufferedTransformation & | bt | ) | const [inline, virtual, inherited] |
Encode this object into a BufferedTransformation.
bt | BufferedTransformation object |
Uses Basic Encoding Rules (BER).
This may be useful if DEREncode() would be too inefficient.
Definition at line 2649 of file cryptlib.h.
void GeneratableCryptoMaterial::GenerateRandomWithKeySize | ( | RandomNumberGenerator & | rng, | |
unsigned int | keySize | |||
) | [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 GeneratableCryptoMaterial::GenerateRandom(), and MakeParameters().
virtual void CryptoMaterial::ThrowIfInvalid | ( | RandomNumberGenerator & | rng, | |
unsigned int | level | |||
) | const [inline, virtual, inherited] |
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 1939 of file cryptlib.h.
bool NameValuePairs::GetThisObject | ( | T & | object | ) | const [inline, inherited] |
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().
bool NameValuePairs::GetThisPointer | ( | T *& | ptr | ) | const [inline, inherited] |
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.
bool NameValuePairs::GetValue | ( | const char * | name, | |
T & | value | |||
) | const [inline, inherited] |
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(), DL_GroupParameters_IntegerBased::GenerateRandom(), DL_GroupParameters_DSA::GenerateRandom(), InvertibleESIGNFunction::GenerateRandom(), Inflator::IsolatedInitialize(), StringSinkTemplate< T >::IsolatedInitialize(), ArraySink::IsolatedInitialize(), FileSink::IsolatedInitialize(), and Grouper::IsolatedInitialize().
T NameValuePairs::GetValueWithDefault | ( | const char * | name, | |
T | defaultValue | |||
) | const [inline, inherited] |
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(), InvertibleRSAFunction::GenerateRandom(), InvertibleLUCFunction::GenerateRandom(), DL_GroupParameters_IntegerBased::GenerateRandom(), DL_GroupParameters_DSA::GenerateRandom(), InvertibleESIGNFunction::GenerateRandom(), Redirector::Initialize(), Deflator::IsolatedInitialize(), SignerFilter::IsolatedInitialize(), HashFilter::IsolatedInitialize(), FileSink::IsolatedInitialize(), and Base64URLEncoder::IsolatedInitialize().
std::string NameValuePairs::GetValueNames | ( | ) | const [inline, inherited] |
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.
bool NameValuePairs::GetIntValue | ( | const char * | name, | |
int & | value | |||
) | const [inline, inherited] |
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 InvertibleRWFunction::GenerateRandom(), InvertibleRSAFunction::GenerateRandom(), InvertibleRabinFunction::GenerateRandom(), InvertibleLUCFunction::GenerateRandom(), DL_GroupParameters_IntegerBased::GenerateRandom(), DL_GroupParameters_DSA::GenerateRandom(), and InvertibleESIGNFunction::GenerateRandom().
int NameValuePairs::GetIntValueWithDefault | ( | const char * | name, | |
int | defaultValue | |||
) | const [inline, inherited] |
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(), Redirector::Initialize(), Deflator::IsolatedInitialize(), ByteQueue::IsolatedInitialize(), HashFilter::IsolatedInitialize(), Grouper::IsolatedInitialize(), Base64URLEncoder::IsolatedInitialize(), VMAC_Base::UncheckedSetKey(), SAFER::Base::UncheckedSetKey(), and Weak1::ARC4_Base::UncheckedSetKey().
static void NameValuePairs::ThrowIfTypeMismatch | ( | const char * | name, | |
const std::type_info & | stored, | |||
const std::type_info & | retrieving | |||
) | [inline, static, inherited] |
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 DL_GroupParameters_EC< EC >::GetVoidValue().
void NameValuePairs::GetRequiredParameter | ( | const char * | className, | |
const char * | name, | |||
T & | value | |||
) | const [inline, inherited] |
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(), RandomNumberSink::IsolatedInitialize(), Grouper::IsolatedInitialize(), and BaseN_Decoder::IsolatedInitialize().
void NameValuePairs::GetRequiredIntParameter | ( | const char * | className, | |
const char * | name, | |||
int & | value | |||
) | const [inline, inherited] |
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.
Referenced by BaseN_Decoder::IsolatedInitialize().