For BER encodings, this function returns the length of the value field.
pBuffer[ index ] MUST point to the start of the length field of a BER encoded type. So for example, <Tag: integer, Length: 1, Value: 5>, this function will return 1. The pointer into the BER encoded buffer, that is index, is advanced to the start of the value field. This function will properly handle both the definite and indefinite form of length encodings.
This function would be useful when decoding the length of, for example, an ASN.1 SEQUENCE constructed type. Each of the other functions below will call decodeLength as part of processing their primitive types.
- Parameters
-
pBuffer | [ in ] Byte array containg the ASN.1 encoded data to decode |
bufSize | [ in ] the amount of data (in bytes) pointed to by pBuffer |
index | [ in ] current offset into pBuffer, should be pointing to the length field of an integer tagged value [ out ] this index moves down the pBuffer data as the data is decoded |
length | [ out ] the number of octets that the current ASN.1 Value occupies |
- Returns
Success | P6R::eOk | |
Failure | P6R::eNotInitialized | A successful call to initialize was not made before this call. |
P6R::eInvalidArg | pBuffer is set to NULL. |
P6R::eFormatError | Could not properly decode the length field. |
P6R::eTooBig | Max length value decoded is 4,394,967,296, or what fits into a P6UINT32 type. |