1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00
putty-source/ssh
Simon Tatham e98615f0ba New post-quantum kex: ML-KEM, and three hybrids of it.
As standardised by NIST in FIPS 203, this is a lattice-based
post-quantum KEM.

Very vaguely, the idea of it is that your public key is a matrix A and
vector t, and the private key is the knowledge of how to decompose t
into two vectors with all their coefficients small, one transformed by
A relative to the other. Encryption of a binary secret starts by
turning each bit into one of two maximally separated residues mod a
prime q, and then adding 'noise' based on the public key in the form
of small increments and decrements mod q, again with some of the noise
transformed by A relative to the rest. Decryption uses the knowledge
of t's decomposition to align the two sets of noise so that the
_large_ changes (which masked the secret from an eavesdropper) cancel
out, leaving only a collection of small changes to the original secret
vector. Then the vector of input bits can be recovered by assuming
that those accumulated small pieces of noise haven't concentrated in
any particular residue enough to push it more than half way to the
other of its possible starting values.

A weird feature of it is that decryption is not a true mathematical
inverse of encryption. The assumption that the noise doesn't get large
enough to flip any bit of the secret is only probabilistically valid,
not a hard guarantee. In other words, key agreement can fail, simply
by getting particularly unlucky with the distribution of your random
noise! However, the probability of a failure is very low - less than
2^-138 even for ML-KEM-512, and gets even smaller with the larger
variants.

An awkward feature for our purposes is that the matrix A, containing a
large number of residues mod the prime q=3329, is required to be
constructed by a process of rejection sampling, i.e. generating random
12-bit values and throwing away the out-of-range ones. That would be a
real pain for our side-channel testing system, which generally handles
rejection sampling badly (since it necessarily involves data-dependent
control flow and timing variation). Fortunately, the matrix and the
random seed it was made from are both public: the matrix seed is
transmitted as part of the public key, so it's not necessary to try to
hide it. Accordingly, I was able to get the implementation to pass
testsc by means of not varying the matrix seed between runs, which is
justified by the principle of testsc that you vary the _secrets_ to
ensure timing is independent of them - and the matrix seed isn't a
secret, so you're allowed to keep it the same.

