Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.SSH.KeyAgreement

Feature notes: SSH implementation notes

Classes, interfaces and records

interfaceiSSHSymmetricKeys

function GetEncryptionKeyLengthC2S: Integer; function GetEncryptionKeyLengthS2C: Integer; function GetInitialIVLengthC2S: Integer; function GetInitialIVLengthS2C: Integer; function GetIntegrityKeyLengthC2S: Integer; function GetIntegrityKeyLengthS2C: Integer; function GetEncryptionKeyC2S: iSecretKey; function GetEncryptionKeyS2C: iSecretKey; function GetInitialIVC2S: iSecretKey; function GetInitialIVS2C: iSecretKey; function GetIntegrityKeyC2S: iSecretKey; function GetIntegrityKeyS2C: iSecretKey; procedure SetEncryptionKeyLengthC2S(const Value: Integer); procedure SetEncryptionKeyLengthS2C(const Value: Integer); procedure SetInitialIVLengthC2S(const Value: Integer); procedure SetInitialIVLengthS2C(const Value: Integer); procedure SetIntegrityKeyLengthC2S(const Value: Integer); procedure SetIntegrityKeyLengthS2C(const Value: Integer); procedure SetEncryptionKeyC2S(const Value: iSecretKey); procedure SetEncryptionKeyS2C(const Value: iSecretKey); procedure SetInitialIVC2S(const Value: iSecretKey); procedure SetInitialIVS2C(const Value: iSecretKey); procedure SetIntegrityKeyC2S(const Value: iSecretKey); procedure SetIntegrityKeyS2C(const Value: iSecretKey); property InitialIVLengthC2S: Integer read GetInitialIVLengthC2S write SetInitialIVLengthC2S; property InitialIVLengthS2C: Integer read GetInitialIVLengthS2C write SetInitialIVLengthS2C; property EncryptionKeyLengthC2S: Integer read GetEncryptionKeyLengthC2S write SetEncryptionKeyLengthC2S; property EncryptionKeyLengthS2C: Integer read GetEncryptionKeyLengthS2C write SetEncryptionKeyLengthS2C; property IntegrityKeyLengthC2S: Integer read GetIntegrityKeyLengthC2S write SetIntegrityKeyLengthC2S; property IntegrityKeyLengthS2C: Integer read GetIntegrityKeyLengthS2C write SetIntegrityKeyLengthS2C; property InitialIVC2S: iSecretKey read GetInitialIVC2S write SetInitialIVC2S; property InitialIVS2C: iSecretKey read GetInitialIVS2C write SetInitialIVS2C; property EncryptionKeyC2S: iSecretKey read GetEncryptionKeyC2S write SetEncryptionKeyC2S; property EncryptionKeyS2C: iSecretKey read GetEncryptionKeyS2C write SetEncryptionKeyS2C; property IntegrityKeyC2S: iSecretKey read GetIntegrityKeyC2S write SetIntegrityKeyC2S; property IntegrityKeyS2C: iSecretKey read GetIntegrityKeyS2C write SetIntegrityKeyS2C;

interfaceiSSHKeyExchange

inherits from iKeyExchange

function GetHostKeyEnc: tBytes; function GetInitClient: tBytes; function GetInitServer: tBytes; function GetNewKeys: Boolean; function GetSessionID: tBytes; function GetVersionClient: string; function GetVersionServer: string; procedure SetHostKeyEnc(const Value: tBytes); procedure SetInitClient(const Value: tBytes); procedure SetInitServer(const Value: tBytes); procedure SetSessionID(const Value: tBytes); procedure SetVersionClient(const Value: string); procedure SetVersionServer(const Value: string); function Execute(const aTransport: iTransport; const aKey : iUnknown; const aMsg : tBytes; const aMsgOffs : Integer; const aMsgLen : Integer) : iSSHSymmetricKeys; property VersionClient: string read GetVersionClient write SetVersionClient; property VersionServer: string read GetVersionServer write SetVersionServer; property InitClient: tBytes read GetInitClient write SetInitClient; property InitServer: tBytes read GetInitServer write SetInitServer; property HostKeyEnc: tBytes read GetHostKeyEnc write SetHostKeyEnc; property SessionID: tBytes read GetSessionID write SetSessionID; property NewKeys: Boolean read GetNewKeys;

classtSSHSymmetricKeys

inherits from tInterfacedObject

implements iSSHSymmetricKeys

(no public members)

classtSSHKeyExchange

inherits from tDSIKeyExchange

implements iSSHKeyExchange

constructor Create(aPool: iDSIDLArith); virtual; destructor Destroy; override;

classtSSHGroup

inherits from tInterfacedObject

implements iDiscreteLogField, iFFSystemParams

