prop 149 updates

This commit is contained in:
zzz
2019-03-15 15:24:09 +00:00
parent 5343f51f23
commit eef78064a2

View File

@@ -5,7 +5,7 @@ B32 for Encrypted LS2
:author: zzz :author: zzz
:created: 2019-03-13 :created: 2019-03-13
:thread: http://zzz.i2p/topics/2682 :thread: http://zzz.i2p/topics/2682
:lastupdated: 2019-03-13 :lastupdated: 2019-03-15
:status: Open :status: Open
.. contents:: .. contents::
@@ -105,10 +105,11 @@ Post-processing and checksum:
{% highlight lang='text' %} {% highlight lang='text' %}
Construct the binary data as above. Construct the binary data as above.
Calculate checksum = Adler32(data[3:end]) Treat checksum as little-endian.
data[0] ^= checksum[0] Calculate checksum = CRC-32(data[3:end])
data[1] ^= checksum[1] data[0] ^= (byte) checksum
data[2] ^= checksum[2] data[1] ^= (byte) (checksum >> 8)
data[2] ^= (byte) (checksum >> 16)
hostname = Base32.encode(data) || ".b32.i2p" hostname = Base32.encode(data) || ".b32.i2p"
{% endhighlight %} {% endhighlight %}
@@ -125,13 +126,14 @@ Decoding and Verification
{% highlight lang='text' %} {% highlight lang='text' %}
strip the ".b32.i2p" from the hostname strip the ".b32.i2p" from the hostname
data = Base32.decode(hostname) data = Base32.decode(hostname)
Calculate checksum = Adler32(data[3:end]) Calculate checksum = CRC-32(data[3:end])
flags = data[0] ^ checksum[0] Treat checksum as little-endian.
flags = data[0] ^ (byte) checksum
if 1 byte sigtypes: if 1 byte sigtypes:
pubkey sigtype = data[1] ^ checksum[1] pubkey sigtype = data[1] ^ (byte) (checksum >> 8)
blinded sigtype = data[2] ^ checksum[2] blinded sigtype = data[2] ^ (byte) (checksum >> 16)
else (2 byte sigtypes) : else (2 byte sigtypes) :
pubkey sigtype = data[1] ^ checksum[1] || data[2] ^ checksum[2] pubkey sigtype = data[1] ^ ((byte) (checksum >> 8)) || data[2] ^ ((byte) (checksum >> 16))
blinded sigtype = data[3] || data[4] blinded sigtype = data[3] || data[4]
parse the remainder based on the flags to get the public key, parse the remainder based on the flags to get the public key,
optional secret, and optional auth privkey optional secret, and optional auth privkey
@@ -148,7 +150,8 @@ Justification
the hostname will be {56 chars}.b32.i2p, decoding to 35 bytes, same as Tor. the hostname will be {56 chars}.b32.i2p, decoding to 35 bytes, same as Tor.
- Tor 2-byte checksum has a 1/64K false negative rate. With 3 bytes, minus a few ignored bytes, - Tor 2-byte checksum has a 1/64K false negative rate. With 3 bytes, minus a few ignored bytes,
ours is approaching 1 in a million, since most flag/sigtype combinations are invalid. ours is approaching 1 in a million, since most flag/sigtype combinations are invalid.
- Adler-32 is a poor choice for small inputs, and for detecting small changes [ADLER32]_.
Use CRC-32 instead. CRC-32 is fast and is widely available.
Caching Caching
======= =======
@@ -182,3 +185,12 @@ Migration
No backward compatibility issues. Longer b32 addresses will fail to be converted No backward compatibility issues. Longer b32 addresses will fail to be converted
to 32-byte hashes in old software. to 32-byte hashes in old software.
References
==========
.. [ADLER32]
https://en.wikipedia.org/wiki/CRc-32
https://tools.ietf.org/html/rfc3309