annando / salmon-protocol

Automatically exported from code.google.com/p/salmon-protocol
0 stars 0 forks source link

Mention need to remove leading zero bytes from modulus & exponent binary serializations #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the RSA key serialization, a first step is convert from an internal integer 
representation of modulus and exponent to the standard network byte order 
representations.  This is ambiguous since it does not specify how to handle 
leading zero bytes -- there are an infinite number of network byte order 
serializations for any number  (42, 042, 0042, 000042...).  This is important 
because we do bytewise comparison of keys and also in some cases sha256 hashes.

Existing code assumes no leading zero bytes (all network byte order 
representations are normalized so the first, leftmost, byte is always nonzero). 
 The specification should state this requirement explicitly.

(At least one Ruby library implementation sometimes generates leading zero 
bytes due to processing data in larger-than-byte-sized-chunks, which is why 
this issue came up.)

Original issue reported on code.google.com by jpanzer@google.com on 9 Dec 2010 at 10:39

GoogleCodeExporter commented 9 years ago
Changed text to "Each of the components is first represented as an integer in 
network byte order (big endian), with no leading zero bytes," to make that step 
of the recipe unambiguous.

Original comment by jpanzer@google.com on 8 Jan 2011 at 12:53