19#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
20# pragma GCC diagnostic push
21# pragma GCC diagnostic ignored "-Wconversion"
22# pragma GCC diagnostic ignored "-Wsign-conversion"
25NAMESPACE_BEGIN(CryptoPP)
285 m_values.push_back(rhs);
return *
this;
312 return m_values.empty();
329 std::ostream& Print(std::ostream& out)
const;
332 friend bool operator==(
const OID &lhs,
const OID &rhs);
333 friend bool operator!=(
const OID &lhs,
const OID &rhs);
334 friend bool operator<(
const OID &lhs,
const OID &rhs);
335 friend bool operator<=(
const OID &lhs,
const OID &rhs);
336 friend bool operator>=(
const OID &lhs,
const OID &rhs);
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;
413 CRYPTOPP_ASSERT(m_definiteLength);
414 return IsDefiniteLength() ? m_length : 0;
419 bool EndReached()
const;
425 byte PeekByte()
const;
431 void CheckByte(
byte b);
449 size_t TransferTo2(
BufferedTransformation &target,
lword &transferBytes,
const std::string &channel=DEFAULT_CHANNEL,
bool blocking=
true);
480 bool m_finished, m_definiteLength;
483 void Init(
byte asnTag);
485 {CRYPTOPP_UNUSED(parameters); CRYPTOPP_ASSERT(
false);}
665 if (seqDecoder.
Peek(b) && (b & mask) == tag)
666 reset(
new T(seqDecoder));
673 if (this->get() != NULLPTR)
674 this->get()->DEREncode(out);
718 {BERDecodeNull(bt);
return false;}
725 {DEREncodeNull(bt);
return false;}
764 {BERDecodeNull(bt);
return false;}
771 {DEREncodeNull(bt);
return false;}
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
906inline bool operator==(
const OID &lhs,
const OID &rhs);
911inline bool operator!=(
const OID &lhs,
const OID &rhs);
917inline bool operator<(
const OID &lhs,
const OID &rhs);
924inline bool operator<=(
const OID &lhs,
const OID &rhs);
931inline bool operator>=(
const OID &lhs,
const OID &rhs);
935inline OID operator+(
const OID &lhs,
unsigned long rhs);
939inline std::ostream& operator<<(std::ostream& out,
const OID &oid)
940 {
return oid.
Print(out); }
942inline bool operator==(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
943 {
return lhs.m_values == rhs.m_values;}
944inline bool operator!=(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
945 {
return lhs.m_values != rhs.m_values;}
946inline 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());}
948inline bool operator<=(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
949 {
return lhs<rhs || lhs==rhs;}
950inline bool operator>=(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
951 {
return ! (lhs<rhs);}
952inline ::CryptoPP::OID operator+(const ::CryptoPP::OID &lhs,
unsigned long rhs)
953 {return ::CryptoPP::OID(lhs)+=rhs;}
954inline 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
CRYPTOPP_DLL bool CRYPTOPP_API BERLengthDecode(BufferedTransformation &bt, size_t &length)
BER decode a length.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodePeekLength(const BufferedTransformation &bt)
BER decode size.
void BERDecodeUnsigned(BufferedTransformation &in, T &w, byte asnTag=INTEGER, T minValue=0, T maxValue=T(0xffffffff))
BER Decode unsigned value.
CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeDate(BufferedTransformation &bt, const SecByteBlock &str, byte asnTag)
DER encode date.
CRYPTOPP_DLL void CRYPTOPP_API DERReencode(BufferedTransformation &bt, BufferedTransformation &dest)
BER decode and DER re-encode.
CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeBitString(BufferedTransformation &bt, const byte *str, size_t strLen, unsigned int unusedBits=0)
DER encode bit string.
CRYPTOPP_DLL void CRYPTOPP_API DEREncodeNull(BufferedTransformation &bt)
DER encode NULL.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeDate(BufferedTransformation &bt, SecByteBlock &str, byte asnTag)
BER decode date.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeTextString(BufferedTransformation &bt, SecByteBlock &str, byte asnTag)
BER decode text string.
CRYPTOPP_DLL void CRYPTOPP_API BERDecodeNull(BufferedTransformation &bt)
BER decode NULL.
size_t DEREncodeUnsigned(BufferedTransformation &out, T w, byte asnTag=INTEGER)
DER Encode unsigned value.
@ PRIVATE
ASN.1 Private class.
@ CONSTRUCTED
ASN.1 Constructed flag.
@ APPLICATION
ASN.1 Application class.
@ CONTEXT_SPECIFIC
ASN.1 Context specific class.
@ UNIVERSAL
ASN.1 Universal class.
@ PRIMITIVE
ASN.1 Primitive flag.
CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeOctetString(BufferedTransformation &bt, const byte *str, size_t strLen)
DER encode octet string.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeBitString(BufferedTransformation &bt, SecByteBlock &str, unsigned int &unusedBits)
DER decode bit string.
CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeOctetString(BufferedTransformation &bt, SecByteBlock &str)
BER decode octet string.
@ REAL
ASN.1 Real integer.
@ UNIVERSAL_STRING
ASN.1 Universal string.
@ NUMERIC_STRING
ASN.1 Numeric string.
@ OCTET_STRING
ASN.1 Octet string.
@ GRAPHIC_STRING
ASN.1 Graphic string.
@ PRINTABLE_STRING
ASN.1 Printable string.
@ ENUMERATED
ASN.1 Enumerated value.
@ EXTERNAL
ASN.1 External reference.
@ UTC_TIME
ASN.1 UTC time.
@ OBJECT_IDENTIFIER
ASN.1 Object identifier.
@ IA5_STRING
ASN.1 IA5 string.
@ BMP_STRING
ASN.1 BMP string.
@ VISIBLE_STRING
ASN.1 Visible string.
@ BIT_STRING
ASN.1 Bit string.
@ GENERAL_STRING
ASN.1 General string.
@ SEQUENCE
ASN.1 Sequence.
@ GENERALIZED_TIME
ASN.1 Generalized time.
@ VIDEOTEXT_STRING
ASN.1 Videotext string.
@ OBJECT_DESCRIPTOR
ASN.1 Object descriptor.
@ UTF8_STRING
ASN.1 UTF-8 string.
@ T61_STRING
ASN.1 T61 string.
CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeTextString(BufferedTransformation &bt, const byte *str, size_t strLen, byte asnTag)
DER encode text string.
void BERDecodeError()
Raises a BERDecodeErr.
CRYPTOPP_DLL size_t CRYPTOPP_API DERLengthEncode(BufferedTransformation &bt, lword length)
DER encode a length.
Encode and decode ASN.1 objects with additional information.
void Load(BufferedTransformation &bt)
BER decode ASN.1 object.
void Save(BufferedTransformation &bt) const
DER encode ASN.1 object.
Interface for encoding and decoding ASN1 objects.
Optional data encoder and decoder.
void DEREncode(BufferedTransformation &out)
DER encode optional data.
void BERDecode(BERSequenceDecoder &seqDecoder, byte tag, byte mask=~CONSTRUCTED)
BER decode optional data.
Exception thrown when an ASN.1 BER decoing error is encountered.
lword RemainingLength() const
Determine remaining length.
bool IsDefiniteLength() const
Determine length encoding.
BERSequenceDecoder(BERSequenceDecoder &inQueue)
Construct an ASN.1 decoder.
BERSequenceDecoder(BERSequenceDecoder &inQueue, byte asnTag)
Construct an ASN.1 decoder.
BERSequenceDecoder(BufferedTransformation &inQueue)
Construct an ASN.1 decoder.
BERSequenceDecoder(BufferedTransformation &inQueue, byte asnTag)
Construct an ASN.1 decoder.
BERSetDecoder(BufferedTransformation &inQueue)
Construct an ASN.1 decoder.
BERSetDecoder(BufferedTransformation &inQueue, byte asnTag)
Construct an ASN.1 decoder.
BERSetDecoder(BERSetDecoder &inQueue, byte asnTag)
Construct an ASN.1 decoder.
BERSetDecoder(BERSetDecoder &inQueue)
Construct an ASN.1 decoder.
Data structure used to store byte strings.
DERSequenceEncoder(DERSequenceEncoder &outQueue, byte asnTag)
Construct an ASN.1 encoder.
DERSequenceEncoder(BufferedTransformation &outQueue, byte asnTag)
Construct an ASN.1 encoder.
DERSequenceEncoder(DERSequenceEncoder &outQueue)
Construct an ASN.1 encoder.
DERSequenceEncoder(BufferedTransformation &outQueue)
Construct an ASN.1 encoder.
DERSetEncoder(DERSetEncoder &outQueue)
Construct an ASN.1 encoder.
DERSetEncoder(BufferedTransformation &outQueue)
Construct an ASN.1 encoder.
DERSetEncoder(BufferedTransformation &outQueue, byte asnTag)
Construct an ASN.1 encoder.
DERSetEncoder(DERSetEncoder &outQueue, byte asnTag)
Construct an ASN.1 encoder.
ASN.1 encoded object filter.
EncodedObjectFilter(BufferedTransformation *attachment=NULLPTR, unsigned int nObjects=1, word32 flags=0)
Construct an EncodedObjectFilter.
void Put(const byte *inString, size_t length)
Input a byte buffer for processing.
Implementation of BufferedTransformation's attachment interface.
Interface for retrieving values given their names.
bool Empty() const
Determine if OID is empty.
OID(word32 v)
Construct an OID.
const std::vector< word32 > & GetValues() const
Retrieve OID value array.
OID(BufferedTransformation &bt)
Construct an OID.
std::ostream & Print(std::ostream &out) const
Print an OID.
OID & operator+=(word32 rhs)
Append a value to an OID.
Encodes and Decodes privateKeyInfo.
virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt)
Decode optional parameters.
virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const
Encode optional parameters.
virtual void DEREncodePrivateKey(BufferedTransformation &bt) const =0
Encode privateKey part of privateKeyInfo.
virtual OID GetAlgorithmID() const =0
Retrieves the OID of the algorithm.
virtual void BERDecodePrivateKey(BufferedTransformation &bt, bool parametersPresent, size_t size)=0
Decode privateKey part of privateKeyInfo.
Acts as a Source for pre-existing, static data.
Exception thrown when an unknown object identifier is encountered.
UnknownOID()
Construct an UnknownOID.
UnknownOID(const char *err)
Construct an UnknownOID.
Encodes and decodes subjectPublicKeyInfo.
virtual OID GetAlgorithmID() const =0
Retrieves the OID of the algorithm.
virtual void BERDecodePublicKey(BufferedTransformation &bt, bool parametersPresent, size_t size)=0
Decode subjectPublicKey part of subjectPublicKeyInfo.
virtual void DEREncodePublicKey(BufferedTransformation &bt) const =0
Encode subjectPublicKey part of subjectPublicKeyInfo.
virtual bool DEREncodeAlgorithmParameters(BufferedTransformation &bt) const
Encode algorithm parameters.
virtual bool BERDecodeAlgorithmParameters(BufferedTransformation &bt)
Decode algorithm parameters.
Pointer that overloads operator ->
const lword LWORD_MAX
Large word type max value.
unsigned int word32
32-bit unsigned datatype
word64 lword
Large word type.
Abstract base classes that provide a uniform interface to this library.
Implementation of BufferedTransformation's attachment interface.
Utility functions for the Crypto++ library.
#define EnumToInt(v)
Integer value.
Classes for an unlimited queue to store bytes.
Classes for automatic resource management.