ietf-openpgp
[Top] [All Lists]

Re: Extension to packet lengths

1998-02-13 01:24:15
* Adam Back wrote:
Presently, a length byte of 0xff is interpreted as a partial-length
byte with length 2^31 or 2 GB.  We would eliminate this interpretation

Yes.  Use your approach of prefix of 0xff followed by 4 byte length
field.  Deprecate all other length field types (except for unknown
length?)

Yep, this is the comment, but it does not make that sense to me. Hal, what's
the reason behind? Complexity of the parser or laziness of the programmer?

int get_v4len(struct Packet_Frame * pframe, LEXER lexer) {
   int c;

   if((c=(*lexer)(NULL)) != OCTET)  return c;
   
   if((yylval.octet & 0xe0) == 0xe0) {

      pframe->len = 1ul << (yylval.octet & 0x1f); /* 2^0 ... 2^31 */
      pframe->final = 0;               /* there are more packets */

   } else if((yylval.octet & 0xe0) == 0xc0) {

      pframe->len = (yylval.octet & 0x1f) << 8;

      if((c=(*lexer)(NULL)) != OCTET)  return c;

      pframe->len += yylval.octet + 192;/* 192 ... 8383 */
      pframe->final = 1;               /* last packet */

   } else if((yylval.octet & 0xc0) == 0x80) {

      pframe->len = 128 + (yylval.octet & 0x3f); /* 128 ... 191 */
      pframe->final = 1;               /* last packet */

   } else if((yylval.octet & 0x80) == 0x00) {

      pframe->len = yylval.octet & 0x7f;/* 0 ... 127 */
      pframe->final = 1;               /* last packet */

   }
   
   return OCTET;                       /* successful */
}