Indy 9
|
TIdBlockCipherIntercept = class(TIdConnectionIntercept)
property BlockSize: Integer;
BlockSize is used to determine when an EIdBlockCipherInterceptException exception shopuld be raised when a block exceeeds the indicated value.
The default value for BlockSize is IdBlockCipherBlockSizeDefault as assigned in the Create constructor.
BlockSize can be changed at runtime as long as the new block size value is greater than 0 and does not exceed IdBlockCipherBlockSizeMax. ANy change to the value in BlockSize outside this acceptable range is ignored.
property Data: TObject;
Data is set to the corresponding property value from the TIdBlockCipherIntercept passed as an argument in CopySettingsFrom.
Note: Data is not maintained by the Create or Destroy methods. Applications must provide memory and/or resource protection required to initailize and free the contents of the Data property.
procedure CopySettingsFrom(ASrcBlockCipherIntercept: TIdBlockCipherIntercept);
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Receive(ABuffer: TStream); override;
The Receive method will exit immediately if the size of the internal buffer is zero (or a negative number).
Receive attempts to read and process blocks of data from the internal receive buffer, using BlockSize as the size of each data block. Receive will continue to read and process data blocks until all data has been read, or the remaining content in the internal receive buffer is smaller than BlockSize. Specifics of the decryption algorithm can be implemented using the OnReceive event handler and the CipherData property.
If a block is read from the internal buffer that is larger than BlockSize, an EIdBlockCipherInterceptException will be raised.
Receive calls the protected virtual Decrypt method for each data block read from the internal receive buffer. Unprocessed bytes from the buffer smaller than BlockSize bytes are cached in the internal receive buffer for subsequent Receive operations. The internal receive buffer is truncated to the number of unprocessed bytes remaining.
The decrypted values for all data blocks are returned in the ABuffer argument, and the length of ABuffer is set to the number of decrypted bytes returned to the stream.
procedure Send(ABuffer: TStream); override;
The Send method will exit immediately if the size of the internal buffer is zero (or a negative number).
Send attempts to read and process blocks of data from the internal send buffer, using BlockSize as the size for each data block. Send will continue to read and process data blocks until all data has been read, or the remaining content in the internal send buffer is smaller than BlockSize. Unprocessed bytes from the buffer smaller than BlockSize bytes are read from the buffer, padded to the length indicated in BlockSize, and Encrypted to complete the transformation of data. Specifics of the encryption algorithm can be implemented using the OnSend event handler and the CipherData property.
Send calls the protected virtual Encrypt method for each data block in the internal Send buffer. The encrypted values for all data blocks are returned in the ABuffer argument, and the length of ABuffer is set to the number of encrypted bytes returned to the stream.
property OnReceive: TIdBlockCipherInterceptDataEvent;
ASender is the TIdBlockCipherIntercept instance for the event notification.
ASrcData is a Pointer to the encrypted data to use as input for the transformation.
ADstData is a Pointer to the unencrypted data after transformation.
Applications must assign a procedure to the event handler to allow implementation of a specific decryption algorithm, and to perform data transformation.
Use OnSend to implement the encryption algorithm used for the block intercept.
property OnSend: TIdBlockCipherInterceptDataEvent;
ASender is the TIdBlockCipherIntercept instance for the event notification.
ASrcData is a Pointer to the unencrypted data to use as input for the transformation.
ADstData is a Pointer to the encrypted data after transformation.
Applications must assign a procedure to the event handler to allow implementation of a specific encryption algorithm, and to perform data transformation.
Use OnReceive to implement the decryption algorithm used for the block intercept.