Hello!

I have made the path. It works. But I'm not sure that it's consistent
with ASN.1-standard... Here http://luca.ntop.org/Teaching/Appunti/asn1.html
in "3.1 Primitive, definite-length method. Identifier octets. High-tag-
number form.":
Two or more octets. First octet is as in low-tag-number form, except
that bits 5-1 all have value "1." Second and following octets give the
tag number, base 128, most significant digit first, with as few digits
as possible, and with the bit 8 of each octet except the last set to
"1."

The problem is in my application first octet doesn't correspond to
rule above: bits 5-1 not all have value "1".(This tag of 2 byte length
is from ICAO standard and I can't change its length.)

Path:
**********************asn.h**********************
//! BER General Decoder
class CRYPTOPP_DLL BERGeneralDecoder : public Store
{
public:
    explicit BERGeneralDecoder(BufferedTransformation &inQueue, byte
asnTag);
    explicit BERGeneralDecoder(BERGeneralDecoder &inQueue, byte
asnTag);

    explicit BERGeneralDecoder(BufferedTransformation &inQueue, byte
hiAsnTag, byte loAsnTag);
    explicit BERGeneralDecoder(BERGeneralDecoder &inQueue, byte
hiAsnTag, byte loAsnTag);

    ~BERGeneralDecoder();

        bool IsDefiniteLength() const {return m_definiteLength;}
        lword RemainingLength() const {assert(m_definiteLength); return
m_length;}
        bool EndReached() const;
        byte PeekByte() const;
        void CheckByte(byte b);

        size_t TransferTo2(BufferedTransformation &target, lword
&transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool
blocking=true);
        size_t CopyRangeTo2(BufferedTransformation &target, lword &begin,
lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool
blocking=true) const;

        // call this to denote end of sequence
        void MessageEnd();

protected:
        BufferedTransformation &m_inQueue;
        bool m_finished, m_definiteLength;
        lword m_length;

private:
        void Init(byte asnTag);
    void Init(byte hiAsnTag, byte loAsnTag);
        void StoreInitialize(const NameValuePairs &parameters) {assert
(false);}
        lword ReduceLength(lword delta);
};
*************************************************

*********************asn.cpp*********************
BERGeneralDecoder::BERGeneralDecoder(BufferedTransformation &inQueue,
byte hiAsnTag, byte loAsnTag)
: m_inQueue(inQueue), m_finished(false)
{
    Init(hiAsnTag, loAsnTag);
}

BERGeneralDecoder::BERGeneralDecoder(BERGeneralDecoder &inQueue, byte
hiAsnTag, byte loAsnTag)
: m_inQueue(inQueue), m_finished(false)
{
    Init(hiAsnTag, loAsnTag);
}

void BERGeneralDecoder::Init(byte hiAsnTag, byte loAsnTag)
{
        byte b;
        if (!m_inQueue.Get(b) || b != hiAsnTag)
                BERDecodeError();

    if (!m_inQueue.Get(b) || b != loAsnTag)
        BERDecodeError();

        if (!BERLengthDecode(m_inQueue, m_length, m_definiteLength))
                BERDecodeError();

        if (!m_definiteLength && !(loAsnTag & CONSTRUCTED))
                BERDecodeError();       // cannot be primitive and have 
indefinite length
}
*************************************************
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to