Encrypt Function

Description

Encrypts a buffer.

Syntax

hasp_status_t HASP_CALLCONV hasp_encrypt(
                hasp_handle_t   handle,
void * buffer,
hasp_size_t length
                )

Parameters

handle

Handle for the session

buffer

Pointer to the buffer to be encrypted

length

Size (in bytes) of the buffer to be encrypted. Minimum size: 16 bytes. Maximum size: 4 GB.

Return Values

HASP_STATUS_OK

HASP_INV_HND

HASP_DEVICE_ERR

HASP_TIME_ERR

HASP_TOO_SHORT

HASP_SCHAN_ERR

HASP_ENC_NOT_SUPP

HASP_BROKEN_SESSION

HASP_LOCAL_COMM_ERR

HASP_REMOTE_COMM_ERR

HASP_FEATURE_EXPIRED

HASP_IDENTITY_RATE_LIMIT_EXCEEDED

Usage Notes

Encrypts data using the encryption engine in the Sentinel protection key. The specified session handle controls which Sentinel protection key and which Feature ID encrypt the data buffer. The encryption key remains in the Sentinel protection key. If the encryption fails, the data buffer is not modified. To decrypt the data buffer, use the Decrypt function.

NOTE   To defeat a protection key emulator attempting to bypass software protection, you can check periodically that the protection key is available and that a session for the key exists. This should not be done using GetSessionInfo (this function does not detect a remote broken session). Instead, use one of the following functions: Encrypt, Decrypt, Read, Write. These functions will return HASP_BROKEN_SESSION if a session for the protection key does not exist.

You can call the Encrypt or Decrypt function to check whether the license for the current Feature has expired. See Checking the License Expiration Date of a Feature.

Related Topics

Decrypt Function

hasp_encrypt screen