IPFS ping protocol

Now, that it works in plaintext, I’ve decided to tackle the encrypted real version.

Starting the handshake with encryption is at first fairly easy. The handshake begins similarly to the plaintext handshake.

/multistream/1.0.0
/multistream/1.0.0
/secio/1.0.0
/secio/1.0.0

But then it gets tricky. It switches to a binary format. I’ll write all in hex.

From what I’ve analysed insofar, we get 6 bytes which are always the same, no matter the node or connection attempt.

00 00 01 7c 0a 10

Next we get 16 bytes which are always different with each attempt of connection.

24 bf fc 18 f4 3d 97 01 9c aa 77 80 0c e8 98 ac

Next are 41 bytes which are always the same, no matter the node or connection attempt:

12 ab 02 08 00 12 a6 02 30 82 01 22 30 0d 06 09 2a 86 48 86 f7 0d 01 01 01 05 00 03 82 01 0f 00 30 82 01 0a 02 82 01 01 00

Next are 256 bytes which are different from node to node, but same for each connection attempt (probably public key):

d4 4d ef ff ce a0 0b af c9 df 75 e4 cf 51 31 91 c4 f9 eb 72 57 54 cc 0f ee b7 17 fe 08 c5 d2 79 8d 66 3d 3f da ff 94 24 65 77 ad d4 11 e5 0c 0d bf be e8 bf 33 a8 f0 a2 b8 0a ec 76 96 f6 09 da 13 ab 7c 56 58 08 c0 90 0f 8d 1f 56 7a 7c 3a 81 91 1a 46 95 e7 4f ec 28 f3 0c 47 aa cc 77 78 58 c8 6a 00 48 5a 39 b6 b8 0c 0d ab cd 92 b1 88 fa 53 3a c4 fd f9 6c 9a 30 46 c1 b2 3c c6 8b ed fa a4 0b af d3 27 57 30 d3 a1 19 91 ab 8a f4 be ae 1f 12 d6 a8 30 45 14 42 61 43 71 bf 5d 51 a2 8d 90 f9 6b 3a 64 f0 36 7a 22 75 1b 86 42 57 3f bd 1a 6b 73 42 cb e7 9a a1 f8 3b d4 74 42 c7 e4 67 4a a0 87 b7 f1 45 06 1e d9 2a 65 05 1a da 0e 63 1a 8d 13 3a d0 69 0a c5 5b cd 57 24 f2 9b a8 6e 78 d3 be b4 ea a6 76 da 8f 1b 2c 31 e6 91 9c 51 71 fd 47 ff 61 c1 c3 58 71 fc 2f fa 4e 1a 15 b9

And at last 65 bytes which are always the same no matter the node or connection attempt:

02 03 01 00 01 1a 11 50 2d 32 35 36 2c 50 2d 33 38 34 2c 50 2d 35 32 31 22 18 41 45 53 2d 32 35 36 2c 41 45 53 2d 31 32 38 2c 42 6c 6f 77 66 69 73 68 2a 0d 53 48 41 32 35 36 2c 53 48 41 35 31 32

Thanks to an user on ipfs@freenode I’ve received a work-in-progress (not yet public?) spec for secio.

The binary format should be protobuf, which is explained here: Encoding | Protocol Buffers Documentation

The serialization should be of this format:

Propose {
Rand: 16 secure random bytes,
Pubkey: public key bytes,
Exchanges: comma separated string of supported key exchanges,
Ciphers: comma separated string of supported ciphers,
Hashes: comma separated string of supported hashes,
}