constructor Create(aPool: iDSIDLArith); virtual; procedure Assign(const aSrc: iDiscreteLogField); overload; procedure Assign(const aSrc: iFFSystemParams); overload; function Clone: iFFSystemParams;
Returns the Clone value, obtained via fParams.
function Compare(const aParams: iDiscreteLogField): Boolean; overload;
Delegates to fGroup.Compare, forwarding aParams, and returns its result.
function Compare(const aParams: iFFSystemParams): Boolean; overload;
Delegates to fGroup.Compare, forwarding aParams, and returns its result.
procedure Generate(aBitSize: Cardinal; aQBitSize: Cardinal); function Validate: Boolean;
Returns the Validate value, obtained via fGroup.
function ScalarFixBitLength: Integer;
Returns the ScalarFixBitLength value, obtained via fGroup.
function FieldElementToBytes(const aElement: iGroupElement) : tBytes; overload;
Delegates to fGroup.FieldElementToBytes, forwarding aElement, and returns its result.
function FieldElementToBytes(const aElement : iGroupElement; const aDst : tBytes; aDstOffset: Integer; var aDstCount : Integer) : Boolean; overload;
Delegates to fGroup.FieldElementToBytes, forwarding aElement, and returns its result.
function BytesToFieldElement(const aSrc: tBytes): iGroupElement; overload;
Delegates to fGroup.BytesToFieldElement, forwarding aSrc, and returns its result.
function BytesToFieldElement(const aSrc: tBytes; aSrcOffset, aSrcCount: Integer) : iGroupElement; overload;
Delegates to fGroup.BytesToFieldElement, forwarding aSrc, and returns its result.
function IsNonTrivialFieldElement(const aElement: iGroupElement): Boolean;
Delegates to fGroup.IsNonTrivialFieldElement, forwarding aElement, and returns its result.
function IsGroupElement(const aElement: iGroupElement): Boolean;
Delegates to fGroup.IsGroupElement, forwarding aElement, and returns its result.
property Pool: iDSIDLArith read GetPool; property P: iDSInteger read GetP write SetP; property Q: iDSInteger read GetQ write SetQ; property G: iDSInteger read GetG write SetG; property J: iDSInteger read GetJ write SetJ; function iDiscreteLogField.GetPrimeModulus = GetP; function iDiscreteLogField.GetGroupOrder = GetQ; function iDiscreteLogField.GetCoFactor = GetJ; procedure iDiscreteLogField.SetPrimeModulus = SetP; procedure iDiscreteLogField.SetGroupOrder = SetQ; procedure iDiscreteLogField.SetCoFactor = SetJ;

interfaceiSSHClientKeyExchange

inherits from iSSHKeyExchange

Diffie-Hellman with pre defined groups

function GetServerKey: iSignPublicKey; procedure SetServerKey(const Value: iSignPublicKey); function Pass1: tBytes; function Pass2(const aKEXMsg: tBytes; const aKeys : iSSHSymmetricKeys) : Boolean; property ServerKey: iSignPublicKey read GetServerKey write SetServerKey;

interfaceiSSHServerKeyExchange

inherits from iSSHKeyExchange

function GetServerKey: iSignPrivateKey; procedure SetServerKey(const Value: iSignPrivateKey); function Pass1(const aKEXMsg: tBytes; const aKeys : iSSHSymmetricKeys) : tBytes; property ServerKey: iSignPrivateKey read GetServerKey write SetServerKey;

classtSSHGroup1

inherits from tSSHGroup

(no public members)

classtSSHGroup14

inherits from tSSHGroup

(no public members)

classtSSHGroup15

inherits from tSSHGroup

(no public members)

classtSSHGroup16

inherits from tSSHGroup

(no public members)

classtSSHGroup18

inherits from tSSHGroup

(no public members)

classtSSHClientKeyExchange

inherits from tSSHKeyExchange

implements iSSHClientKeyExchange

destructor Destroy; override;

classtSSHServerKeyExchange

inherits from tSSHKeyExchange

implements iSSHServerKeyExchange

(no public members)

classtSSHDiffieHellmanGroup1Client

inherits from tSSHClientKeyExchange

(no public members)

classtSSHDiffieHellmanGroup1Server

inherits from tSSHServerKeyExchange

(no public members)

classtSSHDiffieHellmanGroup14Client

inherits from tSSHClientKeyExchange

(no public members)

classtSSHDiffieHellmanGroup14Server

inherits from tSSHServerKeyExchange

(no public members)

classtSSHDiffieHellmanGroup15Client

inherits from tSSHClientKeyExchange

(no public members)

classtSSHDiffieHellmanGroup15Server

inherits from tSSHServerKeyExchange

(no public members)

classtSSHDiffieHellmanGroup16Client

inherits from tSSHClientKeyExchange

(no public members)

classtSSHDiffieHellmanGroup16Server

inherits from tSSHServerKeyExchange

(no public members)

classtSSHDiffieHellmanGroup18Client

inherits from tSSHClientKeyExchange

(no public members)

classtSSHDiffieHellmanGroup18Server

inherits from tSSHServerKeyExchange

(no public members)

classtSSHCurve25519Client

inherits from tSSHClientKeyExchange

curve25519-sha256 (RFC 8731): X25519 ECDH. Reuses the ECDH math of the DSI EC engine (MustGetDSIEC) over the X25519 curve; the ephemeral public keys are octet strings (EphemIsMPInt=False), the shared secret K is still mpint.

(no public members)

classtSSHCurve25519Server

inherits from tSSHServerKeyExchange

(no public members)

classtSSHCurve448Client

