Filter:Pascal Plain C C++ (DLL/Lib) C++ (VCL) C++ (.NET) C# VB.NET Java
This event is fired when custom encryption is used and data block must be encrypted.
TSolFSCryptDataEvent = procedure( Sender : TObject; Key : Pointer; KeyLength : LongWord; Data : Pointer; DataSize : LongWord; ObjectID : LongWord; PageIndex : LongWord; var Result : LongInt) of object;
typedef Error (__stdcall *SolFSCryptDataFunc)( LongWord UserData, void * Key, unsigned long KeyLength, void * Data, unsigned long DataSize, unsigned long ObjectID, unsigned long PageIndex);
typedef void (__closure *TSolFSCryptDataEvent)( System::TObject* Sender, void * Key, unsigned long KeyLength, void * Data, unsigned long DataSize, unsigned long ObjectID, unsigned long PageIndex, unsigned long & Result);
public __delegate void SolFSCryptDataEvent( SolFSStorage* Sender, unsigned char key __gc, unsigned char data __gc, unsigned long objectID, unsigned long pageIndex, Int32 __gc &result);
- Sender - reference to the class that called the delegate/event handler
- Key - a key to be used in encryption
- KeyLength - length of the key
- Data - the data to be encrypted and a placeholder for encrypted data
- DataSize - the size of the data to be encrypted
- ObjectID - reference value that can be used as additional salt during encryption
- PageIndex - reference value that can be used as additional salt during encryption
- Result - out parameter (return value for DLL) where the application places the result of the operation. If you are working with file system, Win32 error code is a good candidate for placing to Result parameter. Otherwise you can use any other error codes, just be sure that 0 means success.
[Java]See Description for details about error reporting in Java.
- [Plain C] UserData - application-defined parameter which is specified when creating the storage and passed back to callback function.
[Java] Return values
The buffer with the encrypted data.
The event is fired when custom encryption is used and the data block must be encrypted. The data to encrypt is passed in Data parameter. The size of the data is always multiple to 32.
The password specified for file or storage encryption is passed in Key parameter. When setting the password for the file or storage, you can use the key itself (and encrypt using this key) or specify the identifier of the encryption key. In the latter case this identifier is passed via Key parameter.
The event handler should put the result of encryption to the buffer pointed by Data parameter (i.e. the same buffer, which contains the data to be encrypted). This means that the size of the encrypted data block must not exceed the size of the original data block.
ObjectID and PageIndex can be used as additional parameters to strengthen encryption.
The callback/event handler must be set before the storage is opened.
You need to implement ISolFSEncryptionEvents interface in your code and pass the object, that implements the events, to one of SolFSStorage constructors that accept storageEvents parameter.
ERROR REPORTING: In Java you can't return more than one parameter, so the natural way is to throw an exception. You can throw any exception, and this exception will be passed back to the code, which called one of SolFS functions. So if you use callback mechanism and throw exception from within event handlers, be sure to wrap each call to SolFS methods with try/catch.