From 61ec50dabe14c5d4582ac187706ea27645b3562b Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 29 Nov 2017 10:54:33 -0500 Subject: Change Doxygen comment style from //! to /// Also see https://groups.google.com/forum/#!topic/cryptopp-users/A7-Xt5Knlzw --- asn.h | 330 +++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 165 insertions(+), 165 deletions(-) (limited to 'asn.h') diff --git a/asn.h b/asn.h index 673b8042..66641997 100644 --- a/asn.h +++ b/asn.h @@ -1,7 +1,7 @@ // asn.h - originally written and placed in the public domain by Wei Dai -//! \file asn.h -//! \brief Classes and functions for working with ANS.1 objects +/// \file asn.h +/// \brief Classes and functions for working with ANS.1 objects #ifndef CRYPTOPP_ASN_H #define CRYPTOPP_ASN_H @@ -22,8 +22,8 @@ NAMESPACE_BEGIN(CryptoPP) -//! \brief ASN.1 types -//! \note These tags and flags are not complete +/// \brief ASN.1 types +/// \note These tags and flags are not complete enum ASNTag { BOOLEAN = 0x01, @@ -51,8 +51,8 @@ enum ASNTag GENERAL_STRING = 0x1b }; -//! \brief ASN.1 flags -//! \note These tags and flags are not complete +/// \brief ASN.1 flags +/// \note These tags and flags are not complete enum ASNIdFlag { UNIVERSAL = 0x00, @@ -65,140 +65,140 @@ enum ASNIdFlag PRIVATE = 0xc0 }; -//! \brief Raises a BERDecodeErr +/// \brief Raises a BERDecodeErr inline void BERDecodeError() {throw BERDecodeErr();} -//! \brief Exception thrown when an unknown object identifier is encountered +/// \brief Exception thrown when an unknown object identifier is encountered class CRYPTOPP_DLL UnknownOID : public BERDecodeErr { public: - //! \brief Construct an UnknownOID + /// \brief Construct an UnknownOID UnknownOID() : BERDecodeErr("BER decode error: unknown object identifier") {} - //! \brief Construct an UnknownOID - //! \param err error message to use for the execption + /// \brief Construct an UnknownOID + /// \param err error message to use for the execption UnknownOID(const char *err) : BERDecodeErr(err) {} }; // unsigned int DERLengthEncode(unsigned int length, byte *output=0); -//! \brief DER encode a length -//! \param bt BufferedTransformation object for writing -//! \param length the size to encode -//! \returns the number of octets used for the encoding +/// \brief DER encode a length +/// \param bt BufferedTransformation object for writing +/// \param length the size to encode +/// \returns the number of octets used for the encoding CRYPTOPP_DLL size_t CRYPTOPP_API DERLengthEncode(BufferedTransformation &bt, lword length); -//! \brief BER decode a length -//! \param bt BufferedTransformation object for reading -//! \param length the decoded size -//! \returns true if the value was decoded -//! \throws BERDecodeError if the value fails to decode or is too large for size_t -//! \details BERLengthDecode() returns false if the encoding is indefinite length. +/// \brief BER decode a length +/// \param bt BufferedTransformation object for reading +/// \param length the decoded size +/// \returns true if the value was decoded +/// \throws BERDecodeError if the value fails to decode or is too large for size_t +/// \details BERLengthDecode() returns false if the encoding is indefinite length. CRYPTOPP_DLL bool CRYPTOPP_API BERLengthDecode(BufferedTransformation &bt, size_t &length); -//! \brief DER encode NULL -//! \param bt BufferedTransformation object for writing +/// \brief DER encode NULL +/// \param bt BufferedTransformation object for writing CRYPTOPP_DLL void CRYPTOPP_API DEREncodeNull(BufferedTransformation &bt); -//! \brief BER decode NULL -//! \param bt BufferedTransformation object for reading +/// \brief BER decode NULL +/// \param bt BufferedTransformation object for reading CRYPTOPP_DLL void CRYPTOPP_API BERDecodeNull(BufferedTransformation &bt); -//! \brief DER encode octet string -//! \param bt BufferedTransformation object for writing -//! \param str the string to encode -//! \param strLen the length of the string -//! \returns the number of octets used for the encoding +/// \brief DER encode octet string +/// \param bt BufferedTransformation object for writing +/// \param str the string to encode +/// \param strLen the length of the string +/// \returns the number of octets used for the encoding CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeOctetString(BufferedTransformation &bt, const byte *str, size_t strLen); -//! \brief DER encode octet string -//! \param bt BufferedTransformation object for reading -//! \param str the string to encode -//! \returns the number of octets used for the encoding +/// \brief DER encode octet string +/// \param bt BufferedTransformation object for reading +/// \param str the string to encode +/// \returns the number of octets used for the encoding CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeOctetString(BufferedTransformation &bt, const SecByteBlock &str); -//! \brief BER decode octet string -//! \param bt BufferedTransformation object for reading -//! \param str the decoded string -//! \returns the number of octets used for the encoding +/// \brief BER decode octet string +/// \param bt BufferedTransformation object for reading +/// \param str the decoded string +/// \returns the number of octets used for the encoding CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeOctetString(BufferedTransformation &bt, SecByteBlock &str); -//! \brief BER decode octet string -//! \param bt BufferedTransformation object for reading -//! \param str the decoded string -//! \returns the number of octets used for the encoding +/// \brief BER decode octet string +/// \param bt BufferedTransformation object for reading +/// \param str the decoded string +/// \returns the number of octets used for the encoding CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeOctetString(BufferedTransformation &bt, BufferedTransformation &str); -//! \brief DER encode text string -//! \param bt BufferedTransformation object for writing -//! \param str the string to encode -//! \param asnTag the ASN.1 type -//! \returns the number of octets used for the encoding -//! \details DEREncodeTextString() can be used for UTF8_STRING, PRINTABLE_STRING, and IA5_STRING +/// \brief DER encode text string +/// \param bt BufferedTransformation object for writing +/// \param str the string to encode +/// \param asnTag the ASN.1 type +/// \returns the number of octets used for the encoding +/// \details DEREncodeTextString() can be used for UTF8_STRING, PRINTABLE_STRING, and IA5_STRING CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeTextString(BufferedTransformation &bt, const std::string &str, byte asnTag); -//! \brief BER decode text string -//! \param bt BufferedTransformation object for reading -//! \param str the string to encode -//! \param asnTag the ASN.1 type -//! \details DEREncodeTextString() can be used for UTF8_STRING, PRINTABLE_STRING, and IA5_STRING +/// \brief BER decode text string +/// \param bt BufferedTransformation object for reading +/// \param str the string to encode +/// \param asnTag the ASN.1 type +/// \details DEREncodeTextString() can be used for UTF8_STRING, PRINTABLE_STRING, and IA5_STRING CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeTextString(BufferedTransformation &bt, std::string &str, byte asnTag); -//! \brief DER encode bit string -//! \param bt BufferedTransformation object for writing -//! \param str the string to encode -//! \param strLen the length of the string -//! \param unusedBits the number of unused bits -//! \returns the number of octets used for the encoding +/// \brief DER encode bit string +/// \param bt BufferedTransformation object for writing +/// \param str the string to encode +/// \param strLen the length of the string +/// \param unusedBits the number of unused bits +/// \returns the number of octets used for the encoding CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeBitString(BufferedTransformation &bt, const byte *str, size_t strLen, unsigned int unusedBits=0); -//! \brief DER decode bit string -//! \param bt BufferedTransformation object for reading -//! \param str the decoded string -//! \param unusedBits the number of unused bits +/// \brief DER decode bit string +/// \param bt BufferedTransformation object for reading +/// \param str the decoded string +/// \param unusedBits the number of unused bits CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeBitString(BufferedTransformation &bt, SecByteBlock &str, unsigned int &unusedBits); -//! \brief BER decode and DER re-encode -//! \param bt BufferedTransformation object for writing -//! \param dest BufferedTransformation object +/// \brief BER decode and DER re-encode +/// \param bt BufferedTransformation object for writing +/// \param dest BufferedTransformation object CRYPTOPP_DLL void CRYPTOPP_API DERReencode(BufferedTransformation &bt, BufferedTransformation &dest); -//! \brief Object Identifier +/// \brief Object Identifier class CRYPTOPP_DLL OID { public: virtual ~OID() {} - //! \brief Construct an OID + /// \brief Construct an OID OID() {} - //! \brief Construct an OID - //! \param v value to initialize the OID + /// \brief Construct an OID + /// \param v value to initialize the OID OID(word32 v) : m_values(1, v) {} - //! \brief Construct an OID - //! \param bt BufferedTransformation object + /// \brief Construct an OID + /// \param bt BufferedTransformation object OID(BufferedTransformation &bt) {BERDecode(bt);} - //! \brief Append a value to an OID - //! \param rhs the value to append + /// \brief Append a value to an OID + /// \param rhs the value to append inline OID & operator+=(word32 rhs) {m_values.push_back(rhs); return *this;} - //! \brief DER encode this OID - //! \param bt BufferedTransformation object + /// \brief DER encode this OID + /// \param bt BufferedTransformation object void DEREncode(BufferedTransformation &bt) const; - //! \brief BER decode an OID - //! \param bt BufferedTransformation object + /// \brief BER decode an OID + /// \param bt BufferedTransformation object void BERDecode(BufferedTransformation &bt); - //! \brief BER decode an OID - //! \param bt BufferedTransformation object - //! \throws BERDecodeErr() if decoded value doesn't match an expected OID - //! \details BERDecodeAndCheck() can be used to parse an OID and verify it matches an expected. - //!
-	//!   BERSequenceDecoder key(bt);
-	//!   ...
-	//!   BERSequenceDecoder algorithm(key);
-	//!   GetAlgorithmID().BERDecodeAndCheck(algorithm);
-	//! 
+ /// \brief BER decode an OID + /// \param bt BufferedTransformation object + /// \throws BERDecodeErr() if decoded value doesn't match an expected OID + /// \details BERDecodeAndCheck() can be used to parse an OID and verify it matches an expected. + ///
+	///   BERSequenceDecoder key(bt);
+	///   ...
+	///   BERSequenceDecoder algorithm(key);
+	///   GetAlgorithmID().BERDecodeAndCheck(algorithm);
+	/// 
void BERDecodeAndCheck(BufferedTransformation &bt) const; std::vector m_values; @@ -208,7 +208,7 @@ private: static size_t DecodeValue(BufferedTransformation &bt, word32 &v); }; -//! \brief ASN.1 encoded object filter +/// \brief ASN.1 encoded object filter class EncodedObjectFilter : public Filter { public: @@ -216,15 +216,15 @@ public: virtual ~EncodedObjectFilter() {} - //! \brief Construct an EncodedObjectFilter - //! \param attachment a BufferedTrasformation to attach to this object - //! \param nObjects the number of objects - //! \param flags bitwise OR of EncodedObjectFilter::Flag + /// \brief Construct an EncodedObjectFilter + /// \param attachment a BufferedTrasformation to attach to this object + /// \param nObjects the number of objects + /// \param flags bitwise OR of EncodedObjectFilter::Flag EncodedObjectFilter(BufferedTransformation *attachment = NULLPTR, unsigned int nObjects = 1, word32 flags = 0); - //! \brief Input a byte buffer for processing - //! \param inString the byte buffer to process - //! \param length the size of the string, in bytes + /// \brief Input a byte buffer for processing + /// \param inString the byte buffer to process + /// \param length the size of the string, in bytes void Put(const byte *inString, size_t length); unsigned int GetNumberOfCompletedObjects() const {return m_nCurrentObject;} @@ -242,7 +242,7 @@ private: lword m_lengthRemaining; }; -//! \brief BER General Decoder +/// \brief BER General Decoder class CRYPTOPP_DLL BERGeneralDecoder : public Store { public: @@ -280,7 +280,7 @@ private: // proper direction. We did not break the library or versioning based on the output of // `nm --demangle libcryptopp.a | grep DERGeneralEncoder::DERGeneralEncoder | grep -v " U "`. -//! \brief DER General Encoder +/// \brief DER General Encoder class CRYPTOPP_DLL DERGeneralEncoder : public ByteQueue { public: @@ -299,7 +299,7 @@ private: byte m_asnTag; }; -//! \brief BER Sequence Decoder +/// \brief BER Sequence Decoder class CRYPTOPP_DLL BERSequenceDecoder : public BERGeneralDecoder { public: @@ -309,7 +309,7 @@ public: : BERGeneralDecoder(inQueue, asnTag) {} }; -//! \brief DER Sequence Encoder +/// \brief DER Sequence Encoder class CRYPTOPP_DLL DERSequenceEncoder : public DERGeneralEncoder { public: @@ -319,7 +319,7 @@ public: : DERGeneralEncoder(outQueue, asnTag) {} }; -//! \brief BER Set Decoder +/// \brief BER Set Decoder class CRYPTOPP_DLL BERSetDecoder : public BERGeneralDecoder { public: @@ -329,7 +329,7 @@ public: : BERGeneralDecoder(inQueue, asnTag) {} }; -//! \brief DER Set Encoder +/// \brief DER Set Encoder class CRYPTOPP_DLL DERSetEncoder : public DERGeneralEncoder { public: @@ -339,17 +339,17 @@ public: : DERGeneralEncoder(outQueue, asnTag) {} }; -//! \brief Optional data encoder and decoder -//! \tparam T class or type +/// \brief Optional data encoder and decoder +/// \tparam T class or type template class ASNOptional : public member_ptr { public: - //! \brief BER decode optional data - //! \param seqDecoder sequence with the optional ASN.1 data - //! \param tag ASN.1 tag to match as optional data - //! \param mask the mask to apply when matching the tag - //! \sa ASNTag and ASNIdFlag + /// \brief BER decode optional data + /// \param seqDecoder sequence with the optional ASN.1 data + /// \param tag ASN.1 tag to match as optional data + /// \param mask the mask to apply when matching the tag + /// \sa ASNTag and ASNIdFlag void BERDecode(BERSequenceDecoder &seqDecoder, byte tag, byte mask = ~CONSTRUCTED) { byte b; @@ -357,8 +357,8 @@ public: reset(new T(seqDecoder)); } - //! \brief DER encode optional data - //! \param out BufferedTransformation object + /// \brief DER encode optional data + /// \param out BufferedTransformation object void DEREncode(BufferedTransformation &out) { if (this->get() != NULLPTR) @@ -366,29 +366,29 @@ public: } }; -//! \brief Encode and decode ASN.1 objects with additional information -//! \tparam BASE base class or type -//! \details Encodes and decodes public keys, private keys and group -//! parameters with OID identifying the algorithm or scheme. +/// \brief Encode and decode ASN.1 objects with additional information +/// \tparam BASE base class or type +/// \details Encodes and decodes public keys, private keys and group +/// parameters with OID identifying the algorithm or scheme. template class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ASN1CryptoMaterial : public ASN1Object, public BASE { public: - //! \brief DER encode ASN.1 object - //! \param bt BufferedTransformation object - //! \details Save() will write the OID associated with algorithm or scheme. - //! In the case of public and private keys, this function writes the - //! subjectPubicKeyInfo and privateKeyInfo parts. + /// \brief DER encode ASN.1 object + /// \param bt BufferedTransformation object + /// \details Save() will write the OID associated with algorithm or scheme. + /// In the case of public and private keys, this function writes the + /// subjectPubicKeyInfo and privateKeyInfo parts. void Save(BufferedTransformation &bt) const {BEREncode(bt);} - //! \brief BER decode ASN.1 object - //! \param bt BufferedTransformation object + /// \brief BER decode ASN.1 object + /// \param bt BufferedTransformation object void Load(BufferedTransformation &bt) {BERDecode(bt);} }; -//! \brief Encodes and decodes subjectPublicKeyInfo +/// \brief Encodes and decodes subjectPublicKeyInfo class CRYPTOPP_DLL X509PublicKey : public ASN1CryptoMaterial { public: @@ -397,21 +397,21 @@ public: void BERDecode(BufferedTransformation &bt); void DEREncode(BufferedTransformation &bt) const; - //! \brief Retrieves the OID of the algorithm - //! \returns OID of the algorithm + /// \brief Retrieves the OID of the algorithm + /// \returns OID of the algorithm 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 + /// 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 + /// encode subjectPublicKey part of subjectPublicKeyInfo, without the BIT STRING header virtual void DEREncodePublicKey(BufferedTransformation &bt) const =0; }; -//! \brief Encodes and decodesprivateKeyInfo +/// \brief Encodes and decodesprivateKeyInfo class CRYPTOPP_DLL PKCS8PrivateKey : public ASN1CryptoMaterial { public: @@ -420,23 +420,23 @@ public: void BERDecode(BufferedTransformation &bt); void DEREncode(BufferedTransformation &bt) const; - //! \brief Retrieves the OID of the algorithm - //! \returns OID of the algorithm + /// \brief Retrieves the OID of the algorithm + /// \returns OID of the algorithm 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 + /// 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 + /// encode privateKey part of privateKeyInfo, without the OCTET STRING header virtual void DEREncodePrivateKey(BufferedTransformation &bt) const =0; - //! decode optional attributes including context-specific tag + /// 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 + /// encode optional attributes including context-specific tag virtual void DEREncodeOptionalAttributes(BufferedTransformation &bt) const; protected: @@ -445,12 +445,12 @@ protected: // ******************************************************** -//! \brief DER Encode unsigned value -//! \tparam T class or type -//! \param out BufferedTransformation object -//! \param w unsigned value to encode -//! \param asnTag the ASN.1 type -//! \details DEREncodeUnsigned() can be used with INTEGER, BOOLEAN, and ENUM +/// \brief DER Encode unsigned value +/// \tparam T class or type +/// \param out BufferedTransformation object +/// \param w unsigned value to encode +/// \param asnTag the ASN.1 type +/// \details DEREncodeUnsigned() can be used with INTEGER, BOOLEAN, and ENUM template size_t DEREncodeUnsigned(BufferedTransformation &out, T w, byte asnTag = INTEGER) { @@ -478,15 +478,15 @@ size_t DEREncodeUnsigned(BufferedTransformation &out, T w, byte asnTag = INTEGER return 1+lengthBytes+bc; } -//! \brief BER Decode unsigned value -//! \tparam T fundamental C++ type -//! \param in BufferedTransformation object -//! \param w the decoded value -//! \param asnTag the ASN.1 type -//! \param minValue the minimum expected value -//! \param maxValue the maximum expected value -//! \throws BERDecodeErr() if the value cannot be parsed or the decoded value is not within range. -//! \details DEREncodeUnsigned() can be used with INTEGER, BOOLEAN, and ENUM +/// \brief BER Decode unsigned value +/// \tparam T fundamental C++ type +/// \param in BufferedTransformation object +/// \param w the decoded value +/// \param asnTag the ASN.1 type +/// \param minValue the minimum expected value +/// \param maxValue the maximum expected value +/// \throws BERDecodeErr() if the value cannot be parsed or the decoded value is not within range. +/// \details DEREncodeUnsigned() can be used with INTEGER, BOOLEAN, and ENUM template void BERDecodeUnsigned(BufferedTransformation &in, T &w, byte asnTag = INTEGER, T minValue = 0, T maxValue = T(0xffffffff)) @@ -534,25 +534,25 @@ void BERDecodeUnsigned(BufferedTransformation &in, T &w, byte asnTag = INTEGER, } #ifdef CRYPTOPP_DOXYGEN_PROCESSING -//! \brief Compare two OIDs for equality -//! \param lhs the first OID -//! \param rhs the second OID -//! \returns true if the OIDs are equal, false otherwise +/// \brief Compare two OIDs for equality +/// \param lhs the first OID +/// \param rhs the second OID +/// \returns true if the OIDs are equal, false otherwise inline bool operator==(const OID &lhs, const OID &rhs); -//! \brief Compare two OIDs for inequality -//! \param lhs the first OID -//! \param rhs the second OID -//! \returns true if the OIDs are not equal, false otherwise +/// \brief Compare two OIDs for inequality +/// \param lhs the first OID +/// \param rhs the second OID +/// \returns true if the OIDs are not equal, false otherwise inline bool operator!=(const OID &lhs, const OID &rhs); -//! \brief Compare two OIDs for ordering -//! \param lhs the first OID -//! \param rhs the second OID -//! \returns true if the first OID is less than the second OID, false otherwise -//! \details operator<() calls std::lexicographical_compare() on each element in the array of values. +/// \brief Compare two OIDs for ordering +/// \param lhs the first OID +/// \param rhs the second OID +/// \returns true if the first OID is less than the second OID, false otherwise +/// \details operator<() calls std::lexicographical_compare() on each element in the array of values. inline bool operator<(const OID &lhs, const OID &rhs); -//! \brief Append a value to an OID -//! \param lhs the OID -//! \param rhs the value to append +/// \brief Append a value to an OID +/// \param lhs the OID +/// \param rhs the value to append inline OID operator+(const OID &lhs, unsigned long rhs); #else inline bool operator==(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs) -- cgit v1.2.1