Allow using IV and tags longer than the minimum lengths

This commit is contained in:
Kovid Goyal
2022-08-12 13:21:57 +05:30
parent 63fa0c4e94
commit da9ffc9b93
2 changed files with 24 additions and 19 deletions

View File

@@ -47,24 +47,25 @@ Encrypted communication
.. versionadded:: 0.26.0
When using the :opt:`remote_control_password` option communication to the terminal is
encrypted to keep the password secure. A public key is used from the
:envvar:`KITTY_PUBLIC_KEY` environment variable. Currently, only one encryption
protocol is supported. The protocol number is present in
:envvar:`KITTY_PUBLIC_KEY` as ``1``. The key data in this environment variable is
`Base-85 <https://github.com/git/git/blob/master/base85.c>`__ encoded.
The algorithm used is `Elliptic Curve Diffie Helman
When using the :opt:`remote_control_password` option communication to the
terminal is encrypted to keep the password secure. A public key is used from
the :envvar:`KITTY_PUBLIC_KEY` environment variable. Currently, only one
encryption protocol is supported. The protocol number is present in
:envvar:`KITTY_PUBLIC_KEY` as ``1``. The key data in this environment variable
is `Base-85 <https://github.com/git/git/blob/master/base85.c>`__ encoded. The
algorithm used is `Elliptic Curve Diffie Helman
<https://en.wikipedia.org/wiki/Elliptic-curve_DiffieHellman>`__ with the
`X25519 curve <https://en.wikipedia.org/wiki/Curve25519>`__. A
time based nonce is used to minimise replay attacks. The original JSON command has
the fields: ``password`` and ``timestamp`` added. The timestamp is the number
of nanoseconds since the epoch, excluding leap seconds. Commands with a
timestamp more than 5 minutes from the current time are rejected. The command is then
encrypted using AES-256-GCM in authenticated encryption mode, with a symmetric key that
is derived from the ECDH key-pair by running the shared secret through SHA-256 hashing, once.
An IV of 96 bits of CSPRNG data is used. The tag for authenticated encryption **must** be 128 bits long.
The tag **must** authenticate only the value of the ``encrypted`` field. A new
command is created and transmitted that contains the fields:
`X25519 curve <https://en.wikipedia.org/wiki/Curve25519>`__. A time based nonce
is used to minimise replay attacks. The original JSON command has the fields:
``password`` and ``timestamp`` added. The timestamp is the number of
nanoseconds since the epoch, excluding leap seconds. Commands with a timestamp
more than 5 minutes from the current time are rejected. The command is then
encrypted using AES-256-GCM in authenticated encryption mode, with a symmetric
key that is derived from the ECDH key-pair by running the shared secret through
SHA-256 hashing, once. An IV of at least 96 bits of CSPRNG data is used. The
tag for authenticated encryption **must** be at least 128 bits long. The tag
**must** authenticate only the value of the ``encrypted`` field. A new command
is created and transmitted that contains the fields:
.. code-block:: json