Skip to content

SshStrictKex

[Source]

The OpenSSH strict key-exchange extension (Terrapin / CVE-2023-48795 mitigation). Each side advertises a role-specific marker as a pseudo key-exchange algorithm in its first KEXINIT only. When both sides advertise it, strict KEX is in effect: the packet sequence number is reset to zero at every NEWKEYS, and no non-key-exchange packets are tolerated during the initial key exchange. The marker is appended last so it never wins negotiation against a real algorithm.

primitive val SshStrictKex

Constructors

create

[Source]

new val create()
: SshStrictKex val^

Returns


Public Functions

client_marker

[Source]

fun box client_marker()
: String val

Returns


server_marker

[Source]

fun box server_marker()
: String val

Returns


our_marker

[Source]

The marker this side advertises, by role.

fun box our_marker(
  role: SshRole)
: String val

Parameters

Returns


initial_kexinit_position_ok

[Source]

Under strict KEX the peer's KEXINIT must be the very first binary packet of the connection. The reader increments its sequence number as each packet is read, so when we process that KEXINIT the reader's sequence number is exactly 1 if nothing preceded it. A larger value means a packet was injected before the KEXINIT (e.g. an SSH_MSG_IGNORE) — the pre-KEXINIT half of the Terrapin attack (CVE-2023-48795) — and the connection must abort.

fun box initial_kexinit_position_ok(
  reader_sequence_after_read: U32 val)
: Bool val

Parameters

  • reader_sequence_after_read: U32 val

Returns


peer_advertised

[Source]

True if the peer's KEXINIT advertised the strict-KEX marker for its role. We always advertise ours, so — since strict KEX requires both sides — this is exactly whether strict KEX is in effect for the connection.

fun box peer_advertised(
  their_kexinit: Array[U8 val] val,
  our_role: SshRole)
: Bool val

Parameters

Returns


eq

[Source]

fun box eq(
  that: SshStrictKex val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: SshStrictKex val)
: Bool val

Parameters

Returns