27 OBJECT_IDENTIFIER = 0x06,
28 OBJECT_DESCRIPTOR = 0x07,
35 NUMERIC_STRING = 0x12,
36 PRINTABLE_STRING = 0x13,
38 VIDEOTEXT_STRING = 0x15,
41 GENERALIZED_TIME = 0x18,
42 GRAPHIC_STRING = 0x19,
43 VISIBLE_STRING = 0x1a,
54 CONTEXT_SPECIFIC = 0x80,
81 CRYPTOPP_DLL
size_t CRYPTOPP_API DEREncodeTextString(
BufferedTransformation &out,
const std::string &str, byte asnTag);
82 CRYPTOPP_DLL
size_t CRYPTOPP_API BERDecodeTextString(
BufferedTransformation &in, std::string &str, byte asnTag);
91 class CRYPTOPP_DLL
OID 95 OID(word32 v) : m_values(1, v) {}
98 inline OID & operator+=(word32 rhs) {m_values.push_back(rhs);
return *
this;}
106 std::vector<word32> m_values;
116 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};
119 void Put(
const byte *inString,
size_t length);
121 unsigned int GetNumberOfCompletedObjects()
const {
return m_nCurrentObject;}
122 unsigned long GetPositionOfObject(
unsigned int i)
const {
return m_positions[i];}
128 unsigned int m_nObjects, m_nCurrentObject, m_level;
129 std::vector<unsigned int> m_positions;
131 enum State {IDENTIFIER, LENGTH, BODY, TAIL, ALL_DONE} m_state;
133 lword m_lengthRemaining;
144 bool IsDefiniteLength()
const {
return m_definiteLength;}
145 lword RemainingLength()
const {assert(m_definiteLength);
return m_length;}
146 bool EndReached()
const;
147 byte PeekByte()
const;
148 void CheckByte(byte b);
158 bool m_finished, m_definiteLength;
162 void Init(byte asnTag);
164 {CRYPTOPP_UNUSED(parameters); assert(
false);}
165 lword ReduceLength(lword delta);
177 #if defined(CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562) 243 if (seqDecoder.
Peek(b) && (b & mask) == tag)
244 reset(
new T(seqDecoder));
248 if (this->
get() != NULL)
249 this->
get()->DEREncode(out);
254 template <
class BASE>
271 virtual OID GetAlgorithmID()
const =0;
273 {BERDecodeNull(bt);
return false;}
275 {DEREncodeNull(bt);
return false;}
290 virtual OID GetAlgorithmID()
const =0;
292 {BERDecodeNull(bt);
return false;}
294 {DEREncodeNull(bt);
return false;}
318 byte buf[
sizeof(w)+1];
320 if (asnTag == BOOLEAN)
322 buf[
sizeof(w)] = w ? 0xff : 0;
328 for (
unsigned int i=0; i<
sizeof(w); i++)
329 buf[i+1] = byte(w >> (
sizeof(w)-1-i)*8);
331 while (bc > 1 && buf[
sizeof(w)+1-bc] == 0)
333 if (buf[
sizeof(w)+1-bc] & 0x80)
338 out.
Put(buf+
sizeof(w)+1-bc, bc);
339 return 1+lengthBytes+bc;
345 T minValue = 0, T maxValue = ((std::numeric_limits<T>::max)()))
348 if (!in.
Get(b) || b != asnTag)
352 bool definite = BERLengthDecode(in, bc);
358 if (bc != in.
Get(buf, bc))
361 const byte *ptr = buf;
362 while (bc >
sizeof(w) && *ptr == 0)
371 for (
unsigned int i=0; i<bc; i++)
372 w = (w << 8) | ptr[i];
374 if (w < minValue || w > maxValue)
378 inline bool operator==(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
379 {
return lhs.m_values == rhs.m_values;}
380 inline bool operator!=(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
381 {
return lhs.m_values != rhs.m_values;}
382 inline bool operator<(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
383 {
return std::lexicographical_compare(lhs.m_values.begin(), lhs.m_values.end(), rhs.m_values.begin(), rhs.m_values.end());}
384 inline ::CryptoPP::OID operator+(const ::CryptoPP::OID &lhs,
unsigned long rhs)
385 {return ::CryptoPP::OID(lhs)+=rhs;}
Utility functions for the Crypto++ library.
size_t DEREncodeUnsigned(BufferedTransformation &out, T w, byte asnTag=INTEGER)
DER Encode Unsigned.
encodes/decodes privateKeyInfo
Abstract base classes that provide a uniform interface to this library.
size_t DERLengthEncode(BufferedTransformation &out, lword length)
DER Length.
Classes for automatic resource management.
Acts as a Source for pre-existing, static data.
SecByteBlock is a SecBlock<byte> typedef.
Pointer that overloads operator→
Classes for an unlimited queue to store bytes.
const std::string DEFAULT_CHANNEL
Default channel for BufferedTransformation.
size_t DEREncodeBitString(BufferedTransformation &out, const byte *str, size_t strLen, unsigned int unusedBits=0)
ASN BitString.
Interface for encoding and decoding ASN1 objects.
bool operator<(const ::PolynomialMod2 &a, const ::PolynomialMod2 &b)
compares degree
void BERDecodeUnsigned(BufferedTransformation &in, T &w, byte asnTag=INTEGER, T minValue=0, T maxValue=((std::numeric_limits< T >::max)()))
BER Decode Unsigned.
Implementation of BufferedTransformation's attachment interface in cryptlib.h.
size_t DEREncodeOctetString(BufferedTransformation &out, const byte *str, size_t strLen)
ASN Strings.
Implementation of BufferedTransformation's attachment interface.
Crypto++ library namespace.
encodes/decodes subjectPublicKeyInfo
Interface for retrieving values given their names.
Exception thrown when an ASN1 BER decoing error is encountered.