API Reference
stSecComp
SecComp Unit
Classes, interfaces and records
classeSecComp
inherits from Exception
(no public members)
interfaceiGetRSAKey
function GetKey(const aIdentifier: OctetString): iUnknown;
An application rarely calls GetKey directly; it is the standard way a consumer that only holds a generic key/proto component (an iUnknown, e.g. fClientKey/fClientKeys in the SSH client/server units) discovers whether that component actually wraps an RSA key, by doing Supports(comp, iGetRSAKey,lGe...
Full description »
interfaceiGetDSSKey
function GetKey(const aIdentifier: OctetString): iUnknown;
Same discovery pattern as iGetRSAKey.GetKey, for a component wrapping a DSA (DSS) key; an application queries this via Supports() rather than calling it on a statically-typed reference. Not tied to a particular client/server role -- either side can hold a DSS key component.
interfaceiGetDHKey
function GetKey(const aIdentifier: OctetString): iUnknown;
interfaceiGetECDSAKey
function GetKey(const aIdentifier: OctetString): iUnknown;
Same discovery pattern as iGetRSAKey.GetKey, for a component wrapping an ECDSA key. Used on the SSH CLIENT side (fClientKey in StreamSec.SSH.Client) to pick the ecdsa-sha2-nistp* client-auth path, and on the SSH SERVER side (fServerECDSAKey in StreamSec.SSH.BaseComponent, shared by client and ser...
Full description »
interfaceiGetECDHKey
function GetKey(const aIdentifier: OctetString): iUnknown;
interfaceiGetMLDSAKey
function GetKey(const aIdentifier: OctetString): iUnknown;
Same discovery pattern as iGetRSAKey.GetKey, for a component wrapping a post-quantum ML-DSA (FIPS 204) key; used to detect/fetch an ML-DSA key from a generic key component without the caller needing to know its concrete class. No client/server-specific meaning.
interfaceiGetMLKEMKey
function GetKey(const aIdentifier: OctetString): iUnknown;
Same discovery pattern as iGetRSAKey.GetKey, for a component wrapping a post-quantum ML-KEM (FIPS 203) key-encapsulation key. No client/server- specific meaning; either side's key component can be queried this way.
interfaceiGetCompositeMLKEMKey
function GetKey(const aIdentifier: OctetString): iUnknown;
Same discovery pattern as iGetRSAKey.GetKey, for a component wrapping a composite (hybrid traditional+ML-KEM) key-encapsulation key, as used by the composite-ML-KEM TLS/CMS support elsewhere in the library. No client/server-specific meaning.
interfaceiGetCompositeMLDSAKey
function GetKey(const aIdentifier: OctetString): iUnknown;
Same discovery pattern as iGetRSAKey.GetKey, for a component wrapping a composite (hybrid traditional+ML-DSA) signature key, as used by the composite-ML-DSA cert/CMS support elsewhere in the library. No client/server-specific meaning.
interfaceiGetEdDSAKey
function GetKey(const aIdentifier: OctetString): iUnknown;
Same discovery pattern as iGetRSAKey.GetKey, for a component wrapping an Ed25519/Ed448 (EdDSA) key. Used on the SSH CLIENT side (fClientKey in StreamSec.SSH.Client) to pick the ssh-ed25519/ssh-ed448 client-auth path, and on the SSH SERVER side (fServerEdDSAKey in StreamSec.SSH.BaseComponent, shar...
Full description »
interfaceiGetSLHDSAKey
function GetKey(const aIdentifier: OctetString): iUnknown;
Same discovery pattern as iGetRSAKey.GetKey, for a component wrapping a post-quantum SLH-DSA (FIPS 205) key. No client/server-specific meaning; used wherever a generic key component needs to be checked for/coerced to this key kind.
classTstCustomMPKey
inherits from TstCustomProtoComponent{$IFDEF D5}
function LoadPublicKeyFromStream(const aIdentifier: OctetString; aStrm : TStream) : Boolean; virtual;
Base implementation just raises "Not implemented"; every concrete key component (TstRSAPublicKey, TstDSSPublicKey, TstECDSAPublicKey, etc. in StreamSec.DSI.ArithComp/stMPArithComp) overrides it with its own wire format.
Full description »
procedure SavePublicKeyToStream(aStrm: TStream; const aIntf: TGUID); virtual;
Base implementation just raises "Not implemented"; concrete key components override it to serialize the public key in their own wire format, selected via aIntf (a GUID such as an iSSHProtocolFormat).
Full description »
procedure SavePrivateKeyToStream(aStrm: TStream; const aIntf: TGUID); virtual;
Base implementation just raises "Not implemented"; concrete key components (e.g. TstRSAKey, TstDSSKey, TstECDSAKey) override it to serialize the PRIVATE key material in their own format, selected via aIntf.
Full description »
classTstKeyRingComponent
inherits from TstCustomMPKey
function AddPrivateAESKey(const PrivKey; PrivKeyLen : Integer; IsLongTermKey: Boolean; KeyIdentifier: AnsiString = '') : Integer; virtual; abstract;
function AddPrivate3DESKey(const PrivKey; PrivKeyLen : Integer; IsLongTermKey: Boolean; KeyIdentifier: AnsiString = '') : Integer; virtual; abstract;
function AddPrivateARC4Key(const PrivKey; PrivKeyLen : Integer; IsLongTermKey: Boolean; KeyIdentifier: AnsiString = '') : Integer; virtual; abstract;
function AddPrivateTwoFishKey(const PrivKey; PrivKeyLen : Integer; IsLongTermKey: Boolean; KeyIdentifier: AnsiString = '') : Integer; virtual; abstract;
function AddPrivateBlowFishKey(const PrivKey; PrivKeyLen : Integer; IsLongTermKey: Boolean; KeyIdentifier: AnsiString = '') : Integer; virtual; abstract;
function FindCreateCipher(const KeyIdentifier: OctetString; Alg : tCipherAlg; Mode : tCipherMode; var KeyedIV : Boolean; var Param : OctetString; MACKey : iSecretKey = nil) : tCipher; virtual; abstract;
classTstCustomSecComponent
inherits from TstBaseComponent
constructor Create(aOwner: tComponent); override;
Common base constructor for every cipher/MAC/hash component descended from here (TstCustomCipherComponent, TstCustomMAC, TstHash, TstCipherMAC); an application does not call this directly, it just constructs the concrete component (e.g. TstCipher.Create). Sets up the internal tCriticalSection used by Lock/Unlock.
» member page
destructor Destroy; override;
Frees the internal critical section and invokes the descendant's CleanUp (which wipes key material); an application does not call this directly beyond the normal component-lifetime Free/destroy.
» member page
procedure Lock;
Acquires this component's internal critical section. An application only needs this if it shares a single cipher/MAC/hash component instance across multiple threads and must serialize a multi-step operation (e.g. SetKey.../Encrypt.../Done) on it; the component itself does not call Lock/Unlock internally, so single-threaded use can ignore it. No client/server-specific meaning.
» member page
procedure Unlock;
Releases the critical section acquired by Lock; see Lock for when an application needs this (multi-threaded sharing of one component instance).
» member page
classTstCustomMAC
inherits from TstCustomSecComponent
procedure Done(Digest: Pointer; DigestLen: Integer = -1); virtual; abstract;
Abstract in this base class; finalizes the running hash/MAC and, when the Digest pointer is non-nil, copies up to aDigestLen bytes of the result to it (aDigestLen is clamped to the algorithm's digest size).
Full description »
procedure GetContext(Context: Pointer); virtual; abstract;
Abstract in this base class; captures the algorithm's current internal state into Context so it can be restored later via SetUpContext. An application uses this to snapshot/resume a long-running hash/MAC computation (e.g. incremental hashing of a large stream) rather than keeping all data buffered. No client/server-specific meaning.
» member page
procedure HashData(const aData; Count: Int64); virtual; abstract;
Abstract in this base class; feeds Count octets at aData into the running hash/MAC. This is the core streaming-input method a caller uses when hashing/MACing data incrementally (e.g. large or chunked input) instead of via the one-shot HashStr/HashPtr/HashIntf convenience calls. No client/server-specific meaning.
» member page
procedure HashIntf(aData: iSecretKey); virtual; abstract;
Abstract in this base class; convenience overload of HashData that takes the input as an iSecretKey, so secret data (e.g. key material being MACed) can be hashed without ever exposing it as a plain buffer that the caller must remember to wipe. No client/server-specific meaning.
» member page
procedure HashPtr(aData: Pointer; Count: Int64); virtual; abstract;
Abstract in this base class; convenience overload of HashData taking a raw pointer + count instead of an open array parameter, for callers that already have a Pointer/size pair (e.g. from a buffer or FFI boundary). No client/server-specific meaning.
» member page
procedure HashStr(const aData: OctetString); virtual; abstract;
Abstract in this base class; convenience overload of HashData that takes an OctetString, the most common one-shot way an application hashes/MACs a whole in-memory string/byte buffer at once. No client/server-specific meaning.
» member page
procedure HashStream(aData: tStream; Count: Integer);
Convenience wrapper that reads Count octets from aData (a stream) and feeds them through HashIntf; pass Count = 0 to hash the whole stream from position 0, or a negative Count to hash from the current position to the end. An application uses this to MAC/hash file or network-buffer content held in a TStream without manually chunking it. No client/server-specific meaning.
» member page
procedure SetKeyBuf(const aKey; aKeyLen: Integer);
Convenience wrapper around SetKeyIntf that takes the MAC key as a raw buffer + length; an application uses this to set/replace the key before hashing/MACing (a zero-length key clears it). Only meaningful for keyed MACs (TstCipherMAC); TstHash ignores/accepts a key only for the HMAC-capable hash algorithms it wraps. No client/server-specific meaning.
» member page
procedure SetKeyIntf(aKey: iSecretKey);
Sets/replaces the MAC key from an iSecretKey and re-runs SetUp so the next Hash* call starts a fresh computation with that key; this is the primary way an application supplies key material without it ever existing as an unprotected buffer. No client/server-specific meaning.
» member page
procedure SetKeyPtr(aKey: Pointer; aKeyLen: Integer);
Convenience overload of SetKeyIntf/SetKeyBuf taking the key as a raw Pointer + length; an application uses whichever SetKey* overload matches the form the key material is already held in. No client/server- specific meaning.
» member page
procedure SetKeyStr(const aKey : OctetString; aFormat: tStringFormat = sfBinary);
Convenience overload of SetKeyIntf that accepts the key encoded as binary, hex, or base64 text (aFormat), decoding it before installing it; an application uses this when the key comes from a config file or UI field in one of those textual encodings. No client/server-specific meaning.
» member page
procedure SetUp; virtual; abstract;
Abstract in this base class; (re)initializes the underlying hash/MAC engine for a fresh computation using the currently-set key/algorithm. An application rarely calls this directly -- it runs automatically from SetKeyIntf/SetKeyBuf/etc. and lazily before the first Hash*/Done/ GetContext call if no key has been set yet. No client/server-specific meaning.
» member page
procedure SetUpContext(Context: Pointer); virtual; abstract;
Abstract in this base class; restores internal engine state previously captured by GetContext, resuming a suspended incremental hash/MAC computation. An application uses this together with GetContext to checkpoint/resume hashing of data that arrives over time (e.g. across multiple network reads). No client/server-specific meaning.
» member page
property Digest: OctetString read GetDigest;
Read-only access to the digest/MAC value most recently produced by Done (or computed on demand by the TstHash/TstCipherMAC override if Done has not been called yet); an application reads this after finishing a hash/MAC computation instead of relying only on the Done out-parameter. No client/server-specific meaning.
» member page
inherits from tSTCustomMAC
procedure Done(aDigest: Pointer; aDigestLen: Integer = -1); override;
This is the concrete, droppable-on-a-form component an application uses to compute a plain (or, via SetKeyIntf, HMAC-style keyed) hash of some data -- set HashAlgorithm, then call SetUp (SetKeyIntf/SetKeyBuf do this for you when supplying a key) to create the underlying tHash, feed data via HashS...
Full description »
procedure GetContext(Context: Pointer); override;
See TstCustomMAC.GetContext; delegates to the underlying tHash's GetContext so an in-progress hash computation can be snapshotted and later resumed with SetUpContext.
» member page
procedure HashData(const aData; Count: Int64); override;
See TstCustomMAC.HashData; feeds Count octets at aData directly into the underlying tHash instance. Unlike Done/GetContext/SetUpContext this does NOT lazily create the tHash -- SetUp (run automatically by SetKeyIntf/ SetKeyBuf, or called explicitly) must have run first. This is what HashStr/HashPtr/HashIntf ultimately call.
» member page
procedure HashIntf(aData: ISecretKey); override;
See TstCustomMAC.HashIntf; hashes the secret-key-wrapped data without exposing it as a plain buffer, useful when hashing key material.
» member page
procedure HashPtr(aData: Pointer; Count: Int64); override;
See TstCustomMAC.HashPtr; convenience overload of HashData for pointer+count input.
» member page
procedure HashStr(const aData: OctetString); override;
See TstCustomMAC.HashStr; the most common one-shot way an application hashes an in-memory OctetString with this component.
» member page
procedure SetUp; override;
Creates (or recreates) the underlying tHash instance for HashAlgorithm via MustFindHashClass, carrying over any previously-set MAC key. An application rarely calls this directly; it runs automatically the first time hashing is needed after HashAlgorithm/key is (re)configured.
» member page
procedure SetUpContext(Context: Pointer); override;
See TstCustomMAC.SetUpContext; restores previously-captured state (GetContext) into the underlying tHash instance, creating it via SetUp first if needed.
» member page
procedure SuggestRequiredUnits(aProc: tGetStringMethod); override;
Design-time/IDE helper (see IDE/stCustomProtoEditors.pas, which walks a dropped component's SuggestRequiredUnits to list the implementation units -- e.g. stSHA256, stSHA3 -- that must be added to the project's uses clause for the selected HashAlgorithm to actually link; an application does not need to call this at runtime.
» member page
property HashAlgorithm: tHashAlgorithm read fHashAlgorithm write SetHashAlgorithm;
Selects which hash algorithm (SHA-1/SHA-2/SHA-3/MD5/MD2/RipeMD160/ Whirlpool) this component computes; set it before calling SetUp (or any keyed SetKey*, which runs SetUp), as SetUp reads this field to pick the tHash class via MustFindHashClass.
Full description »
inherits from TstCustomMAC
constructor Create(aOwner: tComponent); override;
Defaults MACCipherMode-backing fCipherMode to cmCBC (plain CBC-MAC); an application constructs this component directly (or drops it on a form) to compute a cipher-based MAC -- set CipherAlgorithm/MACCipherMode/ CBCMACPadding and a key, then feed data and call Done. No client/ server-specific meaning.
» member page
procedure Done(aDigest: Pointer; aDigestLen: Integer = -1); override;
See TstCustomMAC.Done; finalizes the running cipher-MAC computation (fCipher.Mac) started in SetUp and copies up to aDigestLen bytes (capped at fCipher.GetFinalLen) into aDigest.
» member page
procedure GetContext(Context: Pointer); override;
See TstCustomMAC.GetContext; captures the underlying cipher's IV/state (fIVLength bytes) so the MAC computation can be resumed later via SetUpContext.
» member page
procedure HashData(const aData; Count: Int64); override;
See TstCustomMAC.HashData; feeds Count octets through the underlying cipher's EncryptToNil (the MAC-only, no-ciphertext-output encryption path), i.e. this is where the actual CBC-MAC/OMAC/etc. computation happens block by block.
» member page
procedure HashIntf(aData: ISecretKey); override;
See TstCustomMAC.HashIntf; MACs the secret-key-wrapped data without exposing it as a plain buffer.
» member page
procedure HashPtr(aData: Pointer; Count: Int64); override;
See TstCustomMAC.HashPtr; convenience overload of HashData for pointer+count input.
» member page
procedure HashStr(const aData: OctetString); override;
See TstCustomMAC.HashStr; the most common one-shot way an application MACs an in-memory OctetString with this component.
» member page
procedure SetUp; override;
Creates the underlying iCipherMAC instance for CipherAlgorithm/ MACCipherMode via MustFindCipherClass and installs the padding scheme selected by CBCMACPadding (zero-padding, 10-padding, OMAC, or XCBC-MAC). An application rarely calls this directly; it runs automatically when a key is set.
» member page
procedure SetUpContext(Context: Pointer); override;
See TstCustomMAC.SetUpContext; restores previously-captured IV/state (GetContext) into the underlying cipher, creating it via SetUp first if needed.
» member page
procedure SuggestRequiredUnits(aProc: tGetStringMethod); override;
Design-time/IDE helper (see IDE/stCustomProtoEditors.pas) that lists the implementation unit (e.g. stAES, stTwoFish) needed for the currently selected CipherAlgorithm; an application does not need to call this at runtime.
» member page
property IVLength: Integer read fIVLength;
The IV/block size (in bytes) implied by CipherAlgorithm and MACCipherMode, recomputed whenever either is set; an application reads this if it needs to size a buffer for GetContext/SetUpContext.
» member page
property CipherAlgorithm: tCipherAlg read FCipherAlgorithm write SetCipherAlgorithm;
Selects which block cipher (AES/TwoFish/BlowFish/etc.) underlies the CBC-MAC/OMAC computation; changing it recomputes IVLength and, combined with MACCipherMode, determines the cipher class SetUp instantiates. No client/server-specific meaning -- both peers of a protocol using a cipher-based MAC must agree on this out of band.
» member page
property MACCipherMode: tMACCipherMode read GetMACCipherMode write SetMACCipherMode;
Chooses between plain CBC-MAC (mcmCBC) and the ABC (Accumulated Block Chaining) variant (mcmABC); an application sets this to match whatever MAC construction the protocol/format it implements requires. No client/server-specific meaning.
» member page
property CBCMACPadding: tCBCMACPadding read fCBCMACPadding write SetCBCMACPadding;
Selects the padding/finalization scheme applied on top of the raw CBC-MAC (zero-padding, 10-padding, OMAC, or XCBC-MAC); an application sets this to match the specific MAC construction it needs to interoperate with, since different schemes produce different tag values for the same key/message. No client/server-specific meaning.
» member page
classTstCustomCipherComponent
inherits from TstCustomSecComponent
implements iCipher
constructor Create(AOwner: TComponent); override;
Base constructor for every concrete cipher component (TstCipher and any other TstCustomCipherComponent descendant); defaults PBKDFClass to tPBKDF2_HMAC (PBKDF2, RFC 8018, with HMAC-SHA-256 and 131072 iterations), the password-based key derivation used by SetKeyPassword.
Full description »
destructor Destroy; override;
Releases the PBKDF reference; an application does not call this directly beyond the normal component Free/destroy.
» member page
procedure CleanUp; override;
Frees the underlying tCipher instance and resets InternalDirection back to Direction, so the component is ready to be keyed again (e.g. for a new message) via SetKey*. An application calls this to explicitly end one encrypt/decrypt operation before starting another with the same component instance, though most SetKey* calls do this internally too.
» member page
procedure DecryptToDst(const aBuf; aBufLen: Integer);
Decrypts aBufLen octets at aBuf and writes the (possibly differently- sized, due to padding) plaintext to DestinationStream; use this "ToDst" family instead of the in-place Decrypt/DecryptPtr when the cipher's mode/MAC/padding means the output cannot be the same size as the input (that is exactly...
Full description »
procedure DecryptPtrToDst(aBuf: Pointer; aBufLen: Integer);
Pointer+length overload of DecryptToDst, for callers that already hold the ciphertext as a raw Pointer.
» member page
function DecryptStreamToDst(aBuf: tStream; Count: Integer): Integer;
Convenience wrapper that reads Count octets from aBuf (a stream) in BufferSize-sized chunks and feeds each chunk through DecryptToDst; pass Count = 0 to decrypt from stream position 0, or a negative Count to decrypt from the current position to the end.
Full description »
procedure DecryptStrToDst(const aBuf: string);
Convenience overload of DecryptToDst for a Delphi string's raw byte content; an application uses this when the ciphertext is already held as a string rather than a buffer/stream.
» member page
procedure Decrypt(var aBuf; aBufLen: Integer);
In-place decryption: overwrites aBuf with the plaintext for a mode without padding/MAC expansion (CanDecryptInplace must be true, e.g. stream ciphers or unpadded block modes); raises (via CheckKeyNotSet) if a destination stream is assigned or a pending IV requirement is outstanding.
Full description »
function DecryptBytes(const aBuf : tBytes; var aOffset, aCount : Integer) : Boolean;
tBytes-array in-place decryption overload of Decrypt, operating on aBuf starting at aOffset for aCount bytes; convenient when the ciphertext is already held in a Delphi dynamic byte array.
» member page
function DecryptIntf(aBuf: ISecretKey): Boolean;
In-place decryption overload of Decrypt taking the ciphertext/plaintext as an iSecretKey, so the buffer is handled via the secret-key wiping machinery rather than a plain buffer the caller must remember to wipe itself.
» member page
procedure DecryptPtr(aBuf: Pointer; aBufLen: Integer);
Pointer+length overload of the in-place Decrypt, and raises as it does.
» member page
function DecryptStr(const aBuf: OctetString): OctetString;
One-shot convenience decrypt of an OctetString to a new OctetString result (not in place); the simplest way an application decrypts a small, already-in-memory ciphertext value.
Full description »
function DoneToDst: Boolean;
Finalizes a "ToDst" streaming encrypt or decrypt operation started with EncryptToDst/DecryptToDst, then calls CleanUp: on encrypt, writes the trailing cipher-MAC tag to DestinationStream when fCipherMAC is in use; on decrypt, verifies the trailing MAC or padding held back by DecryptToDst (again o...
Full description »
procedure EncryptToDst(const aBuf; aBufLen: Integer);
Encrypts aBufLen octets at aBuf and writes the resulting ciphertext to DestinationStream (see DecryptToDst for why the "ToDst" family exists instead of in-place Encrypt/EncryptPtr). An application streams multiple calls before finishing with DoneToDst. No client/server- specific meaning; either peer encrypts data it is about to send this way.
» member page
procedure EncryptPtrToDst(aBuf: Pointer; aBufLen: Integer);
procedure EncryptStrToDst(const aBuf: string);
Convenience overload of EncryptToDst for a Delphi string's raw byte content.
» member page
procedure Encrypt(var aBuf; aBufLen: Integer);
In-place encryption: overwrites aBuf with the ciphertext for a mode without padding/MAC expansion (CanEncryptInplace must be true); see Decrypt for the corresponding constraints, including the whole number of blocks that ECB, CBC and ABC require (S_ERR_NotWholeBlocks): a shorter last block is ref...
Full description »
function EncryptBytes(const aBuf : tBytes; var aOffset, aCount : Integer) : Boolean;
tBytes-array in-place encryption overload of Encrypt, operating on aBuf starting at aOffset for aCount octets.
Full description »
function EncryptIntf(aBuf: iSecretKey): Boolean;
In-place encryption overload of Encrypt taking the plaintext/ciphertext as an iSecretKey. When the cipher cannot encrypt aBuf in place (see Encrypt), it returns False, with aBuf still the plaintext, which it does not pass to MAC.
» member page
procedure EncryptPtr(aBuf: Pointer; aBufLen: Integer);
Pointer+length overload of the in-place Encrypt, and raises as it does.
» member page
function EncryptStreamToDst(aBuf: tStream; Count: Integer): Integer;
Convenience wrapper that reads Count octets from aBuf (a stream) in BufferSize-sized chunks and feeds each chunk through EncryptToDst; same Count = 0/negative semantics as DecryptStreamToDst.
Full description »
function EncryptStr(const aBuf: OctetString): OctetString;
One-shot convenience encrypt of an OctetString to a new OctetString result (not in place); the simplest way an application encrypts a small, already-in-memory plaintext value.
Full description »
procedure SetKeyBuf(const aKey; AKeyLen: Integer);
Sets/replaces the cipher key from a raw buffer+length (also honoring KeyedIV); an application uses this to key the cipher directly rather than via a password (SetKeyPassword) or a KeyRing lookup (SetKeyFromKeyRing). Calling any SetKey* method (re)creates the underlying tCipher and its padding/MAC wiring, discarding any previous key. No client/server-specific meaning.
» member page
function SetKeyFromKeyRing: Boolean;
Looks up (or creates) the cipher's key material from the assigned KeyRing using KeyIdentifier/Algorithm/Mode, wiring up a MAC key too if MAC is assigned; returns False if no KeyRing/KeyIdentifier is set. An application uses this instead of SetKeyBuf/SetKeyStr when keys are centrally managed by a tSTKeyRingComponent rather than supplied inline. No client/server-specific meaning.
» member page
procedure SetKeyIntf(aKey: iSecretKey);
Sets/replaces the cipher key from an iSecretKey; the primary way an application supplies key material without it ever existing as an unprotected buffer. No client/server-specific meaning.
» member page
procedure SetKeyPassword(aPassword: iSecretKey; aKeyLen: Integer);
Derives the cipher key (and, if MAC is assigned, a separate MAC key) from aPassword using PBKDF (asserted to be assigned), generating a random salt into Param if one is not already set; an application calls this to key the cipher from a user-supplied password rather than raw key bytes -- e.g. password-protected file/archive encryption. No client/server-specific meaning.
» member page
procedure SetKeyPtr(aKey: Pointer; AKeyLen: Integer);
function SetKeyRandom(aKeyLen: Integer): Boolean;
Generates aKeyLen bytes of random key material, stores it as a new private key in the assigned KeyRing (dispatched by cipher algorithm to the matching AddPrivate*Key method) under KeyIdentifier, and then keys this component from that stored key via SetKeyFromKeyRing; an application uses this to b...
Full description »
procedure SetKeyStr(const aKey: OctetString; aFormat: tStringFormat = sfBinary);
Convenience overload of SetKeyPtr that accepts the key encoded as binary, hex, or base64 text (aFormat); an application uses this when the key comes from a config file or UI field in one of those textual encodings.
» member page
procedure SuggestRequiredUnits(aProc: tGetStringMethod); override;
Design-time/IDE helper (see IDE/stCustomProtoEditors.pas) that lists the implementation unit needed for the currently selected Algorithm; an application does not need to call this at runtime.
» member page
property DestinationStream: tStream read fDestinationStream write SetDestinationStream;
The stream that the "ToDst" family (EncryptToDst/DecryptToDst and their Stream/Str/Ptr variants) writes its output to; an application must assign this before calling any of those methods (it is what makes them different from the in-place Encrypt/Decrypt overloads). Reassigning it records the new stream's current position as the rollback point used by DoneToDst on failed MAC verification.
» member page
property IVector: OctetString read GetIVector write SetIVector;
The cipher's current initialization vector; an application reads this after encrypting to learn/transmit the IV that was used (e.g. a randomly-generated one), or writes it before decrypting to set the IV the peer used, when the protocol does not use KeyedIV-derived IVs.
Full description »
property PBKDF: iPBKDF read fPBKDF;
The read-only PBKDF instance created from PBKDFClass; it is the object SetKeyPassword derives the key through, and SetKeyPassword asserts it is assigned. Note SetKeyPassword allocates a fresh PBKDF instance at the end of each run, so after keying this reference is a new, unused instance rather than one carrying that run's parameters (the generated salt is stored in Param, not here).
» member page
property PBKDFClass: tPBKDFClass read fPBKDFClass write SetPBKDFClass;
Selects which PBKDF algorithm class (default tPBKDF2_HMAC, which gets HMAC-SHA-256 and 131072 iterations) SetKeyPassword uses to derive a key from a password; an application changes this before calling SetKeyPassword if it needs a different KDF (e.g. for interoperability with a specific format/pr...
Full description »
property BufferSize: Integer read fBufferSize write SetBufferSize default 0;
Chunk size (in bytes) used internally by DecryptStreamToDst/ EncryptStreamToDst when reading from the source stream; 0 means read the whole requested Count in one buffer. An application raises this to bound memory use when streaming very large files/data through the cipher in smaller chunks. No client/server-specific meaning.
» member page
property Direction: tCipherDirection read fDirection write SetDirection default cdAuto;
Whether this component instance is used for encryption or decryption (or cdAuto, in which case the first EncryptToDst/DecryptToDst streaming call resolves the internal direction; the in-place Encrypt/Decrypt overloads do not consult it).
Full description »
property KeyedIV: Boolean read fKeyedIV write SetKeyedIV default False;
When True, the IV is derived from/keyed together with the cipher key itself (no separate IVector must be supplied before the first operation); when False (default) an explicit IVector must be set (or SetVectorBuf called) before encrypting/decrypting in a mode that needs one.
Full description »
property MAC: TstCustomMAC read fMAC write SetMAC;
Optional companion MAC component (e.g. a TstHash or TstCipherMAC) that DoCipherText feeds the ciphertext through on every Encrypt*/Decrypt* call: on encrypt the buffer is encrypted first and then hashed, on decrypt it is hashed first and then decrypted, so in both directions it is the ciphertext...
Full description »
inherits from TstCustomCipherComponent
property Param;
Promoted from the protected base class; the algorithm-specific parameter blob (e.g. a salt) used together with SetKeyPassword, or set by SetKeyFromKeyRing from the key ring's stored parameters. An application reads/writes this when it needs to persist or transmit the non-secret parameter alongside a password-derived key. No client/server-specific meaning.
» member page
property Algorithm;
Promoted from the protected base class to published so it can be set at design time on this concrete component; selects the block/stream cipher algorithm (AES, TwoFish, ARC4, etc.) this TstCipher instance uses.
Full description »
property KeyIdentifier;
Promoted from the protected base class to published; identifies which key in KeyRing this component should use via SetKeyFromKeyRing.
Full description »
property KeyRing;
Promoted from the protected base class to published; the tSTKeyRingComponent this cipher looks up its key in (via SetKeyFromKeyRing/SetKeyRandom) when keys are centrally managed rather than supplied inline. Leave unassigned if the application keys this component directly with SetKeyBuf/SetKeyStr/SetKeyPassword instead. No client/server-specific meaning.
» member page
property Mode;
Promoted from the protected base class to published; the block cipher mode of operation (ECB/CBC/ABC/CCM/EAX/GCM/etc.) this TstCipher instance uses.
Full description »
property PaddingMode;
Promoted from the protected base class to published; the padding scheme applied for the current Mode (defaulted automatically by SetMode if the previously-set padding is incompatible with the new mode).
Full description »
Types (enumerations, sets, aliases)
enumtCipherDirection
tCipherDirection = (cdAuto,cdDecrypt,cdEncrypt);
tStringFormat = (sfBinary,sfHex,sfBase64);
proctPasswordEvent
tPasswordEvent = procedure (Sender: TObject; aPassword: iSecretKey) of object;
proctTerminateEvent
tTerminateEvent = procedure (Sender: TObject; var aTerminate: Boolean) of object;
enumtMACCipherMode
tMACCipherMode = (mcmCBC,mcmABC);
typeTstCipherCompClass
TstCipherCompClass = class of TstCustomCipherComponent;
Routines