The three hybrid algorithms, defined by the current Internet-Draft
draft-kampanakis-curdle-ssh-pq-ke, include one hybrid of ML-KEM-768
with Curve25519 in exactly the same way we were already hybridising
NTRU Prime with Curve25519, and two more hybrids of ML-KEM with ECDH
over a NIST curve. The former hybrid interoperates with the
implementation in OpenSSH 9.9; all three interoperate with the fork
'openssh-oqs' at github.com/open-quantum-safe/openssh, and also with
the Python library AsyncSSH.
2024-12-08 10:41:08 +00:00
..
agentf.c Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
bpp1.c New Seat callback, seat_sent(). 2021-06-27 13:52:48 +01:00
bpp2.c Support OpenSSH's new strict kex feature. 2023-12-13 18:47:01 +00:00
bpp-bare.c New Seat callback, seat_sent(). 2021-06-27 13:52:48 +01:00
bpp.h Support OpenSSH's new strict kex feature. 2023-12-13 18:47:01 +00:00
ca-config.c Documentation for OpenSSH certificates. 2022-08-07 18:44:11 +01:00
censor1.c Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
censor2.c Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
channel.h Formatting: normalise back to 4-space indentation. 2022-08-03 20:48:46 +01:00
CMakeLists.txt Move host CA config box out into its own source file. 2022-05-01 10:16:19 +01:00
common.c Terrapin warning: say if reconfiguration can help. 2023-12-13 18:49:17 +00:00
connection1-client.c Rename SocketPeerInfo to SocketEndpointInfo. 2024-06-29 11:49:32 +01:00
connection1-server.c Rename SocketPeerInfo to SocketEndpointInfo. 2024-06-29 11:49:32 +01:00
connection1.c Rename SocketPeerInfo to SocketEndpointInfo. 2024-06-29 11:49:32 +01:00
connection1.h Rename SocketPeerInfo to SocketEndpointInfo. 2024-06-29 11:49:32 +01:00
connection2-client.c Rename SocketPeerInfo to SocketEndpointInfo. 2024-06-29 11:49:32 +01:00
connection2-server.c Rename SocketPeerInfo to SocketEndpointInfo. 2024-06-29 11:49:32 +01:00
connection2.c Rename SocketPeerInfo to SocketEndpointInfo. 2024-06-29 11:49:32 +01:00
connection2.h Rename SocketPeerInfo to SocketEndpointInfo. 2024-06-29 11:49:32 +01:00
crc-attack-detector.c Rename 'ret' variables passed from allocation to return. 2022-09-14 16:10:29 +01:00
gss.h Fix a build failure with NO_GSSAPI defined. 2024-11-28 18:30:48 +00:00
gssc.c GSSAPI fix: don't pass GSS_C_NO_NAME to inquire_cred_by_mech. 2022-09-17 07:55:08 +01:00
gssc.h Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
kex2-client.c Merge GSS EC kex fix and new FAQ from 'pre-0.78'. 2022-09-13 23:53:44 +01:00
kex2-server.c Refactor ecdh_kex into an organised vtable. 2022-04-15 17:46:06 +01:00
login1-server.c Packet protocol layers: new 'final_output' method. 2023-05-04 23:54:01 +01:00
login1.c Warn about Terrapin vulnerability for unpatched servers. 2023-12-13 18:47:08 +00:00
mainchan.c Switch CONF_remote_cmd to being STR_AMBI. 2024-09-26 11:30:07 +01:00
nogss.c Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
nosharing.c Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
pgssapi.c Unix GSSAPI: support static linking against Heimdal. 2022-09-17 07:55:08 +01:00
pgssapi.h Formatting: remove spurious spaces in 'type * var'. 2022-08-03 20:48:46 +01:00
portfwd.c Centralise stub plug/socket functions. 2024-06-29 12:19:35 +01:00
ppl.h Packet protocol layers: new 'final_output' method. 2023-05-04 23:54:01 +01:00
scpserver.c Rewrite some manual char-buffer-handling code. 2022-09-14 16:10:29 +01:00
server.c Centralise stub plug/socket functions. 2024-06-29 12:19:35 +01:00
server.h Uppity: add a stunt mode --close-after-banner. 2023-04-29 11:34:08 +01:00
sesschan.c Centralise stub plug/socket functions. 2024-06-29 12:19:35 +01:00
sftp.c Rename 'ret' variables passed from allocation to return. 2022-09-14 16:10:29 +01:00
sftp.h Fix a batch of typos in comments and docs. 2022-01-03 06:40:51 +00:00
sftpcommon.c Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
sftpserver.c Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
sharing.c Rename SocketPeerInfo to SocketEndpointInfo. 2024-06-29 11:49:32 +01:00
signal-list.h Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
ssh.c connect_to_host(): add missing sk_close on socket error. 2024-10-22 18:48:23 +01:00
transient-hostkey-cache.c Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
transport2.c New post-quantum kex: ML-KEM, and three hybrids of it. 2024-12-08 10:41:08 +00:00
transport2.h Warn about Terrapin vulnerability for unpatched servers. 2023-12-13 18:47:08 +00:00
ttymode-list.h Move the SSH implementation into its own subdirectory. 2021-04-22 18:09:13 +01:00
userauth2-client.c Pass the calling Socket to plug_log. 2024-06-29 12:00:12 +01:00
userauth2-server.c Packet protocol layers: new 'final_output' method. 2023-05-04 23:54:01 +01:00
verstring.c Work around key algorithm naming change in OpenSSH <= 7.7. 2023-05-05 00:05:28 +01:00
x11fwd.c Centralise stub plug/socket functions. 2024-06-29 12:19:35 +01:00
zlib.c Add a batch of missing 'static's. 2022-09-03 12:02:48 +01:00