Feature notes: SSH implementation notes
The iSSHGetPaddingHash interface is implemented by ciphers that provide built in data integrity. The tSSHBlockPadding checks if the cipher implements this interface. If it does, the instance returned by GetHash is used for data integrity. Otherwise an instance of the class corresponding to the negotiated MAC option is used.
function GetHash: tHash;
inherits from tHash
class function Algorithm: tHashAlgorithm; override;
class function DigestSize: Integer; override;
procedure GetContext(Context: Pointer); override;
procedure HashData(const Data; Count: Int64); override;
procedure SetUpContext(Context: Pointer); override;
inherits from tHash
class function Algorithm: tHashAlgorithm; override;
class function DigestSize: Integer; override;
procedure GetContext(Context: Pointer); override;
procedure HashData(const Data; Count: Int64); override;
procedure SetUp; override;
procedure SetUpContext(Context: Pointer); override;
inherits from tCustomHashOMAC
class function OID: ObjectIdentifier; override;
inherits from tRijndaelHashOMAC
class function OID: ObjectIdentifier; override;
inherits from tRijndaelHashOMAC
class function OID: ObjectIdentifier; override;
inherits from tCustomHashOMAC
class function OID: ObjectIdentifier; override;
inherits from tTwoFishHashOMAC
class function OID: ObjectIdentifier; override;
inherits from tTwoFishHashOMAC
class function OID: ObjectIdentifier; override;
constructor Create(aCipherAlg: tCipherAlg; aClass: tHashClass);
class procedure RegisterInitialization(aCipherAlg: tCipherAlg; aClass : tHashClass);
class procedure UnregisterInitialization(const aIdentifier: ObjectIdentifier);
inherits from tBlockPaddingCompoundMode
constructor Create(aBlockEncryptor: iBlockEncryptor); override;
destructor Destroy; override;
class function Mode: tBlockPaddingMode; override;
class function ModeName: string; override;
class function SupportsCipherMode(aMode: tCipherMode): Boolean; override;
function BeforeDecrypt(var aSrc : pByteArray; var aSrcCount: Integer; var aDst : pByteArray; var aDstCount: Integer) : Boolean; override;
function BeforeEncrypt(var aSrc : pByteArray; var aSrcCount: Integer; var aDst : pByteArray; var aDstCount: Integer) : Boolean; override;
function BeforeEncryptToNil(var aBuf : pByteArray; var aCount: Integer): Boolean; override;
procedure GetFinalBuf(var aMac; aCount: Integer); override;
function VerifyFinalBuf(const aSrc; aSrcCount: Integer; var aDst; var aDstCount: Integer) : Boolean; override;
inherits from tBlockPaddingGCM
SSH AEAD: aes128-gcm@openssh.com / aes256-gcm@openssh.com + the RFC 5647 AEAD_AES_128_GCM / AEAD_AES_256_GCM. Reuses the GCM crypto of tBlockPaddingGCM (J0/invocation-counter/GHash/tag) and layers the SSH binary-packet framing: the 4-byte packet_length stays in the CLEAR and is the GCM AAD; the region padding_length || payload || padding is GCM-encrypted (its length a multiple of the 16-byte block, padding >= 4); a 16-byte tag follows. The 96-bit nonce is fixed(4) || invocation_counter(8); the counter increments once per packet (independently of the SSH sequence number). The padding_length byte is inside the ciphertext, so the real payload length is only known after decryption - MessageLength is set to packet_length (an upper bound for the caller's buffer) and VerifyFinalBuf reports the true length via aDstCount.
constructor Create(aBlockEncryptor: iBlockEncryptor); override;
destructor Destroy; override;
class function Mode: tBlockPaddingMode; override;
class function ModeName: string; override;
class function SupportsCipherMode(aMode: tCipherMode): Boolean; override;
function BeforeDecrypt(var aSrc : pByteArray; var aSrcCount: Integer; var aDst : pByteArray; var aDstCount: Integer) : Boolean; override;
function BeforeEncrypt(var aSrc : pByteArray; var aSrcCount: Integer; var aDst : pByteArray; var aDstCount: Integer) : Boolean; override;
procedure GetFinalBuf(var aMac; aCount: Integer); override;
function VerifyFinalBuf(const aSrc; aSrcCount: Integer; var aDst; var aDstCount: Integer) : Boolean; override;