DataDecrypt Event

Fires to decrypt a block of data using a custom encryption implementation.

Syntax

ANSI (Cross Platform)
virtual int FireDataDecrypt(CBVaultDataDecryptEventParams *e);
typedef struct {
const void *Key;
int KeyLength;
const void *Salt1;
int Salt1Size;
const void *Salt2;
int Salt2Size;
void *Data;
int DataSize;
int ResultCode; int reserved; } CBVaultDataDecryptEventParams; Unicode (Windows) virtual INT FireDataDecrypt(CBVaultDataDecryptEventParams *e);
typedef struct {
LPCVOID Key;
INT KeyLength;
LPCVOID Salt1;
INT Salt1Size;
LPCVOID Salt2;
INT Salt2Size;
LPVOID Data;
INT DataSize;
INT ResultCode; INT reserved; } CBVaultDataDecryptEventParams;
- (void)onDataDecrypt:(NSMutableData*)key :(int)keyLength :(NSMutableData*)salt1 :(int)salt1Size :(NSMutableData*)salt2 :(int)salt2Size :(NSMutableData*)data :(int)dataSize :(int*)resultCode;
#define EID_CBVAULT_DATADECRYPT 3

virtual INT CBFSSTORAGE_CALL FireDataDecrypt(LPVOID &lpKey, INT &iKeyLength, LPVOID &lpSalt1, INT &iSalt1Size, LPVOID &lpSalt2, INT &iSalt2Size, LPVOID &lpData, INT &iDataSize, INT &iResultCode);

Remarks

This event fires when the class needs to decrypt a block of data using an application-defined encryption implementation. Please refer to the Encryption topic for more information.

This event only needs to be handled by applications that use one of the CBFSSTORAGE_EM_CUSTOM* encryption modes. To handle this event properly, applications must decrypt all DataSize bytes of data in the Data buffer. After decrypting the data, applications must write it back to the Data buffer. The size of the decrypted data must match DataSize, which is always a multiple of 32.

The Key buffer contains the encryption key (e.g., password) specified for the file, alternate stream, or vault whose data is being decrypted. The KeyLength parameter specifies the length, in bytes, of Key.

The Salt1 and Salt2 buffers contain the same salt values provided when the data was encrypted in an earlier DataEncrypt event. The Salt1Size and Salt2Size parameters specify the length, in bytes, of Salt1 and Salt2.

Please refer to the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), set it to a non-zero value to report an appropriate error. Please refer to the Error Reporting and Handling topic for more information.

Note: An application should not attempt to call class's methods from handlers of this event. Doing this is guaranteed to cause a deadlock.

Note: when a storage is opened concurrently in read-only mode by several applications using CBDrive or CBMemDrive class, the event will fire only in the first application. To prevent such a situation, always open a vault in read-write mode.

Copyright (c) 2021 Callback Technologies, Inc. - All rights reserved.
CBFS Storage 2020 C++ Edition - Version 20.0 [Build 8031]