DataEncrypt Event
Fires to encrypt a block of data using a custom encryption implementation.
Syntax
public event OnDataEncryptHandler OnDataEncrypt; public delegate void OnDataEncryptHandler(object sender, CbdriveDataEncryptEventArgs e); public class CbdriveDataEncryptEventArgs : EventArgs { public IntPtr Key { get; } public int KeyLength { get; } public IntPtr Salt1 { get; } public int Salt1Size { get; } public IntPtr Salt2 { get; } public int Salt2Size { get; } public IntPtr Data { get; } public int DataSize { get; } public int ResultCode { get; set; } }
Public Event OnDataEncrypt As OnDataEncryptHandler Public Delegate Sub OnDataEncryptHandler(sender As Object, e As CbdriveDataEncryptEventArgs) Public Class CbdriveDataEncryptEventArgs Inherits EventArgs Public ReadOnly Property Key As IntPtr Public ReadOnly Property KeyLength As Integer Public ReadOnly Property Salt1 As IntPtr Public ReadOnly Property Salt1Size As Integer Public ReadOnly Property Salt2 As IntPtr Public ReadOnly Property Salt2Size As Integer Public ReadOnly Property Data As IntPtr Public ReadOnly Property DataSize As Integer Public Property ResultCode As Integer End Class
Remarks
This event fires when the component needs to encrypt 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 encrypt all DataSize bytes of data in the Data buffer. After encrypting the data, applications must write it back to the Data buffer. The size of the encrypted 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 salt values that can be used to strengthen encryption, if desired. 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 component'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 component, the event will fire only in the first application. To prevent such a situation, always open a vault in read-write mode.