19 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 20 # pragma GCC diagnostic push 21 # pragma GCC diagnostic ignored "-Wconversion" 22 # pragma GCC diagnostic ignored "-Wsign-conversion" 274 OID(word32 v) : m_values(1, v) {}
285 m_values.push_back(rhs);
return *
this;
312 return m_values.empty();
329 std::ostream& Print(std::ostream& out)
const;
338 std::vector<word32> m_values;
349 enum Flag {PUT_OBJECTS=1, PUT_MESSANGE_END_AFTER_EACH_OBJECT=2, PUT_MESSANGE_END_AFTER_ALL_OBJECTS=4, PUT_MESSANGE_SERIES_END_AFTER_ALL_OBJECTS=8};
350 enum State {IDENTIFIER, LENGTH, BODY, TAIL, ALL_DONE} m_state;
363 void Put(
const byte *inString,
size_t length);
365 unsigned int GetNumberOfCompletedObjects()
const {
return m_nCurrentObject;}
366 unsigned long GetPositionOfObject(
unsigned int i)
const {
return m_positions[i];}
372 std::vector<unsigned int> m_positions;
373 lword m_lengthRemaining;
374 word32 m_nObjects, m_nCurrentObject, m_level, m_flags;
405 return m_definiteLength;
414 return IsDefiniteLength() ? m_length : 0;
419 bool EndReached()
const;
425 byte PeekByte()
const;
431 void CheckByte(byte b);
480 bool m_finished, m_definiteLength;
483 void Init(byte asnTag);
486 lword ReduceLength(lword delta);
665 if (seqDecoder.
Peek(b) && (b & mask) == tag)
666 reset(
new T(seqDecoder));
673 if (this->
get() != NULLPTR)
674 this->
get()->DEREncode(out);
682 template <
class BASE>
711 virtual OID GetAlgorithmID()
const =0;
757 virtual OID GetAlgorithmID()
const =0;
822 byte buf[
sizeof(w)+1];
826 buf[
sizeof(w)] = w ? 0xff : 0;
832 for (
unsigned int i=0; i<
sizeof(w); i++)
833 buf[i+1] = byte(w >> (
sizeof(w)-1-i)*8);
835 while (bc > 1 && buf[
sizeof(w)+1-bc] == 0)
837 if (buf[
sizeof(w)+1-bc] & 0x80)
842 out.
Put(buf+
sizeof(w)+1-bc, bc);
843 return 1+lengthBytes+bc;
857 T minValue = 0, T maxValue = T(0xffffffff))
860 if (!in.
Get(b) || b != asnTag)
869 if (asnTag ==
BOOLEAN && bc != 1)
876 if (bc != in.
Get(buf, bc))
884 const byte *ptr = buf;
885 while (bc >
sizeof(w) && *ptr == 0)
894 for (
unsigned int i=0; i<bc; i++)
895 w = (w << 8) | ptr[i];
897 if (w < minValue || w > maxValue)
901 #ifdef CRYPTOPP_DOXYGEN_PROCESSING 940 {
return oid.
Print(out); }
942 inline bool operator==(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
943 {
return lhs.m_values == rhs.m_values;}
944 inline bool operator!=(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
945 {
return lhs.m_values != rhs.m_values;}
946 inline bool operator<(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
947 {
return std::lexicographical_compare(lhs.m_values.begin(), lhs.m_values.end(), rhs.m_values.begin(), rhs.m_values.end());}
948 inline bool operator<=(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
949 {
return lhs<rhs || lhs==rhs;}
950 inline bool operator>=(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
951 {
return ! (lhs<rhs);}
952 inline ::CryptoPP::OID
operator+(const ::CryptoPP::OID &lhs,
unsigned long rhs)
953 {return ::CryptoPP::OID(lhs)+=rhs;}
954 inline std::ostream&
operator<<(std::ostream& out,
const OID &oid)
955 {
return oid.
Print(out); }
961 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 962 # pragma GCC diagnostic pop BERSetDecoder(BERSetDecoder &inQueue, byte asnTag)
Construct an ASN.1 decoder.
DERSetEncoder(BufferedTransformation &outQueue)
Construct an ASN.1 encoder.
UnknownOID(const char *err)
Construct an UnknownOID.
virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const
Encode optional parameters.
bool operator<=(const OID &lhs, const OID &rhs)
Compare two OIDs for ordering.
DERSetEncoder(DERSetEncoder &outQueue)
Construct an ASN.1 encoder.
ASN.1 External reference.
Utility functions for the Crypto++ library.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeTextString(BufferedTransformation &bt, SecByteBlock &str, byte asnTag)
BER decode text string.
size_t DEREncodeUnsigned(BufferedTransformation &out, T w, byte asnTag=INTEGER)
DER Encode unsigned value.
BERSetDecoder(BufferedTransformation &inQueue, byte asnTag)
Construct an ASN.1 decoder.
Encodes and Decodes privateKeyInfo.
BERSetDecoder(BERSetDecoder &inQueue)
Construct an ASN.1 decoder.
CRYPTOPP_DLL void CRYPTOPP_API DERReencode(BufferedTransformation &bt, BufferedTransformation &dest)
BER decode and DER re-encode.
Abstract base classes that provide a uniform interface to this library.
void BERDecodeUnsigned(BufferedTransformation &in, T &w, byte asnTag=INTEGER, T minValue=0, T maxValue=T(0xffffffff))
BER Decode unsigned value.
CRYPTOPP_DLL bool CRYPTOPP_API BERLengthDecode(BufferedTransformation &bt, size_t &length)
BER decode a length.
Classes for automatic resource management.
void DEREncode(BufferedTransformation &out)
DER encode optional data.
CRYPTOPP_DLL void CRYPTOPP_API BERDecodeNull(BufferedTransformation &bt)
BER decode NULL.
Acts as a Source for pre-existing, static data.
CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeOctetString(BufferedTransformation &bt, const byte *str, size_t strLen)
DER encode octet string.
std::ostream & Print(std::ostream &out) const
Print an OID.
CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeTextString(BufferedTransformation &bt, const byte *str, size_t strLen, byte asnTag)
DER encode text string.
DERSequenceEncoder(DERSequenceEncoder &outQueue)
Construct an ASN.1 encoder.
OID(BufferedTransformation &bt)
Construct an OID.
bool operator==(const OID &lhs, const OID &rhs)
Compare two OIDs for equality.
DERSetEncoder(DERSetEncoder &outQueue, byte asnTag)
Construct an ASN.1 encoder.
Pointer that overloads operator ->
bool Empty() const
Determine if OID is empty.
Optional data encoder and decoder.
void BERDecode(BERSequenceDecoder &seqDecoder, byte tag, byte mask=~CONSTRUCTED)
BER decode optional data.
bool operator!=(const OID &lhs, const OID &rhs)
Compare two OIDs for inequality.
CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeBitString(BufferedTransformation &bt, const byte *str, size_t strLen, unsigned int unusedBits=0)
DER encode bit string.
Classes for an unlimited queue to store bytes.
CRYPTOPP_DLL void CRYPTOPP_API DEREncodeNull(BufferedTransformation &bt)
DER encode NULL.
const std::vector< word32 > & GetValues() const
Retrieve OID value array.
bool operator<(const OID &lhs, const OID &rhs)
Compare two OIDs for ordering.
const std::string DEFAULT_CHANNEL
Default channel for BufferedTransformation.
virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const
Encode algorithm parameters.
UnknownOID()
Construct an UnknownOID.
DERSequenceEncoder(BufferedTransformation &outQueue)
Construct an ASN.1 encoder.
ASN.1 Context specific class.
OID & operator+=(word32 rhs)
Append a value to an OID.
ASN.1 encoded object filter.
Interface for encoding and decoding ASN1 objects.
BERSequenceDecoder(BERSequenceDecoder &inQueue)
Construct an ASN.1 decoder.
bool IsDefiniteLength() const
Determine length encoding.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeBitString(BufferedTransformation &bt, SecByteBlock &str, unsigned int &unusedBits)
DER decode bit string.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeDate(BufferedTransformation &bt, SecByteBlock &str, byte asnTag)
BER decode date.
OID operator+(const OID &lhs, unsigned long rhs)
Append a value to an OID.
BERSequenceDecoder(BufferedTransformation &inQueue, byte asnTag)
Construct an ASN.1 decoder.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt)
Decode algorithm parameters.
void Save(BufferedTransformation &bt) const
DER encode ASN.1 object.
void BERDecodeError()
Raises a BERDecodeErr.
Data structure used to store byte strings.
DERSetEncoder(BufferedTransformation &outQueue, byte asnTag)
Construct an ASN.1 encoder.
BERSequenceDecoder(BufferedTransformation &inQueue)
Construct an ASN.1 decoder.
Implementation of BufferedTransformation's attachment interface.
virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt)
Decode optional parameters.
OID(word32 v)
Construct an OID.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeOctetString(BufferedTransformation &bt, SecByteBlock &str)
BER decode octet string.
BERSetDecoder(BufferedTransformation &inQueue)
Construct an ASN.1 decoder.
void Load(BufferedTransformation &bt)
BER decode ASN.1 object.
Exception thrown when an unknown object identifier is encountered.
Implementation of BufferedTransformation's attachment interface.
bool operator>=(const OID &lhs, const OID &rhs)
Compare two OIDs for ordering.
CRYPTOPP_DLL size_t CRYPTOPP_API DERLengthEncode(BufferedTransformation &bt, lword length)
DER encode a length.
DERSequenceEncoder(DERSequenceEncoder &outQueue, byte asnTag)
Construct an ASN.1 encoder.
DERSequenceEncoder(BufferedTransformation &outQueue, byte asnTag)
Construct an ASN.1 encoder.
Crypto++ library namespace.
Encodes and decodes subjectPublicKeyInfo.
CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeDate(BufferedTransformation &bt, const SecByteBlock &str, byte asnTag)
DER encode date.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodePeekLength(const BufferedTransformation &bt)
BER decode size.
std::ostream & operator<<(std::ostream &out, const OID &oid)
Print a OID value.
Encode and decode ASN.1 objects with additional information.
lword RemainingLength() const
Determine remaining length.
BERSequenceDecoder(BERSequenceDecoder &inQueue, byte asnTag)
Construct an ASN.1 decoder.
Interface for retrieving values given their names.
Exception thrown when an ASN.1 BER decoing error is encountered.