From daec4644fb12b026eb5210827fe66cae3928635a Mon Sep 17 00:00:00 2001 From: weidai Date: Mon, 18 Dec 2006 02:34:33 +0000 Subject: update version number, port to Sun C++ 5.8 git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@265 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- asn.h | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'asn.h') diff --git a/asn.h b/asn.h index 3d8907b..ab92991 100644 --- a/asn.h +++ b/asn.h @@ -230,46 +230,61 @@ public: } }; -//! key that can be ASN.1 encoded -/** derived class should override either BERDecodeKey or BERDecodeKey2 */ -class CRYPTOPP_DLL ASN1Key : public ASN1CryptoMaterial +//! _ +template +class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ASN1CryptoMaterial : public ASN1Object, public BASE { public: - virtual OID GetAlgorithmID() const =0; - virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt) - {BERDecodeNull(bt); return false;} - virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const - {DEREncodeNull(bt); return false;} // see RFC 2459, section 7.3.1 - //! decode subjectPublicKey part of subjectPublicKeyInfo, or privateKey part of privateKeyInfo, without the BIT STRING or OCTET STRING header - virtual void BERDecodeKey(BufferedTransformation &bt) {assert(false);} - virtual void BERDecodeKey2(BufferedTransformation &bt, bool parametersPresent, size_t size) - {BERDecodeKey(bt);} - //! encode subjectPublicKey part of subjectPublicKeyInfo, or privateKey part of privateKeyInfo, without the BIT STRING or OCTET STRING header - virtual void DEREncodeKey(BufferedTransformation &bt) const =0; + void Save(BufferedTransformation &bt) const + {BEREncode(bt);} + void Load(BufferedTransformation &bt) + {BERDecode(bt);} }; //! encodes/decodes subjectPublicKeyInfo -class CRYPTOPP_DLL X509PublicKey : virtual public ASN1Key, public PublicKey +class CRYPTOPP_DLL X509PublicKey : public ASN1CryptoMaterial { public: void BERDecode(BufferedTransformation &bt); void DEREncode(BufferedTransformation &bt) const; + + virtual OID GetAlgorithmID() const =0; + virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt) + {BERDecodeNull(bt); return false;} + virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const + {DEREncodeNull(bt); return false;} // see RFC 2459, section 7.3.1 + + //! decode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header + virtual void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size) =0; + //! encode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header + virtual void DEREncodePublicKey(BufferedTransformation &bt) const =0; }; //! encodes/decodes privateKeyInfo -class CRYPTOPP_DLL PKCS8PrivateKey : virtual public ASN1Key, public PrivateKey +class CRYPTOPP_DLL PKCS8PrivateKey : public ASN1CryptoMaterial { public: void BERDecode(BufferedTransformation &bt); void DEREncode(BufferedTransformation &bt) const; + virtual OID GetAlgorithmID() const =0; + virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt) + {BERDecodeNull(bt); return false;} + virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const + {DEREncodeNull(bt); return false;} // see RFC 2459, section 7.3.1 + + //! decode privateKey part of privateKeyInfo, without the OCTET STRING header + virtual void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size) =0; + //! encode privateKey part of privateKeyInfo, without the OCTET STRING header + virtual void DEREncodePrivateKey(BufferedTransformation &bt) const =0; + //! decode optional attributes including context-specific tag /*! /note default implementation stores attributes to be output in DEREncodeOptionalAttributes */ virtual void BERDecodeOptionalAttributes(BufferedTransformation &bt); //! encode optional attributes including context-specific tag virtual void DEREncodeOptionalAttributes(BufferedTransformation &bt) const; -private: +protected: ByteQueue m_optionalAttributes; }; -- cgit v1.2.1