summaryrefslogtreecommitdiff
path: root/asn.h
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2006-12-18 02:34:33 +0000
committerweidai <weidai11@users.noreply.github.com>2006-12-18 02:34:33 +0000
commit43b41c1042164bc5194f3f61a2ca131ea9014b4a (patch)
tree9732b0bb2e34535743af1bc3680de2ea8d013710 /asn.h
parent54a2acd0aab8ab74ae2c9b88805d259398a1b17e (diff)
downloadcryptopp-git-43b41c1042164bc5194f3f61a2ca131ea9014b4a.tar.gz
update version number, port to Sun C++ 5.8
Diffstat (limited to 'asn.h')
-rw-r--r--asn.h49
1 files changed, 32 insertions, 17 deletions
diff --git a/asn.h b/asn.h
index 3d8907bc..ab929918 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 BASE>
+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<PublicKey>
{
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<PrivateKey>
{
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;
};