▲ | tsimionescu a day ago | |||||||||||||||||||||||||||||||
This seems like a just-so story. Your explanation could make some sense if we were comparing {"e" : "AQAB"} to {"e" : 65537}, but there is no reason why that should be the alternative. The JSON {"e" : "65537"} will be read precisely the same way by any JSON parser out there. Converting the string "65537" to the number 65537 is exactly as easy (or hard), but certainly unambiguous, as converting the string "AQAB" to the same number. Of course, if you're doing this in JS and have reasons to think the resulting number may be larger than the precision of a double, you have a huge problem either way. Just as you would if you were writing this in C and thought the number may be larger than what can fit in a long long. But that's true regardless of how you represent it in JSON. | ||||||||||||||||||||||||||||||||
▲ | pornel a day ago | parent | next [-] | |||||||||||||||||||||||||||||||
For very big numbers (that could appear in these fields), generating and parsing a base 10 decimal representation is way more cumbersome than using their binary representation. The DER encoding used in the TLS certificates uses the big endian binary format. OpenSSL API wants the big endian binary too. The format used by this protocol is a simple one. It's almost exactly the format that is needed to use these numbers, except JSON can't store binary data directly. Converting binary to base 64 is a simple operation (just bit twiddling, no division), and it's easier than converting arbitrarily large numbers between base 2 and base 10. The 17-bit value happens to be an easy one, but other values may need thousands of bits. It would be silly for the sender and recipient to need to use a BigNum library when the sender has the bytes and the recipient wants the bytes, and neither has use for a decimal number. | ||||||||||||||||||||||||||||||||
▲ | deepsun a day ago | parent | prev [-] | |||||||||||||||||||||||||||||||
Some parsers, like PHP, may treat 65537 and "65537" the same. Room for vulnerability. | ||||||||||||||||||||||||||||||||
|