138
138
byte PeekByte() const;
139
139
void CheckByte(byte b);
141
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=NULL_CHANNEL, bool blocking=true);
142
size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=NULL_CHANNEL, bool blocking=true) const;
141
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true);
142
size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const;
144
144
// call this to denote end of sequence
145
145
void MessageEnd();
233
//! key that can be ASN.1 encoded
234
/** derived class should override either BERDecodeKey or BERDecodeKey2 */
235
class CRYPTOPP_DLL ASN1Key : public ASN1CryptoMaterial
234
template <class BASE>
235
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ASN1CryptoMaterial : public ASN1Object, public BASE
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;
238
void Save(BufferedTransformation &bt) const
240
void Load(BufferedTransformation &bt)
251
244
//! encodes/decodes subjectPublicKeyInfo
252
class CRYPTOPP_DLL X509PublicKey : virtual public ASN1Key, public PublicKey
245
class CRYPTOPP_DLL X509PublicKey : public ASN1CryptoMaterial<PublicKey>
255
248
void BERDecode(BufferedTransformation &bt);
256
249
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;
259
263
//! encodes/decodes privateKeyInfo
260
class CRYPTOPP_DLL PKCS8PrivateKey : virtual public ASN1Key, public PrivateKey
264
class CRYPTOPP_DLL PKCS8PrivateKey : public ASN1CryptoMaterial<PrivateKey>
263
267
void BERDecode(BufferedTransformation &bt);
264
268
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;
266
281
//! decode optional attributes including context-specific tag
267
282
/*! /note default implementation stores attributes to be output in DEREncodeOptionalAttributes */
268
283
virtual void BERDecodeOptionalAttributes(BufferedTransformation &bt);
269
284
//! encode optional attributes including context-specific tag
270
285
virtual void DEREncodeOptionalAttributes(BufferedTransformation &bt) const;
273
288
ByteQueue m_optionalAttributes;