Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

void PASNObject::EncodeASNLength ( PBYTEArray &  buffer,
WORD  length 
) [static, inherited]

Encode an ASN length value

Parameters:
buffer  buffer to encode into
length  ASN length to encode

Definition at line 202 of file pasn.cxx.

Referenced by PASNObject::EncodeASNHeader(), and PASNObject::EncodeASNSequenceStart().

{
  PINDEX offs = buffer.GetSize();

  // handle lengths less then 128
  if (length < 128) 
    buffer[offs++] = (BYTE)length;

  // handle lengths less than 256
  else if (length < 256) {
    buffer[offs++] = (BYTE)(0x01 | ASN_LONG_LEN);
    buffer[offs++] = (BYTE)length;
  }

  // handle lengths up to 0xffff
  else {
    buffer[offs++] = (u_char)(0x02 | ASN_LONG_LEN);
    buffer[offs++] = (u_char)((length >> 8) & 0xFF);
    buffer[offs++] = (u_char)(length & 0xFF);
  }
}


Generated by  Doxygen 1.6.0   Back to index