234
template <class BASE>
235
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ASN1CryptoMaterial : public ASN1Object, public BASE
233
//! key that can be ASN.1 encoded
234
/** derived class should override either BERDecodeKey or BERDecodeKey2 */
235
class CRYPTOPP_DLL ASN1Key : public ASN1CryptoMaterial
238
void Save(BufferedTransformation &bt) const
240
void Load(BufferedTransformation &bt)
238
virtual OID GetAlgorithmID() const =0;
239
virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt)
240
{BERDecodeNull(bt); return false;}
241
virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const
242
{DEREncodeNull(bt); return false;} // see RFC 2459, section 7.3.1
243
//! decode subjectPublicKey part of subjectPublicKeyInfo, or privateKey part of privateKeyInfo, without the BIT STRING or OCTET STRING header
244
virtual void BERDecodeKey(BufferedTransformation &bt) {assert(false);}
245
virtual void BERDecodeKey2(BufferedTransformation &bt, bool parametersPresent, size_t size)
247
//! encode subjectPublicKey part of subjectPublicKeyInfo, or privateKey part of privateKeyInfo, without the BIT STRING or OCTET STRING header
248
virtual void DEREncodeKey(BufferedTransformation &bt) const =0;
244
251
//! encodes/decodes subjectPublicKeyInfo
245
class CRYPTOPP_DLL X509PublicKey : public ASN1CryptoMaterial<PublicKey>
252
class CRYPTOPP_DLL X509PublicKey : virtual public ASN1Key, public PublicKey
248
255
void BERDecode(BufferedTransformation &bt);
249
256
void DEREncode(BufferedTransformation &bt) const;
251
virtual OID GetAlgorithmID() const =0;
252
virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt)
253
{BERDecodeNull(bt); return false;}
254
virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const
255
{DEREncodeNull(bt); return false;} // see RFC 2459, section 7.3.1
257
//! decode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header
258
virtual void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size) =0;
259
//! encode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header
260
virtual void DEREncodePublicKey(BufferedTransformation &bt) const =0;
263
259
//! encodes/decodes privateKeyInfo
264
class CRYPTOPP_DLL PKCS8PrivateKey : public ASN1CryptoMaterial<PrivateKey>
260
class CRYPTOPP_DLL PKCS8PrivateKey : virtual public ASN1Key, public PrivateKey
267
263
void BERDecode(BufferedTransformation &bt);
268
264
void DEREncode(BufferedTransformation &bt) const;
270
virtual OID GetAlgorithmID() const =0;
271
virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt)
272
{BERDecodeNull(bt); return false;}
273
virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const
274
{DEREncodeNull(bt); return false;} // see RFC 2459, section 7.3.1
276
//! decode privateKey part of privateKeyInfo, without the OCTET STRING header
277
virtual void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size) =0;
278
//! encode privateKey part of privateKeyInfo, without the OCTET STRING header
279
virtual void DEREncodePrivateKey(BufferedTransformation &bt) const =0;
281
266
//! decode optional attributes including context-specific tag
282
267
/*! /note default implementation stores attributes to be output in DEREncodeOptionalAttributes */
283
268
virtual void BERDecodeOptionalAttributes(BufferedTransformation &bt);
284
269
//! encode optional attributes including context-specific tag
285
270
virtual void DEREncodeOptionalAttributes(BufferedTransformation &bt) const;
288
273
ByteQueue m_optionalAttributes;