HashCalculate Event

Fires to calculate a password hash using a custom hashing implementation.

Syntax

// CBVaultHashCalculateEventArgs carries the CBVault HashCalculate event's parameters.
type CBVaultHashCalculateEventArgs struct {...}

func (args *CBVaultHashCalculateEventArgs) Password() []byte
func (args *CBVaultHashCalculateEventArgs) PasswordSize() int32
func (args *CBVaultHashCalculateEventArgs) Salt() []byte
func (args *CBVaultHashCalculateEventArgs) SaltSize() int32
func (args *CBVaultHashCalculateEventArgs) Hash() []byte
func (args *CBVaultHashCalculateEventArgs) SetHash(value []byte)
func (args *CBVaultHashCalculateEventArgs) HashSize() int32
func (args *CBVaultHashCalculateEventArgs) ResultCode() int32
func (args *CBVaultHashCalculateEventArgs) SetResultCode(value int32)

// CBVaultHashCalculateEvent defines the signature of the CBVault HashCalculate event's handler function.
type CBVaultHashCalculateEvent func(sender *CBVault, args *CBVaultHashCalculateEventArgs)

func (obj *CBVault) GetOnHashCalculateHandler() CBVaultHashCalculateEvent
func (obj *CBVault) SetOnHashCalculateHandler(handlerFunc CBVaultHashCalculateEvent)

Remarks

This event fires when the component needs to calculate a password hash using an application-defined hashing implementation. The calculated hash is used to check the password's validity before using it for encryption. 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*_DIRECT_KEY encryption modes. To handle this event property, applications must calculate a hash of the data in the Password buffer (whose length, in bytes, is specified by PasswordSize). The calculated hash must be written to the Hash buffer. The size of the calculated hash must not exceed HashSize.

Applications may, if desired, perform their own password validation and return a predefined value for the hash. Applications should not use the same process for key derivation and hash calculation (or should, at the very least, ensure that salt is used in both operations).

The Salt buffer contains a salt value that can be used (if desired) to strengthen security by increasing the uniqueness of the hash. The SaltSize parameter specifies the length, in bytes, of Salt.

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.

Copyright (c) 2021 Callback Technologies, Inc. - All rights reserved.
CBFS Vault 2020 Go Edition - Version 20.0 [Build 7982]