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 decrypted.
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 decryption
- KeyLength - length of the key
- Data - the data to be decrypted and a placeholder for decrypted data
- DataSize - the size of the data to be decrypted
- ObjectID - reference value that was passed during encryption of the data block
- PageIndex - reference value that was passed during encryption of the data block
- 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 decrypted data.
The event is fired when custom encryption is used and the data block must be decrypted. Data to decrypt is put to 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 decrypt using this key) or specify the identifier of the decryption key. In the latter case this identifier is passed via Key parameter.
The event handler should put the result of decryption to the buffer pointed by Data parameter (i.e. the same buffer, which contains the encrypted data). This means that the size of the decrypted data block must not exceed the size of the encrypted data block.
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.