2020-10-09 15:06:13 +00:00
|
|
|
========================================
|
|
|
|
Smaller Tunnel Build Messages
|
|
|
|
========================================
|
|
|
|
.. meta::
|
|
|
|
:author: zzz, orignal
|
|
|
|
:created: 2020-10-09
|
|
|
|
:thread: http://zzz.i2p/topics/2957
|
2021-07-31 10:33:58 -04:00
|
|
|
:lastupdated: 2021-07-31
|
2020-10-09 15:06:13 +00:00
|
|
|
:status: Open
|
|
|
|
:target: 0.9.51
|
|
|
|
|
|
|
|
.. contents::
|
|
|
|
|
|
|
|
|
2021-07-31 10:33:58 -04:00
|
|
|
Note
|
|
|
|
====
|
|
|
|
Implemented as of API version 0.9.51.
|
|
|
|
Network deployment and testing in progress.
|
|
|
|
Subject to minor revision.
|
|
|
|
See [I2NP]_ and [Tunnel-Creation-ECIES]_ for the final specification.
|
|
|
|
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
Overview
|
|
|
|
========
|
|
|
|
|
|
|
|
|
|
|
|
Summary
|
|
|
|
-------
|
|
|
|
|
2021-03-21 08:19:22 -04:00
|
|
|
The current size of the encrypted tunnel Build Request and Reply records is 528.
|
2020-10-09 15:06:13 +00:00
|
|
|
For typical Variable Tunnel Build and Variable Tunnel Build Reply messages,
|
2021-05-13 08:26:25 -04:00
|
|
|
the total size is 2113 bytes. This message is fragmented into three 1KB tunnel
|
2020-10-09 15:06:13 +00:00
|
|
|
messages for the reverse path.
|
|
|
|
|
2021-03-21 08:19:22 -04:00
|
|
|
Changes to the 528-byte record format for ECIES-X25519 routers are specified in [Prop152]_ and [Tunnel-Creation-ECIES]_.
|
2020-10-09 15:06:13 +00:00
|
|
|
For a mix of ElGamal and ECIES-X25519 routers in a tunnel, the record size must remain
|
|
|
|
528 bytes. However, if all routers in a tunnel are ECIES-X25519, a new, smaller
|
|
|
|
build record is possible, because ECIES-X25519 encryption has much less overhead
|
|
|
|
than ElGamal.
|
|
|
|
|
|
|
|
Smaller messages would save bandwidth. Also, if the messages could fit in a
|
|
|
|
single tunnel message, the reverse path would be three times more efficient.
|
|
|
|
|
2021-01-09 18:07:36 -05:00
|
|
|
This proposal defines new request and reply records and new Build Request and Build Reply messages.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
2021-07-31 09:39:52 -04:00
|
|
|
The tunnel creator and all hops in the created tunnel must ECIES-X25519, and at least version 0.9.51.
|
2021-03-21 11:07:55 -04:00
|
|
|
This proposal will not be useful until a majority of the routers in the network are ECIES-X25519.
|
|
|
|
This is expected to happen by year-end 2021.
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
Goals
|
|
|
|
-----
|
|
|
|
|
|
|
|
See [Prop152]_ and [Prop156]_ for additional goals.
|
|
|
|
|
|
|
|
- Smaller records and messages
|
2021-03-21 08:19:22 -04:00
|
|
|
- Maintain sufficient space for future options, as in [Prop152]_ and [Tunnel-Creation-ECIES]_
|
2020-10-09 15:06:13 +00:00
|
|
|
- Fit in one tunnel message for the reverse path
|
|
|
|
- Support ECIES hops only
|
2021-03-21 08:19:22 -04:00
|
|
|
- Maintain improvements implemented in [Prop152]_ and [Tunnel-Creation-ECIES]_
|
2020-10-09 15:06:13 +00:00
|
|
|
- Maximize compatibility with current network
|
2021-03-22 12:56:27 -04:00
|
|
|
- Hide inbound build messages from the OBEP
|
|
|
|
- Hide outbound build reply messages from the IBGW
|
2020-10-09 15:06:13 +00:00
|
|
|
- Do not require "flag day" upgrade to entire network
|
|
|
|
- Gradual rollout to minimize risk
|
|
|
|
- Reuse existing cryptographic primitives
|
|
|
|
|
|
|
|
|
|
|
|
Non-Goals
|
|
|
|
-----------
|
|
|
|
|
|
|
|
See [Prop156]_ for additional non-goals.
|
|
|
|
|
|
|
|
- No requirement for mixed ElGamal/ECIES tunnels
|
|
|
|
- Layer encryption changes, for that see [Prop153]_
|
2021-01-09 11:58:56 -05:00
|
|
|
- No speedups of crypto operations. It's assumed that ChaCha20 and AES are similar,
|
|
|
|
even with AESNI, at least for the small data sizes in question.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
Design
|
|
|
|
======
|
|
|
|
|
|
|
|
|
|
|
|
Records
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
See appendix for calculations.
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
Encrypted request and reply records will be 218 bytes, compared to 528 bytes now.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
The plaintext request records will be 154 bytes,
|
2020-10-09 15:06:13 +00:00
|
|
|
compared to 222 bytes for ElGamal records,
|
2021-03-21 08:19:22 -04:00
|
|
|
and 464 bytes for ECIES records as defined in [Prop152]_ and [Tunnel-Creation-ECIES]_.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
The plaintext response records will be 202 bytes,
|
2020-10-09 15:06:13 +00:00
|
|
|
compared to 496 bytes for ElGamal records,
|
2021-03-21 08:19:22 -04:00
|
|
|
and 512 bytes for ECIES records as defined in [Prop152]_ and [Tunnel-Creation-ECIES]_.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
2020-12-29 12:59:00 -05:00
|
|
|
The reply encryption will be ChaCha20 (NOT ChaCha20/Poly1305),
|
|
|
|
so the plaintext records do not need to be a multiple of 16 bytes.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
Request records will be made smaller by using HKDF to create the
|
|
|
|
layer and reply keys, so they do not need to be explicitly included in the request.
|
|
|
|
|
|
|
|
|
|
|
|
Tunnel Build Messages
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
Both will be "variable" with a one-byte number of records field,
|
|
|
|
as with the existing Variable messages.
|
|
|
|
|
2021-01-09 18:07:36 -05:00
|
|
|
ShortTunnelBuild: Type 25
|
2021-03-21 11:07:55 -04:00
|
|
|
````````````````````````````````
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
Typical length (with 4 records): 873 bytes
|
|
|
|
|
|
|
|
When used for inbound tunnel builds,
|
|
|
|
it is recommended (but not required) that this message be garlic encrypted by the originator,
|
|
|
|
targeting the inbound gateway (delivery instructions ROUTER),
|
|
|
|
to hide inbound build messages from the OBEP.
|
|
|
|
The IBGW decrypts the message,
|
|
|
|
puts the reply into the correct slot,
|
|
|
|
and sends the ShortTunnelBuildMessage to the next hop.
|
|
|
|
|
|
|
|
The record length is selected so that a garlic-encrypted STBM will fit
|
|
|
|
in a single tunnel message. See the appendix below.
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
|
2021-03-21 11:07:55 -04:00
|
|
|
|
2021-01-10 06:03:33 -05:00
|
|
|
OutboundTunnelBuildReply: Type 26
|
2021-03-21 11:07:55 -04:00
|
|
|
``````````````````````````````````````
|
|
|
|
|
2021-01-10 06:03:33 -05:00
|
|
|
We define a new OutboundTunnelBuildReply message.
|
|
|
|
This is used for outbound tunnel builds only.
|
2021-03-22 12:56:27 -04:00
|
|
|
The purpose is to hide outbound build reply messages from the IBGW.
|
|
|
|
It must be garlic encrypted by the OBEP, targeting the originator
|
2021-01-10 06:03:33 -05:00
|
|
|
(delivery instructions TUNNEL).
|
|
|
|
The OBEP decrypts the tunnel build message,
|
|
|
|
constructs a OutboundTunnelBuildReply message,
|
|
|
|
and puts the reply into the cleartext field.
|
|
|
|
The other records go into the other slots.
|
|
|
|
It then garlic encrypts the message to originator with the derived symmetric keys.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
|
2021-03-21 11:07:55 -04:00
|
|
|
Notes
|
|
|
|
```````
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
By garlic encrypting the OTBRM and STBM, we also avoid any potential
|
2021-03-22 12:56:27 -04:00
|
|
|
issues with compatibility at the IBGW and OBEP of the paired tunnels.
|
2021-03-21 11:07:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-10 06:03:33 -05:00
|
|
|
Message Flow
|
|
|
|
------------------
|
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight %}
|
|
|
|
STBM: Short tunnel build message (type 25)
|
|
|
|
OTBRM: Outbound tunnel build reply message (type 26)
|
|
|
|
|
|
|
|
Outbound Build A-B-C
|
|
|
|
Reply through existing inbound D-E-F
|
|
|
|
|
|
|
|
|
2021-03-21 11:07:55 -04:00
|
|
|
New Tunnel
|
2021-01-10 06:03:33 -05:00
|
|
|
STBM STBM STBM
|
|
|
|
Creator ------> A ------> B ------> C ---\
|
|
|
|
OBEP \
|
|
|
|
| Garlic wrapped
|
|
|
|
| OTBRM
|
|
|
|
| (TUNNEL delivery)
|
|
|
|
| from OBEP to
|
|
|
|
| creator
|
2021-03-21 11:07:55 -04:00
|
|
|
Existing Tunnel /
|
2021-01-10 06:03:33 -05:00
|
|
|
Creator <-------F---------E-------- D <--/
|
|
|
|
IBGW
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inbound Build D-E-F
|
|
|
|
Sent through existing outbound A-B-C
|
|
|
|
|
|
|
|
|
2021-03-21 11:07:55 -04:00
|
|
|
Existing Tunnel
|
2021-01-10 06:03:33 -05:00
|
|
|
Creator ------> A ------> B ------> C ---\
|
|
|
|
OBEP \
|
2021-06-22 07:52:33 -04:00
|
|
|
| Garlic wrapped (optional)
|
|
|
|
| STBM
|
2021-01-10 06:03:33 -05:00
|
|
|
| (ROUTER delivery)
|
|
|
|
| from creator
|
2021-03-21 11:07:55 -04:00
|
|
|
New Tunnel | to IBGW
|
2021-01-10 06:03:33 -05:00
|
|
|
STBM STBM STBM /
|
|
|
|
Creator <------ F <------ E <------ D <--/
|
|
|
|
IBGW
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% endhighlight %}
|
2021-01-09 18:07:36 -05:00
|
|
|
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
Record Encryption
|
|
|
|
------------------
|
|
|
|
|
2021-03-21 08:19:22 -04:00
|
|
|
Request and reply record encryption: as defined in [Prop152]_ and [Tunnel-Creation-ECIES]_.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
2020-12-29 12:59:00 -05:00
|
|
|
Reply record encryption for other slots: ChaCha20.
|
|
|
|
|
|
|
|
|
|
|
|
Layer Encryption
|
|
|
|
------------------
|
|
|
|
|
|
|
|
Currently there is no plan to change layer encryption for tunnels built with
|
|
|
|
this specification; it would remain AES, as currently used for all tunnels.
|
|
|
|
|
|
|
|
Changing layer encryption to ChaCha20 is a topic for additional research.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
New Tunnel Data Message
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
Currently there is no plan to change the 1KB Tunnel Data Message used for tunnels built with
|
|
|
|
this specification.
|
|
|
|
|
|
|
|
It may be useful to introduce a new I2NP message that is larger or variable-sized, concurrent with this proposal,
|
|
|
|
for use over these tunnels.
|
|
|
|
This would reduce overhead for large messages.
|
|
|
|
This is a topic for additional research.
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Specification
|
|
|
|
=============
|
|
|
|
|
|
|
|
|
2021-03-21 08:19:22 -04:00
|
|
|
Short Request Record
|
2020-10-09 15:06:13 +00:00
|
|
|
-----------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-21 08:19:22 -04:00
|
|
|
Short Request Record Unencrypted
|
|
|
|
```````````````````````````````````````
|
|
|
|
|
|
|
|
This is the proposed specification of the tunnel BuildRequestRecord for ECIES-X25519 routers.
|
|
|
|
Summary of changes from [Tunnel-Creation-ECIES]_:
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
- Change unencrypted length from 464 to 154 bytes
|
|
|
|
- Change encrypted length from 528 to 218 bytes
|
2021-03-21 08:19:22 -04:00
|
|
|
- Remove layer and reply keys and IVs, they will be generated from split() and a KDF
|
|
|
|
|
|
|
|
|
|
|
|
The request record does not contain any ChaCha reply keys.
|
|
|
|
Those keys are derived from a KDF. See below.
|
|
|
|
|
|
|
|
All fields are big-endian.
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
Unencrypted size: 154 bytes.
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight lang='dataspec' %}
|
|
|
|
|
|
|
|
bytes 0-3: tunnel ID to receive messages as, nonzero
|
|
|
|
bytes 4-7: next tunnel ID, nonzero
|
|
|
|
bytes 8-39: next router identity hash
|
|
|
|
byte 40: flags
|
2021-03-29 15:12:03 -04:00
|
|
|
bytes 41-42: more flags, unused, set to 0 for compatibility
|
|
|
|
byte 43: layer encryption type
|
2021-03-21 08:19:22 -04:00
|
|
|
bytes 44-47: request time (in minutes since the epoch, rounded down)
|
|
|
|
bytes 48-51: request expiration (in seconds since creation)
|
|
|
|
bytes 52-55: next message ID
|
|
|
|
bytes 56-x: tunnel build options (Mapping)
|
|
|
|
bytes x-x: other data as implied by flags or options
|
2021-06-22 07:52:33 -04:00
|
|
|
bytes x-153: random padding (see below)
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
{% endhighlight %}
|
|
|
|
|
2021-03-21 08:38:02 -04:00
|
|
|
|
2021-07-13 10:33:57 -04:00
|
|
|
The flags field is the same as defined in [Tunnel-Creation]_ and contains the following::
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
Bit order: 76543210 (bit 7 is MSB)
|
|
|
|
bit 7: if set, allow messages from anyone
|
|
|
|
bit 6: if set, allow messages to anyone, and send the reply to the
|
|
|
|
specified next hop in a Tunnel Build Reply Message
|
|
|
|
bits 5-0: Undefined, must set to 0 for compatibility with future options
|
|
|
|
|
|
|
|
Bit 7 indicates that the hop will be an inbound gateway (IBGW). Bit 6
|
|
|
|
indicates that the hop will be an outbound endpoint (OBEP). If neither bit is
|
|
|
|
set, the hop will be an intermediate participant. Both cannot be set at once.
|
|
|
|
|
2021-03-29 15:12:03 -04:00
|
|
|
Layer encryption type: 0 for AES (as in current tunnels);
|
|
|
|
1 for future (ChaCha?)
|
|
|
|
|
2021-03-21 08:19:22 -04:00
|
|
|
The request exipration is for future variable tunnel duration.
|
|
|
|
For now, the only supported value is 600 (10 minutes).
|
|
|
|
|
2021-03-21 08:38:02 -04:00
|
|
|
The creator ephemeral public key is an ECIES key, big-endian.
|
|
|
|
It is used for the KDF for the IBGW layer and reply keys and IVs.
|
|
|
|
This is only included in the plaintext record in an Inbound Tunnel Build message.
|
|
|
|
It is required because there is no DH at this layer for the build record.
|
|
|
|
|
2021-03-21 08:19:22 -04:00
|
|
|
The tunnel build options is a Mapping structure as defined in [Common]_.
|
|
|
|
This is for future use. No options are currently defined.
|
|
|
|
If the Mapping structure is empty, this is two bytes 0x00 0x00.
|
2021-06-22 07:52:33 -04:00
|
|
|
The maximum size of the Mapping (including the length field) is 98 bytes,
|
|
|
|
and the maximum value of the Mapping length field is 96.
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Short Request Record Encrypted
|
|
|
|
`````````````````````````````````````
|
|
|
|
|
|
|
|
All fields are big-endian except for the ephemeral public key which is little-endian.
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
Encrypted size: 218 bytes
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight lang='dataspec' %}
|
|
|
|
|
|
|
|
bytes 0-15: Hop's truncated identity hash
|
|
|
|
bytes 16-47: Sender's ephemeral X25519 public key
|
2021-06-22 07:52:33 -04:00
|
|
|
bytes 48-201: ChaCha20 encrypted ShortBuildRequestRecord
|
|
|
|
bytes 202-217: Poly1305 MAC
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Short Reply Record
|
2020-10-09 15:06:13 +00:00
|
|
|
-----------------------
|
|
|
|
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
Short Reply Record Unencrypted
|
|
|
|
`````````````````````````````````````
|
|
|
|
This is the proposed specification of the tunnel ShortBuildReplyRecord for ECIES-X25519 routers.
|
|
|
|
Summary of changes from [Tunnel-Creation-ECIES]_:
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
- Change unencrypted length from 512 to 202 bytes
|
|
|
|
- Change encrypted length from 528 to 218 bytes
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
ECIES replies are encrypted with ChaCha20/Poly1305.
|
|
|
|
|
|
|
|
All fields are big-endian.
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
Unencrypted size: 202 bytes.
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight lang='dataspec' %}
|
|
|
|
|
|
|
|
bytes 0-x: Tunnel Build Reply Options (Mapping)
|
|
|
|
bytes x-x: other data as implied by options
|
2021-06-22 07:52:33 -04:00
|
|
|
bytes x-200: Random padding (see below)
|
|
|
|
byte 201: Reply byte
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
The tunnel build reply options is a Mapping structure as defined in [Common]_.
|
|
|
|
This is for future use. No options are currently defined.
|
|
|
|
If the Mapping structure is empty, this is two bytes 0x00 0x00.
|
2021-06-22 07:52:33 -04:00
|
|
|
The maximum size of the Mapping (including the length field) is 201 bytes,
|
|
|
|
and the maximum value of the Mapping length field is 199.
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
The reply byte is one of the following values
|
|
|
|
as defined in [Tunnel-Creation]_ to avoid fingerprinting:
|
|
|
|
|
|
|
|
- 0x00 (accept)
|
|
|
|
- 30 (TUNNEL_REJECT_BANDWIDTH)
|
|
|
|
|
|
|
|
|
|
|
|
Short Reply Record Encrypted
|
|
|
|
```````````````````````````````````
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
Encrypted size: 218 bytes
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight lang='dataspec' %}
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
bytes 0-201: ChaCha20 encrypted ShortBuildReplyRecord
|
|
|
|
bytes 202-217: Poly1305 MAC
|
2021-03-21 08:19:22 -04:00
|
|
|
|
|
|
|
{% endhighlight %}
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
KDF
|
|
|
|
-----------------------
|
|
|
|
|
2021-07-12 15:31:22 -04:00
|
|
|
See KDF section below.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-09 18:07:36 -05:00
|
|
|
.. _msg-ShortTunnelBuild:
|
2021-01-09 11:58:56 -05:00
|
|
|
|
2021-01-09 18:07:36 -05:00
|
|
|
ShortTunnelBuild
|
|
|
|
-------------------
|
|
|
|
I2NP Type 25
|
2021-01-09 11:58:56 -05:00
|
|
|
|
2021-04-30 09:17:09 -04:00
|
|
|
This message is sent to middle hops, OBEP, and IBEP (creator).
|
|
|
|
It may not be sent to the IBGW (use garlic wrapped InboundTunnelBuild instead).
|
|
|
|
When received by the OBEP, it is transformed to an OutboundTunnelBuildReply,
|
|
|
|
garlic wrapped, and sent to the originator.
|
|
|
|
|
|
|
|
|
2021-01-09 18:07:36 -05:00
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight lang='dataspec' %}
|
|
|
|
+----+----+----+----+----+----+----+----+
|
|
|
|
| num| ShortBuildRequestRecords...
|
|
|
|
+----+----+----+----+----+----+----+----+
|
|
|
|
|
|
|
|
num ::
|
|
|
|
1 byte `Integer`
|
|
|
|
Valid values: 1-8
|
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
record size: 218 bytes
|
|
|
|
total size: 1+$num*218
|
2021-01-09 18:07:36 -05:00
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
Notes
|
|
|
|
`````
|
2021-06-22 07:52:33 -04:00
|
|
|
* Typical number of records is 4, for a total size of 873.
|
2021-01-09 18:07:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-10 06:03:33 -05:00
|
|
|
.. _msg-OutboundTunnelBuildReply:
|
2021-01-09 18:07:36 -05:00
|
|
|
|
2021-01-10 06:03:33 -05:00
|
|
|
OutboundTunnelBuildReply
|
|
|
|
---------------------------
|
2021-01-09 18:07:36 -05:00
|
|
|
I2NP Type 26
|
|
|
|
|
2021-04-30 09:17:09 -04:00
|
|
|
This message is only sent by the OBEP to the IBEP (creator) via an existing inbound tunnel.
|
|
|
|
It may not be sent to any other hop.
|
|
|
|
It is always garlic encrypted.
|
|
|
|
|
2021-01-09 18:07:36 -05:00
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight lang='dataspec' %}
|
|
|
|
+----+----+----+----+----+----+----+----+
|
2021-07-13 08:32:10 -04:00
|
|
|
| num| |
|
|
|
|
+----+ +
|
2021-02-18 09:32:11 -05:00
|
|
|
| ShortBuildReplyRecords... |
|
|
|
|
+----+----+----+----+----+----+----+----+
|
2021-01-09 18:07:36 -05:00
|
|
|
|
|
|
|
num ::
|
2021-02-18 09:32:11 -05:00
|
|
|
Total number of records,
|
2021-01-09 18:07:36 -05:00
|
|
|
1 byte `Integer`
|
2021-02-18 09:32:11 -05:00
|
|
|
Valid values: 1-8
|
2021-01-09 18:07:36 -05:00
|
|
|
|
2021-02-18 09:32:11 -05:00
|
|
|
ShortBuildReplyRecords ::
|
|
|
|
Encrypted records
|
2021-07-13 08:32:10 -04:00
|
|
|
length: num * 218
|
2021-02-18 09:32:11 -05:00
|
|
|
|
2021-06-22 07:52:33 -04:00
|
|
|
encrypted record size: 218 bytes
|
2021-07-13 08:32:10 -04:00
|
|
|
total size: 1+$num*218
|
2021-01-09 18:07:36 -05:00
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
Notes
|
|
|
|
`````
|
2021-07-13 08:32:10 -04:00
|
|
|
* Typical number of records is 4, for a total size of 873.
|
|
|
|
* This message should be garlic encrypted.
|
2021-01-09 19:49:39 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-12 08:45:26 -04:00
|
|
|
KDF
|
|
|
|
---
|
|
|
|
|
|
|
|
We use ck from Noise state after tunnel build record encryption/decrytion
|
2021-07-12 15:31:22 -04:00
|
|
|
to derive following keys: reply key, AES layer key, AES IV key and garlic reply key/tag for OBEP.
|
2021-07-12 08:45:26 -04:00
|
|
|
|
|
|
|
Reply key:
|
|
|
|
Unlike long records we can't use left part of ck for reply key, because it's not last and will be used later.
|
2021-07-31 09:39:52 -04:00
|
|
|
Reply key is used to encypt reply that record using AEAD/Chaha20/Poly1305 and Chacha20 to reply other records.
|
|
|
|
Both use the same key, nonce is record's position in the message starting from 0.
|
2021-07-12 08:45:26 -04:00
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight lang='dataspec' %}
|
2021-07-12 15:31:22 -04:00
|
|
|
keydata = HKDF(ck, ZEROLEN, "SMTunnelReplyKey", 64)
|
|
|
|
replyKey = keydata[32:63]
|
|
|
|
ck = keydata[0:31]
|
2021-07-12 08:45:26 -04:00
|
|
|
|
2021-07-12 09:11:53 -04:00
|
|
|
Layer key:
|
|
|
|
Layer key is always AES for now, but same KDF can be used from Chacha20
|
2021-07-12 08:45:26 -04:00
|
|
|
|
2021-07-12 15:31:22 -04:00
|
|
|
keydata = HKDF(ck, ZEROLEN, "SMTunnelLayerKey", 64)
|
|
|
|
layerKey = keydata[32:63]
|
2021-07-12 08:45:26 -04:00
|
|
|
|
2021-07-12 15:31:22 -04:00
|
|
|
IV key for non-OBEP record:
|
|
|
|
ivKey = keydata[0:31]
|
2021-07-12 09:11:53 -04:00
|
|
|
because it's last
|
2021-07-12 08:45:26 -04:00
|
|
|
|
2021-07-12 15:31:22 -04:00
|
|
|
IV key for OBEP record:
|
|
|
|
ck = keydata[0:31]
|
|
|
|
keydata = HKDF(ck, ZEROLEN, "TunnelLayerIVKey", 64)
|
|
|
|
ivKey = keydata[32:63]
|
|
|
|
ck = keydata[0:31]
|
2021-07-12 08:45:26 -04:00
|
|
|
|
2021-07-12 09:11:53 -04:00
|
|
|
OBEP garlic reply key/tag:
|
2021-07-12 15:31:22 -04:00
|
|
|
keydata = HKDF(ck, ZEROLEN, "RGarlicKeyAndTag", 64)
|
|
|
|
replyKey = keydata[32:63]
|
|
|
|
replyTag = keydata[0:7]
|
2021-07-12 08:45:26 -04:00
|
|
|
|
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
Justification
|
|
|
|
=============
|
|
|
|
|
|
|
|
This design maximizes reuse of existing cryptographic primitives, protocols, and code.
|
|
|
|
|
|
|
|
This design minimizes risk.
|
|
|
|
|
2021-01-09 11:58:56 -05:00
|
|
|
ChaCha20 is slightly faster than AES for small records, in Java testing.
|
|
|
|
ChaCha20 avoids a requirement for data size multiples of 16.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
Implementation Notes
|
|
|
|
=====================
|
|
|
|
|
2021-01-09 11:58:56 -05:00
|
|
|
- As with the existing variable tunnel build message,
|
|
|
|
messages smaller than 4 records are not recommended.
|
|
|
|
The typical default is 3 hops.
|
|
|
|
Inbound tunnels must be built with an extra record for
|
|
|
|
the originator, so the last hop does not know it is last.
|
|
|
|
So that middle hops don't know if a tunnel is inbound or outbound,
|
|
|
|
outbound tunnels should be built with 4 records also.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issues
|
|
|
|
======
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Migration
|
|
|
|
=========
|
|
|
|
|
|
|
|
The implementation, testing, and rollout will take several releases
|
|
|
|
and approximately one year. The phases are as follows. Assignment of
|
|
|
|
each phase to a particular release is TBD and depends on
|
|
|
|
the pace of development.
|
|
|
|
|
|
|
|
Details of the implementation and migration may vary for
|
|
|
|
each I2P implementation.
|
|
|
|
|
2021-03-21 11:07:55 -04:00
|
|
|
Tunnel creator must ensure that all hops in the created tunnel are ECIES-X25519, AND are at least version TBD.
|
2020-10-09 15:06:13 +00:00
|
|
|
The tunnel creator does NOT have to be ECIES-X25519; it can be ElGamal.
|
|
|
|
However, if the creator is ElGamal, it reveals to the closest hop that it is the creator.
|
|
|
|
So, in practice, these tunnels should only be created by ECIES routers.
|
|
|
|
|
2021-03-21 11:07:55 -04:00
|
|
|
It should NOT be necessary for the paired tunnel OBEP or IBGW is ECIES or
|
|
|
|
of any particular version.
|
|
|
|
The new messages are garlic-wrapped and not visible at the OBEP or IBGW
|
|
|
|
of the paired tunnel.
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
Phase 1: Implementation, not enabled by default
|
|
|
|
|
|
|
|
Phase 2 (next release): Enable by default
|
|
|
|
|
2021-03-21 11:07:55 -04:00
|
|
|
There are no backward-compatibility issues. The new messages may only be sent to routers that support them.
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
Appendix
|
|
|
|
==========
|
|
|
|
|
|
|
|
|
2021-06-19 10:23:07 -04:00
|
|
|
Without garlic overhead for unencrypted inbound STBM,
|
|
|
|
if we don't use ITBM:
|
|
|
|
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight lang='text' %}
|
|
|
|
Current 4-slot size: 4 * 528 + overhead = 3 tunnel messages
|
|
|
|
|
|
|
|
4-slot build message to fit in one tunnel message, ECIES-only:
|
|
|
|
|
|
|
|
1024
|
|
|
|
- 21 fragment header
|
|
|
|
----
|
|
|
|
1003
|
2021-06-19 10:23:07 -04:00
|
|
|
- 35 unfragmented ROUTER delivery instructions
|
2020-10-09 15:06:13 +00:00
|
|
|
----
|
2021-06-19 10:23:07 -04:00
|
|
|
968
|
2020-10-09 15:06:13 +00:00
|
|
|
- 16 I2NP header
|
|
|
|
----
|
2021-06-19 10:23:07 -04:00
|
|
|
952
|
2020-10-09 15:06:13 +00:00
|
|
|
- 1 number of slots
|
|
|
|
----
|
2021-06-19 10:23:07 -04:00
|
|
|
951
|
2020-10-09 15:06:13 +00:00
|
|
|
/ 4 slots
|
|
|
|
----
|
2021-06-19 10:23:07 -04:00
|
|
|
237 New encrypted build record size (vs. 528 now)
|
2020-10-09 15:06:13 +00:00
|
|
|
- 16 trunc. hash
|
|
|
|
- 32 eph. key
|
|
|
|
- 16 MAC
|
|
|
|
----
|
2021-06-19 10:23:07 -04:00
|
|
|
173 cleartext build record max (vs. 222 now)
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-19 10:23:07 -04:00
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
|
|
|
|
With garlic overhead for 'N' noise pattern to encrypt inbound STBM,
|
|
|
|
if we don't use ITBM:
|
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
{% highlight lang='text' %}
|
|
|
|
Current 4-slot size: 4 * 528 + overhead = 3 tunnel messages
|
|
|
|
|
|
|
|
4-slot garlic-encrypted build message to fit in one tunnel message, ECIES-only:
|
|
|
|
|
|
|
|
1024
|
|
|
|
- 21 fragment header
|
|
|
|
----
|
|
|
|
1003
|
|
|
|
- 35 unfragmented ROUTER delivery instructions
|
|
|
|
----
|
|
|
|
968
|
|
|
|
- 16 I2NP header
|
|
|
|
- 4 length
|
|
|
|
----
|
|
|
|
948
|
|
|
|
- 32 byte eph. key
|
|
|
|
----
|
|
|
|
916
|
|
|
|
- 7 byte DateTime block
|
|
|
|
----
|
|
|
|
909
|
|
|
|
- 3 byte Garlic block overhead
|
|
|
|
----
|
|
|
|
906
|
|
|
|
- 9 byte I2NP header
|
|
|
|
----
|
|
|
|
897
|
|
|
|
- 1 byte Garlic LOCAL delivery instructions
|
|
|
|
----
|
|
|
|
896
|
|
|
|
- 16 byte Poly1305 MAC
|
|
|
|
----
|
|
|
|
880
|
|
|
|
- 1 number of slots
|
|
|
|
----
|
|
|
|
879
|
|
|
|
/ 4 slots
|
|
|
|
----
|
|
|
|
219 New encrypted build record size (vs. 528 now)
|
|
|
|
- 16 trunc. hash
|
|
|
|
- 32 eph. key
|
|
|
|
- 16 MAC
|
|
|
|
----
|
|
|
|
155 cleartext build record max (vs. 222 now)
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
{% endhighlight %}
|
|
|
|
|
2021-06-19 10:23:07 -04:00
|
|
|
Notes:
|
|
|
|
|
|
|
|
Current build record cleartext size before unused padding: 193
|
|
|
|
|
|
|
|
Removal of full router hash and HKDF generation of keys/IVs would free up plenty of room for future options.
|
|
|
|
If everything is HKDF, required cleartext space is about 58 bytes (without any options).
|
|
|
|
|
2021-07-28 11:16:45 -04:00
|
|
|
The garlic-wrapped OTBRM will be slightly smaller than the garlic-wrapped STBM,
|
|
|
|
because the delivery instructions are LOCAL not ROUTER,
|
|
|
|
there's no DATETIME block included, and
|
|
|
|
it uses an 8-byte tag rather than the 32-byte ephemeral key for a full 'N' message.
|
2021-06-19 10:23:07 -04:00
|
|
|
|
|
|
|
|
2020-10-09 15:06:13 +00:00
|
|
|
|
|
|
|
References
|
|
|
|
==========
|
|
|
|
|
|
|
|
.. [Common]
|
|
|
|
{{ spec_url('common-structures') }}
|
|
|
|
|
|
|
|
.. [ECIES]
|
|
|
|
{{ spec_url('ecies') }}
|
|
|
|
|
|
|
|
.. [I2NP]
|
|
|
|
{{ spec_url('i2np') }}
|
|
|
|
|
|
|
|
.. [Prop123]
|
|
|
|
{{ proposal_url('123') }}
|
|
|
|
|
|
|
|
.. [Prop144]
|
|
|
|
{{ proposal_url('144') }}
|
|
|
|
|
|
|
|
.. [Prop145]
|
|
|
|
{{ proposal_url('145') }}
|
|
|
|
|
|
|
|
.. [Prop152]
|
|
|
|
{{ proposal_url('152') }}
|
|
|
|
|
|
|
|
.. [Prop153]
|
|
|
|
{{ proposal_url('153') }}
|
|
|
|
|
|
|
|
.. [Prop154]
|
|
|
|
{{ proposal_url('154') }}
|
|
|
|
|
|
|
|
.. [Prop156]
|
|
|
|
{{ proposal_url('156') }}
|
|
|
|
|
|
|
|
.. [Tunnel-Creation]
|
|
|
|
{{ spec_url('tunnel-creation') }}
|
|
|
|
|
2021-03-21 08:19:22 -04:00
|
|
|
.. [Tunnel-Creation-ECIES]
|
|
|
|
{{ spec_url('tunnel-creation-ecies') }}
|
|
|
|
|