6 #ifndef CRYPTOPP_IMPORTS 31 bt.Put(
byte(length >> (j-1)*8));
47 definiteLength =
true;
52 unsigned int lengthBytes = b & 0x7f;
56 definiteLength =
false;
60 definiteLength =
true;
64 if (length >> (8*(
sizeof(length)-1)))
70 length = (length << 8) | b;
84 return definiteLength;
109 return 1+lengthBytes+strLen;
130 if (bc != bt.
Get(str, bc))
155 bt.
Put((
const byte *)str.data(), str.size());
156 return 1+lengthBytes+str.size();
162 if (!bt.
Get(b) || b != asnTag)
172 if (bc != bt.
Get(temp, bc))
174 str.assign((
char *)temp.
begin(), bc);
185 return 2+lengthBytes+strLen;
204 if (!bt.
Get(unused) || unused > 7)
208 if ((bc-1) != bt.
Get(str, bc-1))
233 bt.
Put((
byte)(0x80 | ((v >> i) & 0x7f)));
247 if (v >> (8*
sizeof(v)-7))
261 for (
size_t i=2; i<
m_values.size(); i++)
290 if (valueLen > length)
306 if (m_flags & PUT_OBJECTS)
307 return *AttachedTransformation();
314 if (m_nCurrentObject == m_nObjects)
316 AttachedTransformation()->Put(inString, length);
322 while (
m_queue.AnyRetrievable())
329 m_queue.TransferTo(CurrentTarget(), 1);
334 if (m_level > 0 && m_id == 0 &&
m_queue.Peek(b) && b == 0)
336 m_queue.TransferTo(CurrentTarget(), 1);
338 m_state = IDENTIFIER;
350 if (!(m_id & CONSTRUCTED))
353 m_state = IDENTIFIER;
359 m_lengthRemaining -=
m_queue.TransferTo(CurrentTarget(), m_lengthRemaining);
361 if (m_lengthRemaining == 0)
362 m_state = IDENTIFIER;
369 if (m_state == IDENTIFIER && m_level == 0)
374 if (m_flags & PUT_MESSANGE_END_AFTER_EACH_OBJECT)
375 AttachedTransformation()->MessageEnd();
377 if (m_nCurrentObject == m_nObjects)
379 if (m_flags & PUT_MESSANGE_END_AFTER_ALL_OBJECTS)
380 AttachedTransformation()->MessageEnd();
382 if (m_flags & PUT_MESSANGE_SERIES_END_AFTER_ALL_OBJECTS)
383 AttachedTransformation()->MessageSeriesEnd();
385 m_queue.TransferAllTo(*AttachedTransformation());
393 : m_inQueue(inQueue), m_finished(false)
452 if (!
Get(b) || b != check)
539 GetAlgorithmID().BERDecodeAndCheck(algorithm);
540 bool parametersPresent = algorithm.
EndReached() ?
false : BERDecodeAlgorithmParameters(algorithm);
545 BERDecodePublicKey(subjectPublicKey, parametersPresent, (
size_t)subjectPublicKey.
RemainingLength());
555 GetAlgorithmID().DEREncode(algorithm);
556 DEREncodeAlgorithmParameters(algorithm);
560 subjectPublicKey.
Put(0);
561 DEREncodePublicKey(subjectPublicKey);
571 BERDecodeUnsigned<word32>(privateKeyInfo,
version,
INTEGER, 0, 0);
574 GetAlgorithmID().BERDecodeAndCheck(algorithm);
575 bool parametersPresent = algorithm.EndReached() ?
false : BERDecodeAlgorithmParameters(algorithm);
576 algorithm.MessageEnd();
579 BERDecodePrivateKey(octetString, parametersPresent, (
size_t)privateKeyInfo.
RemainingLength());
582 if (!privateKeyInfo.EndReached())
583 BERDecodeOptionalAttributes(privateKeyInfo);
584 privateKeyInfo.MessageEnd();
590 DEREncodeUnsigned<word32>(privateKeyInfo, 0);
593 GetAlgorithmID().DEREncode(algorithm);
594 DEREncodeAlgorithmParameters(algorithm);
595 algorithm.MessageEnd();
598 DEREncodePrivateKey(octetString);
601 DEREncodeOptionalAttributes(privateKeyInfo);
602 privateKeyInfo.MessageEnd();
612 m_optionalAttributes.CopyTo(bt);
Base class for all exceptions thrown by the library.
void DEREncode(BufferedTransformation &bt) const
DER encode this OID.
lword RemainingLength() const
BufferedTransformation & CurrentTarget()
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
bool SafeConvert(T1 from, T2 &to)
Tests whether a conversion from -> to is safe to perform.
use this to make sure LazyPut is finalized in event of exception
size_t BERDecodeBitString(BufferedTransformation &bt, SecByteBlock &str, unsigned int &unusedBits)
DER decode bit string.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true)
Transfer bytes from this object to another BufferedTransformation.
void BERDecodeNull(BufferedTransformation &in)
BER decode NULL.
void resize(size_type newSize)
Change size and preserve contents.
unsigned int BytePrecision(const T &value)
Returns the number of 8-bit bytes or octets required for a value.
#define NAMESPACE_BEGIN(x)
size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const
Copy bytes from this object to another BufferedTransformation.
size_t DERLengthEncode(BufferedTransformation &bt, lword length)
DER Length.
size_type size() const
Provides the count of elements in the SecBlock.
void DEREncode(BufferedTransformation &bt) const
Encode this object into a BufferedTransformation.
Library configuration file.
std::hash for asio::adress
void New(size_type newSize)
Change size without preserving contents.
void BERDecodeAndCheck(BufferedTransformation &bt) const
BER decode an OID.
size_t BERDecodeOctetString(BufferedTransformation &bt, SecByteBlock &str)
BER decode octet string.
void BERDecode(BufferedTransformation &bt)
Decode this object from a BufferedTransformation.
void DERReencode(BufferedTransformation &source, BufferedTransformation &dest)
BER decode and DER re-encode.
concurrent_queue< JitTask > m_queue
virtual void DEREncodeOptionalAttributes(BufferedTransformation &bt) const
encode optional attributes including context-specific tag
bool BERLengthDecode(BufferedTransformation &bt, lword &length, bool &definiteLength)
BufferedTransformation & TheBitBucket()
An input discarding BufferedTransformation.
virtual ~BERGeneralDecoder()
size_t BERDecodeTextString(BufferedTransformation &bt, std::string &str, byte asnTag)
BER decode text string.
size_t DEREncodeBitString(BufferedTransformation &bt, const byte *str, size_t strLen, unsigned int unusedBits)
ASN BitString.
size_t DEREncodeOctetString(BufferedTransformation &bt, const byte *str, size_t strLen)
ASN Strings.
virtual ~DERGeneralEncoder()
bool IsDefiniteLength() const
std::vector< word32 > m_values
void DEREncodeNull(BufferedTransformation &out)
DER encode NULL.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
DERGeneralEncoder(BufferedTransformation &outQueue, byte asnTag=SEQUENCE|CONSTRUCTED)
#define CRYPTOPP_ASSERT(exp)
lword ReduceLength(lword delta)
size_t DEREncodeTextString(BufferedTransformation &bt, const std::string &str, byte asnTag)
DER encode text string.
void BERDecode(BufferedTransformation &bt)
BER decode an OID.
void BERDecodeError()
Raises a BERDecodeErr.
Data structure used to store byte strings.
Classes and functions for working with ANS.1 objects.
static void EncodeValue(BufferedTransformation &bt, word32 v)
void Put(const byte *inString, size_t length)
Input a byte buffer for processing.
iterator begin()
Provides an iterator pointing to the first element in the memory block.
BufferedTransformation & m_outQueue
#define USING_NAMESPACE(x)
BufferedTransformation & m_inQueue
virtual void BERDecodeOptionalAttributes(BufferedTransformation &bt)
decode optional attributes including context-specific tag
lword CurrentSize() const
static size_t DecodeValue(BufferedTransformation &bt, word32 &v)
T1 RoundUpToMultipleOf(const T1 &n, const T2 &m)
Rounds a value up to a multiple of a second value.
const T & STDMAX(const T &a, const T &b)
Replacement function for std::max.
BERGeneralDecoder(BufferedTransformation &inQueue, byte asnTag)
lword GetCurrentPosition()
unsigned int BitPrecision(const T &value)
Returns the number of bits required for a value.