summaryrefslogtreecommitdiff
path: root/asn.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-18 02:34:33 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-18 02:34:33 +0000
commitdaec4644fb12b026eb5210827fe66cae3928635a (patch)
tree9732b0bb2e34535743af1bc3680de2ea8d013710 /asn.h
parentecf8b8bd23401e833a901eb10ba06d0ab9482f88 (diff)
downloadcryptopp-daec4644fb12b026eb5210827fe66cae3928635a.tar.gz
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
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 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 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;
};