OT - calculating length

Jerry Windrel jerry.windrel at verizon.net
Sun May 9 22:39:15 CEST 2004


It seems like you'd do the following:

Take the length and do an integer-divide by 256.  (If your language doesn't
have an integer-divide operator, do a floating-point divide and chop off the
fractional part to get a whole number).  Add 192.  That's your first octet.

Take the length and do an integer-remainder by 256.  (If your language
doesn't have an integer-remainder operator, multiply the result of the
integer-divide above [before you added 192] by 256 and subtract that from
the length.) Add 192.  That's your second octet.

----- Original Message ----- 
From: "Atom 'Smasher'" <atom at suspicious.org>
To: <gnupg-users at gnupg.org>
Sent: Sunday, May 09, 2004 3:38 PM
Subject: OT - calculating length


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> it's been a long time since i had any math classes... can anyone help me
> figure out how to calculate octet lengths as specified in
> rfc2440:4.2.2.2. Two-Octet Lengths
>
> A two-octet Body Length header encodes a length of from 192 to
> 8383 octets.  It is recognized because its first octet is in the
> range 192 to 223.  The body length is equal to:
>
> bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
>
> so, if i have something that's a certain size, how do i calculate that as
> a two octet representation? how do i verify that it's correct? can someone
> explain that to me in a "dumbed down" way?
>
> thanks...
>
>
>   ...atom
>
>  _________________________________________
>  PGP key - http://atom.smasher.org/pgp.txt
>  3EBE 2810 30AE 601D 54B2 4A90 9C28 0BBF 3D7D 41E3
>  -------------------------------------------------
>
> "Aerial bombardment is never proportionate, measured or
> targeted. It evolves a logic of its own, an escalation
> of horror similar to that unleashed by the terrorist.
> Like all distant and indiscriminate violence, it breeds
> a violent response. It is the dumbest weapon of war."
> -- Simon Jenkins
> They Opted to Bomb - It Had Better Work
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (FreeBSD)
> Comment: What is this gibberish?  -
http://atom.smasher.org/links/#digital_signatures
>
> iEYEARECAAYFAkCeiL0ACgkQnCgLvz19QePBmACeIaZl0f4ao4zXKq/oQUuOu/li
> ZsQAniKUx+XwQn1nZDo0jSbWI/5iYG4J
> =7slN
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Gnupg-users mailing list
> Gnupg-users at gnupg.org
> http://lists.gnupg.org/mailman/listinfo/gnupg-users




More information about the Gnupg-users mailing list