inherits from tSSHClientKeyExchange

curve448-sha512 (RFC 8731): X448 ECDH. Same Montgomery shared-secret path as curve25519 (raw u-coordinate via GroupOpIteration), over the X448 curve with a SHA-512 exchange hash; the ephemeral public keys are octet strings.

(no public members)

classtSSHCurve448Server

inherits from tSSHServerKeyExchange

(no public members)

classtSSHECDHNistClient

inherits from tSSHClientKeyExchange

ecdh-sha2-nistp256/384/521 (RFC 5656): ECDH over the NIST prime curves. These are Weierstrass curves, so the inherited (KeyAgreementScheme_DH1) shared-secret path applies - IsMontgomeryGroup stays False. The ephemeral public key Q is an uncompressed octet-string point (EphemIsMPInt=False; FE2OSFormat=cUncompressed).

(no public members)

classtSSHECDHNistServer

inherits from tSSHServerKeyExchange

(no public members)

classtSSHECDHNistP256Client

inherits from tSSHECDHNistClient

(no public members)

classtSSHECDHNistP256Server

inherits from tSSHECDHNistServer

(no public members)

classtSSHECDHNistP384Client

inherits from tSSHECDHNistClient

(no public members)

classtSSHECDHNistP384Server

inherits from tSSHECDHNistServer

(no public members)

classtSSHECDHNistP521Client

inherits from tSSHECDHNistClient

(no public members)

classtSSHECDHNistP521Server

inherits from tSSHECDHNistServer

(no public members)

classtSSHSntrup761X25519Client

inherits from tSSHCurve25519Client

RFC 9941: sntrup761 + X25519 with SHA-512. The RFC name and the older @openssh.com alias share these engines. Q_C/Q_S are PQ-first strings; K = SHA-512(K_PQ || K_X25519) is a fixed 64-byte string, never an mpint.

destructor Destroy; override;

classtSSHSntrup761X25519Server

inherits from tSSHCurve25519Server

(no public members)

classtSSHKemClientKeyExchange

inherits from tSSHClientKeyExchange

Pure: draft-harrison-sshm-mlkem (mlkem512/768/1024-sha256/384) Hybrid: RFC 10042 (mlkem768x25519 / mlkem768nistp256 / mlkem1024nistp384). The 30/31 framing and the host-key sign/verify of tSSHClient/ServerKeyExchange are reused; only the INIT/REPLY payloads and the exchange-hash middle differ (IsKEM=True). The pure path calls the ML-KEM primitives (MustGetDSIML) directly; the hybrid path drives the composite ML-KEM pool (MustGetDSICK, StreamSec.DSI.CompositeKEM): the client offer C_INIT is the composite public key, the server reply S_REPLY is the composite ciphertext, and K is the SSH combiner output.

destructor Destroy; override;

classtSSHKemServerKeyExchange

inherits from tSSHServerKeyExchange

(no public members)

classtSSHMLKEM512Client

inherits from tSSHKemClientKeyExchange

(no public members)

classtSSHMLKEM512Server

inherits from tSSHKemServerKeyExchange

(no public members)

classtSSHMLKEM768Client

inherits from tSSHKemClientKeyExchange

(no public members)

classtSSHMLKEM768Server

inherits from tSSHKemServerKeyExchange

(no public members)

classtSSHMLKEM1024Client

inherits from tSSHKemClientKeyExchange

(no public members)

classtSSHMLKEM1024Server

inherits from tSSHKemServerKeyExchange

(no public members)

classtSSHMLKEM768X25519Client

inherits from tSSHKemClientKeyExchange

(no public members)

classtSSHMLKEM768X25519Server

inherits from tSSHKemServerKeyExchange

(no public members)

classtSSHMLKEM768NistP256Client

inherits from tSSHKemClientKeyExchange

(no public members)

classtSSHMLKEM768NistP256Server

inherits from tSSHKemServerKeyExchange

(no public members)

classtSSHMLKEM1024NistP384Client

inherits from tSSHKemClientKeyExchange

(no public members)

classtSSHMLKEM1024NistP384Server

inherits from tSSHKemServerKeyExchange

(no public members)

interfaceiSSHClientKeyExchangeGroup

inherits from iSSHKeyExchange

Diffie Hellman with arbitrary groups

function GetServerKey: iSignPublicKey; procedure SetServerKey(const Value: iSignPublicKey); procedure Pass1(const aGroupSizeMsg: tBytes); function Pass2(const aGEXMsg: tBytes): tBytes; function Pass3(const aKEXMsg: tBytes; const aKeys : iSSHSymmetricKeys) : Boolean; property ServerKey: iSignPublicKey read GetServerKey write SetServerKey;

interfaceiSSHServerKeyExchangeGroup

inherits from iSSHKeyExchange

function GetServerKey: iSignPrivateKey; procedure SetServerKey(const Value: iSignPrivateKey); function Pass1(const aGroupSizeMsg: tBytes): tBytes; function Pass2(const aKEXMsg: tBytes; const aKeys : iSSHSymmetricKeys) : tBytes; property ServerKey: iSignPrivateKey read GetServerKey write SetServerKey;

Routines