VDS 6.2.0 VAE Install API Guide
VDS 6.2.0 VAE Install API Guide
COSTS, CLAIMS, OR LIABILITIES ARISING OUT OF ANY AGREEMENT BETWEEN LICENSEE AND ANY THIRD PARTY.
NO PROVISION OF ANY AGREEMENT BETWEEN LICENSEE AND ANY THIRD PARTY SHALL BE BINDING ON THALES.
Protected by U.S. patents:
6,678,828
6,931,530
7,143,288
7,283,538
7,334,124
Contents
.....................................................................
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Documentation Version History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi
Related Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi
Guide to VAE Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi
Vormetric Data Security Platform—Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
Service Updates and Support Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Installation Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Agent Install Checklist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Determine Your Agent Registration Method . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Host Name Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Initial Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
To Install the VAE Agent on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
To Install the VAE Agent on Linux/UNIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Modify the Key Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
To Modify the Key Cache on the DSM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Certificate Renewal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Uninstalling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
A API Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
General Purpose Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
C_Initialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
C_Finalize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
C_GetInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
C_GetFunctionList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Slot and Token Management Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
C_GetSlotList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
C_GetSlotInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
C_GetTokenInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
C_GetMechanismList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
GetMechanismInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Session Management Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
C_OpenSession . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
C_CloseSession . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
C_CloseAllSessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
C_GetSessionInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
C_Login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
C_Logout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Object Management Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
C_WrapKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
C_UnwrapKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
C_CreateObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
CK_BBOOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
C_DestroyObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
C_FindObjectsInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
C_FindObjects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
C_FindObjectsFinal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
C_GetAttributeValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
C_SetAttributeValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
C_GenerateKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
C_GenerateKeyPair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Digest and MAC Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
C_DigestInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
C_Digest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
C_DigestKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
C_DigestUpdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
C_DigestFinal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Signing and Calculating MAC Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
C_SignInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
C_Sign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
C_VerifyInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
C_Verify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Encryption Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
C_EncryptInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
C_Encrypt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
C_EncryptUpdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
C_EncryptFinal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Decryption Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
C_DecryptInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
C_Decrypt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
C_DecryptUpdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
C_DecryptFinal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Random Data Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
C_GenerateRandom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
C_SeedRandom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
PREFACE
.....................................................................
The Installation and API Reference Guide describes the functions and features of VAE. It provides
descriptions, syntax, and usage examples for each of the actions and data types for the VAE solution. This
document describes the Vormetric implementation of the PKCS #11 standard.
Product/Document
Version Date Changes
6.2.0 3/12/19 Added new section “ Running Samples with the Java
Wrapper”; added GCM support info; added information on
Identities for creating a key directly in a key group; added
Content for new Java Wrapper; added information on
asymmetric keys
6.1.0 6/24/18 6.1.0 release includes many doc fixes and content for
Identities feature, Docker containers, Random API, and SQL
Server.
5.2.5 Patch v1 12/16/16 Update System Requirements. Fix Return Values in Digest
functions.
5.2.5 v3 9/27/16 Added Digest functions and FIPS. Partial copy edit to fix
wording.
5.2.5 v2 8/5/16 Fixed some typos and added note in Installation section
about key cache only in memory and not written to disk.
5.2.4 v2 3/23/16 Fixed some typos and information errors with the naming of
the binaries for installation.
Product/Document
Version Date Changes
ASSUMPTIONS
This documentation assumes knowledge of C and PKCS #11.
The system administrator must have root permissions for the systems on which Vormetric Application
Encryption (VAE) software is installed.
RELATED DOCUMENTS
The following documents are available to registered users on the Vormetric Web site at:
https://help.vormetric.com
1. Data Security Manager (DSM) Installation and Configuration Guide. In most cases, you will
probably use an existing DSM, but use this document if you need to install a new Data Security
Manager (DSM) Appliance.
2. Vormetric Application Encryption (VAE) Installation and API Reference Guide. (This book.) For
developers who want to use application encryption with Vormetric’s implementation of
PKCS #11.
3. Vormetric Security Intelligence Configuration Guide. Use this to integrate your Vormetric VAE
events logs with the ArcSight ESM, Splunk, or IBM QRadar
4. Vormetric Data Security (VDS) Platform Event and Log Messages Reference. A listing of all the
VDS Platform event and log messages with severity, long and short form, and description.
C:\Documents\PDFs\5.2.3>dir
Admin_Guide_V1.pdf
Agent_Install_&_Config_Guide_v2.pdf
Data_Transformation_Guide_v1.pdf
DSM_Automation_Reference_v1.pdf
DSM_Install_Guide_v1.pdf
Event_&_Log_Messages_Ref_v1.pdf
GettingStarted_v1.pdf
VSI_Reference_v1.pdf
RN_DSM.pdf
RN_Linux.pdf
RN_RHEL7.pdf
RN_UNIX.pdf
RN_Windows.pdf
VDSCompatibilityMatrix.pdf
The platform consists of products that share a common, extensible infrastructure. At the heart of the
platform is the DSM, which coordinates policies, keys, and the collection of security intelligence, all of
which is managed and observed through your browser. In addition to the DSM, the Vormetric Data Security
Platform consists of the following products:
• http://help.thalesesecurity.com
• http://support.vormetric.com
• support@thalesesecurity.com
• (877) 267-3247
• http://enterprise-encryption.vormetric.com/contact-sales.html
• sales@thalesesec.net
• (408) 433-6000
.....
Vormetric Application Encryption (VAE) enables data encryption at the application level. Applications can
use VAE to encrypt a column in a database or a field, such as credit card numbers or Social Security
numbers. VAE can also be used to encrypt an entire data file or directory.
VAE provides some of the same functionality as Vormetric Transparent Encryption (VTE), but they differ
significantly. VTE does not support application-level data encryption, but it supports encryption of an entire
data file or directory through an application’s interface. VAE and VTE both offer this file-level encryption,
but they use different mechanisms for it.
NOTE: VAE does not have a daemon that pings the DSM periodically, so it will not
know about changes on the DSM. However, it does pick up new configurations from
the DSM every 15 minutes.
Product Overview
.....................................................................
Application Encryption Workflow
www.example.com
Web Server
Encryption key
Request / Response*
Application
Server
Components
Vormetric Application Encryption (VAE) makes use of several other components of the Vormetric Data
Security (VDS) Platform, including:
Key Agent
The Vormetric Key Agent provides a library that implements the PKCS #11 interface. This
library is a dynamically loadable library (dll) on Windows and a shared object (so) on Linux
and UNIX. The Key Agent's PKCS #11 library communicates over a secure channel to the DSM
for all significant functionality. The Key Agent can also be referred to as the Vormetric
Application Encryption Agent.
Functionality
VAE APIs support real-time I/O encryption and decryption of “at rest” data and log files. Data is encrypted
by adding VAE API calls to existing applications.
The APIs in the Vormetric library are a subset of the PKCS #11 specification version 2.20. They are platform-
independent to cryptographic tokens, and are traditionally used for HSMs (hardware security modules) and
smartcards.
VAE supports single and multi-part encryption and decryption using RSA 1024, RSA 2048, AES 128, and AES
256.
• Create a key
• Find a key
• Destroy a key
• Export a key
• Import a key
• Versioned key support
• Encrypt data
• Decrypt data
• Sign data
• Verify data signature
• Compute the digest for data with a key (HMAC)
• Thales-specific opaque objects
• Random number generation
NOTE: See “API Reference” on page 57 for a complete list of the supported APIs.
keep the keys on the DSM; however, doing this will affect performance. Table compares the
advantages of each option.
Table 1: Key Storage Options
Security - Most secure. The key never - Key is cached on the client in memory.
leaves the DSM. - In compliance with PCI security standards
- In compliance with PCI security
standards
NOTE: For supported agent operating systems and compatibility matrices, see
“Supported OS and Compatibility” on page 113.
.....
This chapter is intended for readers who are not familiar with the Thales/Vormetric security solutions. It
includes detailed descriptions of how the VAE communicates with the DSM, along with the various ways
that Thales/Vormetric handles keys for encryption and decryption. It also describes how the solution
authenticates for a key with the PKCS system of PINs.
This section discusses the two methods available for registration, along with communication with the DSM
during operation. For details on the procedures, refer to the installation chapter in this manual and to the
DSM documentation.
Fingerprint
The fingerprint method requires the DSM Security Administrator to add the FQDN or IP address of each
host to the DSM before registering VAE.
During the registration, the DSM generates the certificate and passes it down to the VAE with the
fingerprint. The security administrator must verify the fingerprint to make sure the certificate is valid.
Shared Secret
The shared secret method requires the DSM Security Administrator to create a shared secret registration
password—a case-sensitive string of characters—for auto-registering a host in a domain or host group.
VAE installers use this shared secret to add and register hosts to the DSM for a domain or host group. This
method can automatically add host names or IP addresses to the DSM. This approach eliminates the need
to verify that the host and DSM share valid certificates. You can add multiple hosts dynamically, during VAE
installation and registration, with a single shared secret password.
If you choose the Shared Secret method, you need the DSM Administrator to supply a shared secret for the
domain, or host group, in which the new host will reside. Then, obtain the shared secret and the validity
period (one hour, day, week, or month). You can then register within that period.
The VAE APIs give the developer ways to share existing keys with the DSM. The two methods that comprise
this functionality include C_CreateObject, which imports key bytes onto the DSM and creates a new key
in the DSM, and C_WrapKey, which exports a wrapped pair of keys (one from the DSM and another key
imported to the DSM).
NOTE: The DSM administrator must set all of the VAE key templates being to retrieve
these keys. Consult the Vormetric Key Management (VKM) Manual for complete
details.
Key Management
.....................................................................
Every encryption system depends on its keys to make it both unique and reversible. Poor key management
is one of the most common causes of an unauthorized hack.
Manual key management was the original solution, but many of today’s systems have too much traffic and
complexity to make this approach possible any longer. When secured data needs to be available at any
time, and when it also needs to be protected as it moves across the network, automated key management
is essential.
The Thales e-Security’s solution, which includes VAE and DSM, ensures that an overarching security policy
is enforced throughout the network, resulting in lower cost and reduced risk of security loopholes.
Key Headers
Thales e-Security provides optional header content for its generated ciphertext output. Generating
ciphertext with headers allows each key to be formally versioned, and it also prevents the need for by trial
and error data decryption due to a lack of a unique identifier for any given key.
Thales e-Security offers three header formats, all of which are based on the DPM format from RSA. The
three variants available are:
• Version 1.5
• Version 2.1
• Version 2.7
NOTE: Keys created with the DSM GUI have no DPM attributes.
1 10 NUL 1 16
UUID (always 16
bytes; mandatory.) Other optional fields
32 bytes
{
RKMC210 NUL 0,0,0,5 UUID NUL 0,0,0,16 1 0,0, CSUM NUL 0,0,
16 0,32
Checksum
0,5
MUID (always 32
bytes; mandatory.) Other optional fields
32 bytes
{
RKMC270 NUL 0,0,0,5 MUID NUL 0,0,0,32 1 0,0, CSUM NUL 0,0,
32 0,32
Checksum
0,5
CKM_THALES_V27HDR 0x04000000
CKM_THALES_V21HDR 0x02000000
CKM_THALES_V15HDR 0x01000000
CKM_THALES_BASE64 0x08000000
can also be ORed with the method to indicate that the whole output (header and ciphertext)
should be BASE64-encoded.
If one of these modifiers is used, the following bit must also be ORed with the method:
CKM_VENDOR_DEFINED (0x80000000)
For C_DecryptInit, the value which can be ORed to the method value is:
CKM_THALES_ALLHDR 0x07000000
and optionally:
CKM_THALES_BASE64 0x08000000
If CKM_THALES_BASE64 is set, the header and the ciphertext after the header will be
BASE64-decoded first.
The following table shows which header types are compatible with which encryption
methods.
Table 2: Header Compatibility with Encryption Methods
Methods
Format
ECB CBC CBC-PAD CTR FPE FF1 GCM
V 1.5 No Yes Yes No No No No
Versioning
In the VAE, a key’s version refers to one of the three RSA headers, each of which is a different version of a
similar format. Once a key has been created to support versioning, the API can append any or none of these
headings to a given cipher text.
Of course, functions that decrypt the data must know which key version to expect.
Thales e-Security uses stateful keys that are fully compatible with the NIST standard. For convenience, the
descriptions of each key state are:
• Preactivation
A key enters this state immediately after it becomes active, and normally stays there until
ready for use. Preactivated keys that have been compromised or are not needed are
destroyed instead.
• Active
Keys in the active state can both encrypt and decrypt information. They are destroyed when
their use period ends, or enter the compromised state when they are suspected of being
compromised.
The active state has two valid sub-states: protect-only and process-only.
• Suspended
Keys can be suspended and reactivated later for several possible reasons. For example, the
entity associated with a key could take a leave of absence, or there needs to be an
investigation into whether the key was compromised. Suspended keys are not allowed to
encrypt data, but they could still decrypt data that was locked before the suspension took
place.
The suspended state has only one valid sub-state, which is process-only.
• Deactivated
Keys are most often deactivated at the end of their use periods. Deactivated keys are not
allowed to encrypt data, but they could still decrypt data that was locked before the
deactivation. Deactivated keys should be destroyed as soon as they are no longer needed.
The deactivated state has only one valid sub-state, which is process-only.
• Compromised
A compromised key must never be used to encrypt information, and it should be destroyed
when no longer needed.
The compromised state has only one valid sub-state, which is process-only.
• Destroyed
The key itself has been deleted, although metadata relating to the key might still be
preserved for record keeping. Such practice is important if it’s later discovered that the key
was compromised before it was deleted.
Opaque Objects
In the Thales/Vormetric environment, opaque objects are used for importing previously unsupported size
keys, creating keys with unsupported algorithms, and importing certificates associated with a key. The
object itself is not necessarily a key.
Cached Keys
One valuable feature of the VAE is its ability to cache keys in local memory, instead of relying exclusively on
a key cache within the DSM. This local cache speeds up performance on database transactions and small
amounts of data. The VAE uses openSSL to perform the encryption locally.
NOTE: For information on how to enable a local key cache, see See “Encryption Use
Cases” on page 39.
AES-GCM includes additional input and output parameters to the known CBC and CTR used to verify the
plain text result of a decryption use GCM. Create AES-GCM keys on the DSM. The VAE receives and register
keys to and the DSM. When implementing GCM consider the following usage restrictions:
• GCM support is only available in the custom Thales Java wrapper. It is not available in the
traditional sun.security.pkcs11 wrapper.
• GCM mode is in C.
• GCM mode is not supported for C#.
Export an asymmetric key in a wrapping key passed to C_WrapKey. The format must be set to PEM in
CK_MECHANISM Mechanism::
If the wrapping key is symmetric key use the CKA_THALES_DEFINED and one of the following wrapping
mechanisms:
• CKM_AES_CBC_PAD
• CKM_RSA_PKCS
In addition to exporting an symmetric key by itself, the following options are supported:
When exporting an asymmetric key, or exporting symmetric key with asymmetric key as the wrapper
include the following additional CKA_THALES_DEFINED mechanism configuration:
NOTE: In this case the wrapping mechanism is handled in the VAE library and not the
DSM.
All the constants should be ORed together to form the mechanism passed in. Refer to the sample code for
examples.
C_WrapKey example:
CK_DEFINE_FUNCTION(CK_RV, C_WrapKey)
(
CK_SESSION_HANDLE hSession, /* the session's handle */
CK_MECHANISM_PTR pMechanism, /* the wrapping mechanism */
CK_OBJECT_HANDLE hWrappingKey, /* wrapping key */
CK_OBJECT_HANDLE hKey, /* key to be wrapped */
CK_BYTE_PTR pWrappedKey, /* gets wrapped key */
CK_ULONG_PTR pulWrappedKeyLen /* gets wrapped key size */
)
C_UnwrapKey example:
CK_DEFINE_FUNCTION(CK_RV, C_UnwrapKey)
(
CK_SESSION_HANDLE hSession, /* session's handle */
CK_MECHANISM_PTR pMechanism, /* unwrapping mech. */
CK_OBJECT_HANDLE hUnwrappingKey, /* unwrapping key */
CK_BYTE_PTR pWrappedKey, /* the wrapped key */
CK_ULONG ulWrappedKeyLen, /* wrapped key len */
CK_ATTRIBUTE_PTR pTemplate, /* new key template */
CK_ULONG ulAttributeCount, /* template length */
CK_OBJECT_HANDLE_PTR phKey /* Gets new handle */
)
Before using the Identities feature on the VAE, the DSM admin must setup keys and key groups on the
domain.
NOTE: For more information about the Identities feature see: “Providing Identity-
Based Key Access Credentials” on page 35 and the Data Security Manager (DSM)
Installation and Configuration Guide.
The VAE provides credentials (username and password) to support Identity-Based Key Access. Permission
based domain access is regulated by Key Groups. Keys are assigned to key groups and can be included in
multiple key groups to establish exclusive access to the keys. The association between identities and key
groups is many to many.
NOTE: For backward compatibility legacy C_Login calls still work. In this case the
Identity User and Identity Password are not passed to the DSM.
CK_DEFINE_FUNCTION(CK_RV, C_Login)
(
CK_SESSION_HANDLE hSession, /* session's handle */
CK_USER_TYPE userType, /* the user’s type*/
CK_CHAR_PTR pPin, /* the user’s PIN*/
CK_ULONG ulPinLen, /* the length of the PIN*/
)
The pPin takes the <registered pin>:<identity name>:identity password>:<default key group>, with <default
key group> being optional.
PKCS#11
.....................................................................
Encryption and Decryption in the VAE follow the PKCS (Public Key Cryptography Standards) interface,
developed by RSA Laboratories. PKCS is actually a group of 15 separate standards, in which #11 is an API
called Cryptoki that defines a generic interface to cryptographic tokens.
PINs
An important part of the PKCS standard is that a PIN be used to log in, enabling the user to access the API
functions for encryption and key management. When a VAE and DSM are used together, this PIN is created
during machine registration.
The PIN is used for encrypting the private certificate file that establishes a secure channel between the VAE
and the DSM. The PIN is hashed for verification of login. It is specific to only the server on which it was
created, which makes it necessary to re-register if the VAE or the DSM is migrated.
Header Files
The header files used by the Cryptoki API contain a comprehensive set of object and function definitions.
• Key Objects
• Certificate Objects
• Domain Parameter Objects
• Mechanism Objects
Types of defined functions include:
.....
This chapter describes how to install and configure Vormetric Application Encryption (VAE) on Windows
and Linux systems. It contains the following sections:
• “Overview” on page 17
• “Installation Plan” on page 18
• “Agent Install Checklist” on page 18
• “Before You Begin” on page 19
• “Initial Setup” on page 21
• “Modify the Key Cache” on page 27
• “Certificate Renewal” on page 28
• “Uninstalling” on page 29
Overview
.....................................................................
Installing the key agent installs the shared library that enables application encryption. The library
(libvorpkcs11.so on Linux or vorpkcs11.dll on Windows) provides functions that the customer can
call to do application encryption and key management.
Assumptions
The IP address, routing configuration, and DNS addresses for the hosts where Vormetric Encryption
Agents are installed allow connectivity to all DSMs.
NOTE: Since the key cache on the VAE agent is only in memory and not written to
disk, the VAE (key) agent must connect to the DSM upon a reboot to retrieve
necessary keys. The challenge-response/generate password option (in which the
user can type in a password to unlock the agent when the DSM is off-line) is available
only for VTE agents and is NOT supported with the VAE (key) agent.
Installation Plan
.....................................................................
Following are the high-level steps for installing and configuring VAE.
1. If fingerprint verification is used, confirm with the DSM Security Administrator that the host
where you will install the agent has been added to the DSM.
2. Collect configuration information.
3. Set up the host name resolution method.
4. Open firewall ports, if applicable.
5. Choose the installation method (Silent or Interactive).
6. Decide if you want to enable the anti-cloning functionality.
7. Install the agent software.
8. Verify the installation.
Protected hosts can be registered with the DSM using either the Fingerprint method or the default Shared
Secret method.
• The Fingerprint method—requires the DSM Security Administrator to add the FQDN or IP
address of each protected host to the DSM database before registering the agent.
After registration, the installer of the agent passes the CA certificate fingerprint to the DSM
Security Administrator to verify that the protected host and DSM share valid certificates.
If you choose the Fingerprint method, ask the DSM Security Manager to add the FQDN or IP
address of the protected host to the DSM database before registering that host.
• The Shared Secret method—requires the DSM Security Administrator to create a shared
secret—a case-sensitive string of characters—for auto-registering a domain or host group.
Agent Installers use the shared secret to add and register protected hosts to the DSM for a
domain or host group. The DSM Security Administrators can skip adding host names or IP
addresses to the DSM database, because this is done automatically using the Shared Secret
Registration method, and there is no need to verify that the protected host and DSM share
valid certificates. Multiple protected hosts can be added dynamically with a single shared
secret password during the agent installation and registration process.
If you choose the Shared Secret method, ask the DSM Security Manager to create a shared secret for the
domain or host group in which the new protected host will reside. Then, get the shared secret and the
validity period (one hour, day, week, or month) and register within that period.
There is a “Require that hosts are first added” checkbox in DSM Shared Secret creation page. If this box is
checked, the hosts must be manually added to the DSM database.
You can map a host name to an IP address using the Domain Name System (DNS). DNS is the most
preferred method of host name resolution.
You can also modify the hosts file on the DSM or identify a host using only the IP address.
• If you use DNS to resolve host names, use the FQDN for the host names.
• If you do NOT use a DNS server to resolve host names, do the following on all of the DSMs and
the protected hosts:
• Modify the hosts file on the DSM: To use names like serverx.domain.com, enter the host
names and matching IP addresses in the /etc/hosts file on the DSM using the host
command under the network menu.
For example:
Request:
Response:
IMPORTANT: You must do this on each DSM, since entries in the hosts file are not replicated
across DSMs.
• Modify the hosts file on the protected hosts: Enter the DSMhost names and matching IP
addresses in the /etc/hosts file on the protected host. You must do this on EACH
protected host making sure to add an entry for all DSM nodes (if using HA).
NOTE: The Vormetric Data Security Manager (DSM) is sometimes referred to in the
code as a “Security Server” or a "Data Security Server” or sometimes as just
the “Server”.
Initial Setup
.....................................................................
The following steps describe how to install the VAE Agent for the first time. For Supported OSs and DSM
compatibility information, refer to the Release Notes.
NOTE: The minimum length for the PIN is 8 characters and maximum length is 63
characters. The PIN cannot contain the $ symbol.
5. Accept the License Agreement and then click Next. The Destination Folder window opens.
6. Click Next to accept the default folder. The Ready to Install the Program screen opens.
NOTE: If you have a Vormetric Transparent Encryption (VTE) (file system) agent
already installed on the system, you cannot change the Destination Folder.
7. Click Install. The agent software installs. This may take a few minutes.
8. When the install is finished, the Install Shield Wizard Completed screen opens. Register
Vormetric Key Agent (64 bit) now is selected.
NOTE: If you have a specific plan to register the agent later, clear the check box for
Register Vormetric Key Agent (64 bit) now, click Finish, and then skip the rest of the
steps in this section.
9. Click Finish to start the registration process. The Register Host window opens. Click Next.
Verify the correct agent type is selected.
10. Click Next. Type the name of the DSM. This name must match the Server name on the
Dashboard of the DSM.
11. Click Next. Enter the name of the machine hosting the agent. You can type the name or
select it from the drop-down menu. This name must match the host name added to the
DSM database by the Security Administrator.
12. Click Next. Enter a password. This is the PIN that will authenticate this device in the
PKCS #11 applications you write.
NOTE: If you are in a cluster environment, we recommend that you enter the same
password for all cluster nodes.
13. Click the Enable hardware association box to enable the cloning prevention function.
14. Click Register. The Register Host window displays the VAE Agent version and a pop-up
window displays the signer CA certificate fingerprint.
At this stage of the installation, the host administrator and DSM Security Administrator must
exchange information to confirm that the agent host and DSM share valid certificates.
15. Host Admin: Send the fingerprint to the DSM Security Administrator and wait for
confirmation.
NOTE: After installation, the PIN or password must be provided by the application
developer when prompted during C_Login. Do not forget this password. To change
the password, you must re-register the agent.
NOTE: Password minimum length for PIN is 8 characters and maximum length is 63
characters.
1. Log on to the host where you will install the VAE Agent. You must have root access.
2. Copy or mount the installation file to the host system.
3. Start the installation. At the prompt, type:
./vee-key-<product-version-build-system>.bin
Example:
./vee-key-6.1.0-rh7-x86_64.bin
4. Type ‘y’ and press Enter to accept the Vormetric License Agreement.
The installation proceeds.
NOTE: The Vormetric Data Security Manager (DSM) is sometimes referred to in the
code as a "Security Server" or a "Data Security Server" or sometimes as
just the "Server".
5. At the following prompt, type ‘y’ or press Enter to proceed with registration, or type ‘n’ if
you specifically plan to register later.
Please enter the primary Security Server host name: DSM Appliance-dg-
15208.com
You entered the host name dsm-dg-15208.com
Is this host name correct? (Y/N) [Y]: Y
Please enter the host name of this machine, or select from the
following list. If using the “fingerprint” registration method, the
name you provide must precisely match the name used on the "Add Host"
page of the Management Console.
[1] h55119.dg.com
[2] 10.3.55.119
Enter a number, or type a different host name or IP address in
manually:
What is the name of this machine? [1]:
You selected "h55119.dg.com".
Example:
Please enter the host name of this machine, or select from the
following list. The name you provide must precisely match the name
used on the “Add Host” page of the Management Console.
[1] host1.example.com
[2] sys41017-priv.example.com
[3] sys41017-vip.example.com
[4] 10.3.41.127
Enter a number, or type a different host name or IP address in
manually:
What is the name of this machine? [1]: 1
Generating certificate...done.
Signing certificate...done.
10. Host Admin: Send the fingerprint to the DSM Security Administrator and wait for
confirmation.
11. DSM Security Admin:
a. Log on to the DSM Management Console and navigate to the domain where the host
was added.
b. Click the Dashboard tab.
c. Match the fingerprint from the Host Admin with the EC CA fingerprint on the
Dashboard.
d. Advise the Host Admin of the results.
12. Host Admin: If the fingerprints match, type ‘y’ and then press Enter. “Installation
success.” is displayed.
NOTE: After installation, the PIN or password must be provided by the application
developer when prompted during C_Login. Do not forget this password. To change
the password, you must re-register the agent.
By default, keys are cached on the host, with a time-to-live value of 44640 minutes (31 days).
• You can choose to store the key on the DSM or cache the key on the host.
• You can also modify how long the key stays in the local key cache before it is re-fetched from
the DSM.
NOTE: There is also the option of “Storing Keys on the Server by Default” by editing
the agent.conf file, which takes precedence over a DSM setting.
4. In the Key Type drop down, select Cached on Host or Stored on Server (DSM).
5. In the Key Refreshing Period (minutes) field, enter the number of minutes you want the key to
exist in the local key cache before it is re-fetched from the DSM. Then click OK.
Certificate Renewal
.....................................................................
The certificate that is registered between the VAE and the DSM expires in one year. However, renewal of
the certificate happens automatically when the library in either makes a C_Initialize() call or a re-
initialization takes place. The library checks for the validity of the agent certificate, and if it is found to
expire within eight (8) days, a certificate signing request (CSR) is sent to the DSM to obtain a new
certificate.
The directory in which the agent certificate is stored is owned by root, so there could be an issue when an
application linking against the pkcs11 VAE library is running under another user. In this case, it is necessary
to run a cron job (on windows) to renew the certificate. The application can be as simple as calling
C_Initialize() and C_Finalize() only. There is a sample program named
vpkcs11_sample_renew_cert within the bundle of sample programs. The crontab entry on Linux should
look like the following:
0 12 * * 1 <path>/vpkcs11_sample_renew_cert
Uninstalling
.....................................................................
To uninstall VAE on Linux, run the uninstall command:
/opt/vormetric/DataSecurityExpert/agent/pkcs11/bin/uninstall
.....
This chapter is for application developers. It describes how to use the Vormetric Application Encryption
(VAE) APIs to integrate VAE functionality with your applications. It contains the following sections:
Sample Code
.....................................................................
VAE provides code examples for C and Java. The sample code demonstrates the following functionality:
https://support.vormetric.com
Place the files in the following directory:
<install directory>/vormetric/DataSecurityExpert/agent/pkcs11/
.../samples/c_samples
.../samples/java_samples
NOTE: Refer to the README file in the samples directory for more information.
To compile and run the sample code provided in c_samples, use gmake. (Previously, the make command
was used on Linux). Use the following commands.
gmake clean
To compile:
gmake
/opt/vormetric/DataSecurityExpert/agent/pkcs11/lib
<install directory>/vormetric/DataSecurityExpert/agent/pkcs11/samples
On a Windows 32-bit machine, find the sample and library files as follows:
• Samples:
C:\Program Files\Vormetric\DataSecurityExpert\agent\pkcs11\samples
• Library installation directory:
C:\Program Files\Vormetric\DataSecurityExpert\agent\pkcs11\bin
On a Windows 64-bit machine, find the sample and library files as follows:
Table 4: Samples
%\ProgramData\Vormetric\DataSecurityExpert\agent\log
IMPORTANT: Make sure you are using VAE version 6.2.0 or newer.
NOTE: See “Example With Thales Java Wrapper” on page 53 for a complete code
sample.
To check whether the API passed this test, view the log files:
• Linux: /var/log/vorpkcs11/selftest.log
• Windows:
C:\ProgramData\Vormetric\DataSecurityExpert\agent\log\vorpkcs11_startu
p.log
If the self-test is successful, the following messages appear in the log file for each startup of the application
running the library:
Linux:
VAE Library (45771): Tue Sep 20 14:40:21 2016 [SUCCESS] selftest passed!
VAE Library (45771): Tue Sep 20 14:40:21 2016 [SUCCESS] integrity check
passed!
Windows:After this verification step, the application can access the cryptographic functions.
If the verification fails, the VAE library logs a message and exits with status 255. The messages logged my
either be related to an integrity failure or a Know Answer Test (KAT) failure.
VAE Library (45771): Tue Sep 20 14:40:21 2016 [FAILURE] selftest failed!
VAE Library (45771): Tue Sep 20 14:40:21 2016 [TERMINATE] exiting due to
failure!
VAE Library (45771): Tue Sep 20 14:40:21 2016 [FAILURE] integrity check
failed!
VAE Library (45771): Tue Sep 20 14:40:21 2016 [TERMINATE] exiting due to
failure!
Use the VAE “C_Login” API to pass in the username and password pair. The user is expected to pass the
following parameters using a colon delimiter:
• vaepin
• Identity User
• Identity Password
If the Identity User and Identity Password are not provided. the VAE accepts the vaepin and
domain access is not restricted by identity/key group.
IMPORTANT: the user parameter cannot include the following characters: “:”, “!”, “@”,
“#”, “$”, “%”, “^”, “&”, “*”, “(“ “)”.
NOTE: For more details see See also “C_Login” on page 73.
Use the VAE “C_Login” API create the Key Group with the following syntax:
Pin:Identity:password:group
To restrict older VAE or VKM clients from accessing key on the DSM, the DSM admin must move all keys
into a key group that requires identity enforcement. This solution is effective for all versions of the VAE or
VKM before 6.1.0.
Metadata logging is used to pass extra information (such as user name, user login ID or any other user-
specified information), associated with the user who makes a particular function call.
Two calls are required for a corresponding function to create metadata logging. In the first call, the input
buffer contains the user metadata to be logged. The corresponding buffer length passed must be zero. The
second call follows the regular PKCS #11 calling conventions by passing in the allocated buffer and its
corresponding length.
C Sample
The following example is for vpkcs11_sample_metadata_logging.c:
encryptAndDecrypt ()
. . .
CK_BYTE* cipherText = NULL_PTR;
CK_ULONG cipherTextLen = 0;
CK_ULONG metaDataLen = 256;
CK_CHAR metadata[] = "META: This is a test metadata/Encryption: user:
tester: hostname" ;
CK_CHAR metadata2[] = "META: This is a test metadata/Decryption: user:
tester: hostname" ;
/* For C_Decrypt */
CK_BYTE* decryptedText = NULL_PTR;
CK_ULONG decryptedTextLen = 0;
/* General */
CK_RV rc = CKR_OK;
. . .
cipherText = (CK_BYTE *)calloc( 1, sizeof(CK_BYTE) * metaDataLen );
if(cipherText != NULL)
{
sprintf((char*)cipherText, "%s", (char *)metadata);
}
printf ("Plain Text length: %d\n", (int)sizeof( plainText));
/* first call C_Encrypt by pass in metadata and obtain cipherText buffer
size upon CKR_OK return */
rc = FunctionListFuncPtr->C_Encrypt(
hSession,
plainText, sizeof (plainText),
cipherText,&cipherTextLen
);
if (rc != CKR_OK){
printf ("C_Encrypt failed\n");
return rc;
}
else
{
printf ("C_Encrypt succeed, cipherTextLen is : %ld \n",
(long)cipherTextLen);
cipherText = (CK_BYTE *)calloc( 1, sizeof(CK_BYTE) * cipherTextLen );
}
. . .
Java Sample
Metadata samples for Java can be found in the following files:
• EncryptDecryptMetaData.java
• EncryptDecryptFileMeta.java
Troubleshooting
.....................................................................
By default, keys are cached on the host. If you don’t want them cached on the host, log on to the DSM
Console, switch to the domain with the desired host, click the Keys tab and select the key name from the
Name list. In the Key Type drop down menu in the Edit Agent Key window, select Stored on Server.
.....
This chapter describes the general work flows of several different encryption applications, followed by a
walk-through of how the encryption and decryption cycle works with the VAE and DSM.
Signing
.....................................................................
One important use for encryption, in addition to securing users’ data, is in the creation of digital signatures.
Just like handwritten signatures, digital signatures are used to indicate the authenticity of the source of a
message, but digital signing is much more difficult to forge.
Creating a signature is an asymmetric encryption process that begins with two generated keys, one public
and one that is private to the sender. The two keys are mathematically linked to allow verification by the
receiver. The next step is to create a hash of at least part of the data to be sent. (For a more in-depth
discussion of hashing, refer to the next section.) In practice, the data to be hashed is usually not the actual
message; it’s simply a large random number. The content of the message may or may not be encrypted
separately.
In either case, the sender encrypts this hashed data with the private key, resulting in the digital signature.
Because the value of the hash is always unique to the data, any change in the data results in a different
hash value. This feature makes it nearly impossible to compromise either the sender’s identity or the
message itself.
The receiver can validate the message by decrypting the hashed data with the sender’s public key. If the
original hash algorithm is known, the receiver can simply compare the computed hash value with the
encrypted hash value in the message. If they match, it proves that the message has not changed since it
was signed. If not, it shows that the message was either tampered with or encrypted with a key that is not
linked to the sender’s public key.
Hashing
.....................................................................
Even though hashing is very different from encryption, it still plays an important role in many different
encryption use cases, including many VAE applications. The fundamental difference between hashing and
encryption is that encryption is designed to be reversible. Hashing is designed not to be.
As detailed in the previous section on Signing, hashing is very useful for generating a signature. However,
there are several other common use cases. For example, one of the most common applications for hashing
is to compare two values that, for security reasons, the user does not want to store internally. Passwords
are the most obvious case, of course. If you have already stored a hashed copy of the user’s password in
your system’s database, all that is required is to run any future password inputs through the same hash
algorithm. You are not interested in what the password was: you are interested only in whether the input
matches the one that was stored.
Most other uses for hashing also involve data integrity. The CRC32 algorithm, for example, is a hash that is
often used for checking for whether compressed data has been corrupted. It’s also possible to use hashing
to check a file system for pirated data.
NOTE: It is very important for a hashing algorithm to avoid a situation where two
different inputs return the same hash value: this phenomenon is called a collision.
Well-designed hash algorithms minimize the probability of collisions, usually based
on input size.
FPE
.....................................................................
Format Preserving Encryption (FPE) is designed to create an encrypted output (ciphertext) that has the
same length and character set as the input (called plaintext). The most common use of FPE is for financial
data, such as credit card numbers, where there is legacy software that is unable to deal with encrypted
data with different lengths or character sets.
Although a variety of FPE algorithms have been used, VAE relies on the FF1 and FF3 algorithms. For
complete details of these, refer to NIST Special Publication 800-38G, Recommendation for Block Cipher
Modes of Operation: Methods for Format-Preserving Encryption.
NOTE: A character set for FPE is entirely user defined. You could define a character
set with as few as 2 characters (‘Y’ and ‘N’ or ‘0’ and ‘1’), as large as 65535, or just 62
(‘0’-‘9’ and ‘A’-‘Z’ and ‘a’-‘z’). It is up to the user to decide how large the character set
should be. However, for VAE, input characters not present in the character set result
in an error.
A character set should be chosen carefully. If it is too small, the user gets an error if a
character that is not part of the character set appears in the input. If the character
set is too large, the input is basically a random sample of the supplied character set!
!
Caution: When using variable-length character sets, make sure to allocate enough
memory for the worst-case ciphertext, which can be larger than the plaintext.
In previous releases, you could decide to store individual keys on the server two ways:
NOTE: Template values override the agent.conf values. Therefore, if you add the
Key_StoredOnServer flag to the agent.conf file, it can be overridden for
individual keys by setting CKA_THALES_CACHED_ON_HOST API attribute to 1, or
through the DSM GUI.
You can enable Automated Key Versioning when you create a key with C_GenerateKey. See Option 2,
below.
NOTE: Automated Key Versioning does not pertain to VAE’s support for RSA DPM
Encryption Header versions.)
The DSM administrator can also implement Automated Key Versioning in the DSM UI.
NOTE: The DSM user interface refers to “Automatic Key Rotation,” which VAE calls
“Automated Key Versioning.”)
A versioned key is a standard cryptographic key that is versioned, with a version number and other
metadata placed as a header in front of encrypted data. Versioned keys enable key material to changed
(sometimes referred to as ‘rotation’) without changing the associated key metadata (such as key name, key
size or algorithm). However, new key material and a new version identifier are created.
A developer can use the APIs of the VAE library to accomplish the following functions:
Encryption: A header containing the key identifier is placed in front of the encrypted data:
C_Encrypt.init, C_EncryptUpdate, C_EncryptFinal
Decryption: The header in front of the encrypted data is parsed and is used to detect the correct key to
decrypt data: C_Decrypt.init, C_DecryptUpdate, C_DecryptFinal
Key creation: A standard cryptographic key is created with its own metadata, including version, name, size,
algorithm, etc.
C_GenerateKey
Key deletion: Key must be in a pre-activated, deactivated, or compromised state before the key can be
deleted using the key ID. Deleting the base key deletes all versions.
C_DestroyObject
Key Import/Export: Key can be imported into DSM with the VAE APIs and each version can be imported
sequentially. Key can be retrieved by wrapping it with another symmetric key.
C_CreateObject/C_WrapKey/C_UnwrapKey
NOTE: To import an existing keypair, you must import the private key. The DSM
regenerates the public key. If only the public key is imported, only the public key is
on the DSM.
Automated key versioning: At requested time intervals, new cryptographic key materials and version ID
are created. The original key name, algorithm, and key size remain unchanged.
C_GenerateKey
them back to the databases. Batch Data Transformation, another product from Thales
eSecurity, is another option for implementing this behavior.
Sample Scenario
• Key is generated; version 1 is created
• When data is encrypted, the data is tagged with a header containing version 1
• When data is decrypted, the application detects that version 1 was used for encryption, and
the correct key is used to decrypt
• At the specified interval, automatic key versioning creates version 2 of the key material
• Now new data is encrypted with the new version 2 key
• When data is decrypted, the application will parse the correct version and decrypt the data.
Note that the version may be 1 or 2.
There are two simple ways to enable automated key versioning in VAE 6.0. The minimum version lifespan is
1 day and there is no effective limit on the number of key versions supported in a versioning rotation
schedule.
NOTE: The VAE term “automated key versioning” and the DSM term “automatic key
rotation” refer to the same thing.
1. In the DSM UI, select Keys > Agent Keys > Keys and click Add.
The Add Agent Key window is displayed.
2. Enter the following values:
Name: create a name
Template: Default_SQL_Symmetric_Key_Template (required)
Algorithm: AES 128 or AES 256
Key Type: Cached on Host (recommended)
Key Creation Method: Generate
Key Refresh Period: (refers to Cached on Host setting—not important for key rotation)
Automatic Key Rotation: checked
Key Version Lifespan (days): any positive number between 1 – 10,000 (inclusive)
3. Click OK.
NOTE: Once the key is created with automatic key rotation checked and the lifespan
set, the key cannot be reverted to non-auto-rotation status.
{CKA_THALES_KEY_VERSION_ACTION, &keyVersionAction,
sizeof(keyVersionAction) } and
{CKA_THALES_KEY_VERSION_LIFE_SPAN, &ulifespan,
sizeof(ulifespan) }
NOTE:
CKA_THALES_KEY_VERSION_ACTION and
CKA_THALES_KEY_VERSION_LIFE_SPAN are defined in
vpkcs11_sample_helper.h.
Actual Values:
CKA_THALES_KEY_VERSION_ACTION 0x40000082
CKA_THALES_KEY_VERSION_LIFE_SPAN 0x40000083
4. Use editor to copy/paste/edit the two attribute types into your application, as part of
generating the key (function C_GenerateKey).
5. Set the attribute types as follows:
• keyVersionAction = 0 [meaning base key creation]
• ulifespan = [any positive number between 1-10,000 (measured in days) for
rotation schedule.]
NOTE: Once the key is created with the ulifespan attribute type set, the key
cannot be reverted to non-auto-rotation status.
NOTE: For more information see the DSM Installation and Configuration Guide.
Complete Walk-Through
.....................................................................
This section examines sample code driving the process used in the VAE to create a key and use it to encrypt
data. These samples are in Java, but the VAE library also supports code in C.
The most important parts of this code are the calls to the PKCS library, beginning with ‘C_’.
Key creation starts with creating the PKCS11 instance, after which the following steps are programically
executed:
This code bundle also has a createKeyObject method, which is similar to createKey
but it also passes CKA_VALUE as one of the key attributes, and uses
C_GenerateObject instead of C_GenerateKey to obtain the key handle.
Finally, the code logs out of the session, closes it, and destroys the PKCS11 instance.
Troubleshooting
If a CKR_DATA_LEN_RANGE error is thrown, do the following:
1.Append these two lines in the agent.conf file:
logger_threshold_P11 = TRACE
appender_threshold_File_Appender = TRACE
Once the PKCS11 session is active and the key is created, the actual encryption is straightforward to code.
The following method takes a predefined text string, encrypts the string, prints the byte length of the
result, and then decrypts the string to create a result that matches the original text.
switch (args.length)
{
case 2:
{
if ( !args[0].equals("-p")) usage();
pin = args[1];
break;
}
case 4:
{
if ( !args[0].equals("-p")) usage();
pin = args[1];
if ( !args[2].equals("-m")) usage();
libPath = args[3];
break;
}
default:
usage();
break;
}
try
{
Vpkcs11Session session =
Vpkcs11_sample_helper.startUp(Vpkcs11_sample_helper.getPKCS11LibPath(libPath),
pin);
if (keyID == 0)
{
System.out.println ("the key is not found, creating it..." );
keyID = Vpkcs11_sample_helper.createKey(session, keyName);
System.out.println ("Key successfully Created. Key Handle: " +
keyID);
}
Vpkcs11_sample_helper.closeDown(session);
}
catch (PKCS11Exception e)
{
System.out.println (e.getMessage());
e.printStackTrace();
}
catch (Exception e)
{
System.out.println ("Exception thrown.");
System.out.println (e.getMessage());
}
}
}
The following code sample shows the GenerateKey class with the Thales Java Wrapper
implemented:
NOTE: For more information see “Using Java 9 and Higher with VAE” on page 33.
} catch (PKCS11Exception e) {
System.out.println("=== PKCS11Exception is thrown ===");
String errMsg = e.getMessage();
System.out.println("=== error message = " + errMsg);
} finally {
try {
p11.C_Logout(sessionHandle);
System.out.println("=== Successfully log out ===");
p11.C_CloseSession(sessionHandle);
System.out.println("=== Successfully close session ===");
} catch (PKCS11Exception e) {
}
}
}
ant "C:\Program
Files\Vormetric\DataSecurityExpert\agent\pkcs11\java_samples\pkc
s11
-wrapper-6.2.0-27.jar" compile
Buildfile: c:\Program
Files\Vormetric\DataSecurityExpert\agent\pkcs11\java_sampl
es\build.xml
compile:
[mkdir] Created dir: c:\Program
Files\Vormetric\DataSecurityExpert\agent\pkc
s11\java_samples\build\classes
[javac] c:\Program
Files\Vormetric\DataSecurityExpert\agent\pkcs11\java_samp
les\build.xml:51: warning: 'includeantruntime' was not set,
defaulting to build.
sysclasspath=last; set to false for repeatable builds
[javac] Compiling 16 source files to c:\Program
Files\Vormetric\DataSecurity
Expert\agent\pkcs11\java_samples\build\classes
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
BUILD SUCCESSFUL
Total time: 5 seconds
c:\Program
Files\Vormetric\DataSecurityExpert\agent\pkcs11\java_samples>
java -cp build/classes/;build/jar/pkcs11-wrapper-6.2.0-27.jar
com.vormetric.pkcs11.sample.CreateKey -p Vormetric456! -m
"C:\Program
Files\Vormetric\DataSecurityExpert\agent\pkcs11\bin\vorpkcs11.dl
l" -k "YourKeyLabel"
Use “;” instead of a “:” between items in the class path on Windows.
Add the “-m” string with the path to the vorpkcs11.dll file.
.....
This API reference is organized by the following functional groups:
CK_DEFINE_FUNCTION(CK_RV, C_Initialize)(
CK_VOID_PTR pInitArgs
);
NOTE: Only the applications written in C will call C_Initialize. Java and .NET
versions do not. For more examples, see the sample code.
Parameter Description
C_Finalize
Called to indicate that an application is finished with using the pkcs11 library.
CK_DEFINE_FUNCTION(CK_RV, C_Finalize)(
CK_VOID_PTR pReserved
);
Parameter Description
Parameter Description
CKR_ARGUMENTS_BAD Generic error code which indicates that the arguments supplied to the
Cryptoki function were in some way not appropriate.
CKR_CRYPTOKI_NOT_INIT Indicates that the function cannot be executed because the Cryptoki
IALIZED library has not yet been initialized by a call to C_Initialize.
C_GetInfo
CK_DEFINE_FUNCTION(CK_RV, C_GetInfo)
(CK_INFO_PTR pInfo);
Parameter Description
Parameter Description
Response Description
manufacturerID ID of the Cryptoki library manufacturer. Must be padded with the blank
character (' '). Should not be null-terminated.
flags Bit flags reserved for future versions. Must be zero for this version.
Parameter Description
CKR_ARGUMENTS_BAD Generic error code which indicates that the arguments supplied to the
Cryptoki function were in some way not appropriate.
CKR_CRYPTOKI_NOT_INIT Indicates that the function cannot be executed because the Cryptoki
IALIZED library has not yet been initialized by a call to C_Initialize.
C_GetFunctionList
Allows the application (caller of the Application Encryption Library) to find the list of APIs that are
supported and their addresses.
CK_DEFINE_FUNCTION(CK_RV, C_GetFunctionList)(
CK_FUNCTION_LIST_PTR_PTR ppFunctionList
);
NOTE: Only the applications written in C will call C_GetFunctionList. Java and
.NET versions do not. For more examples, see the sample code.
Parameter Description
Parameter Description
ppFunctionList Filled in with the address of the list of function pointers from the
PKCS#11 library.
Table 15: Return Values
Parameter Description
CKR_ARGUMENTS_BAD Generic error code which indicates that the arguments supplied to the
Cryptoki function were in some way not appropriate.
Provides list of available slots. It can be a single default slot. In C, call this function twice to get the actual
slot list. The first time, it returns the number of available slots. Allocate memory to the available slots, and
then the second call returns the actual slot list.
CK_DEFINE_FUNCTION(CK_RV, C_GetSlotList)(
CK_BBOOL tokenPresent,
CK_SLOT_ID_PTR pSlotList,
CK_ULONG_PTR pulCount);
);
NOTE: Only the applications written in C will call C_GetSlotList. Java and .NET
versions do not. For more examples, see the sample code.
Parameter Description
Parameter Description
Parameter Description
Parameter Description
pulCount Points to the number of slots available. It is always 1 for our library.
Parameter Description
CKR_ARGUMENTS_BAD Generic error code which indicates that the arguments supplied to the
Cryptoki function were in some way not appropriate.
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied buffer.
CKR_CRYPTOKI_NOT_INIT Indicates that the function cannot be executed because the Cryptoki
IALIZED library has not yet been initialized by a call to C_Initialize.
C_GetSlotInfo
CK_DEFINE_FUNCTION(CK_RV, C_GetSlotInfo)(
CK_SLOT_ID slotID,
CK_SLOT_INFO_PTR pInfo
);
Parameter Description
Parameter Description
Parameter Description
CKR_ARGUMENTS_BAD Generic error code which indicates that the arguments supplied to the
Cryptoki function were in some way not appropriate.
CKR_CRYPTOKI_NOT_INIT Indicates that the function cannot be executed because the Cryptoki
IALIZED library has not yet been initialized by a call to C_Initialize.
C_GetTokenInfo
CK_DEFINE_FUNCTION(CK_RV, C_GetTokenInfo)(
CK_SLOT_ID slotID,
CK_SLOT_INFO_PTR pInfo );
Parameter Description
Parameter Description
Parameter Description
CKR_TOKEN_NOT_PRESENT The token was not present in its slot at the time that the
function was invoked.
CKR_TOKEN_NOT_RECOGNIZED The Cryptoki library and/or slot does not recognize the token
in the slot.
C_GetMechanismList
CK_DEFINE_FUNCTION(CK_RV,C_GetMechanismList)(
CK_SLOT_ID slotID,
CK_MECHANISM_TYPE_PTR pMechanismList,
CK_ULONG_PTR pulCount
);
Parameter Description
Parameter Description
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied buffer.
CKR_CRYPTOKI_NOT_INITIAL Indicates that the function cannot be executed because the Cryptoki
IZED library has not yet been initialized by a call to C_Initialize.
Parameter Description
CKR_TOKEN_NOT_PRESENT The token was not present in its slot at the time that the function
was invoked.
CKR_TOKEN_NOT_RECOGNIZED The Cryptoki library and/or slot does not recognize the token in the
slot.
CKR_ARGUMENTS_BAD Generic error code which indicates that the arguments supplied to
the Cryptoki function were in some way not appropriate.
GetMechanismInfo
CK_DEFINE_FUNCTION(CK_RV, C_GetMechanismInfo)(
CK_SLOT_ID slotID,
CK_MECHANISM_TYPE type,
CK_MECHANISM_INFO_PTR pInfo
);
Parameter Description
Parameter Description
Parameter Description
CKR_TOKEN_NOT_PRESENT The token was not present in its slot at the time that the function
was invoked.
CKR_TOKEN_NOT_RECOGNIZED The Cryptoki library and/or slot does not recognize the token in
the slot.
CKR_ARGUMENTS_BAD Generic error code which indicates that the arguments supplied
to the Cryptoki function were in some way not appropriate.
CK_DEFINE_FUNCTION(CK_RV, C_OpenSession)(
CK_SLOT_ID slotID,
CK_FLAGS flags, CK_VOID_PTR pApplication,
CK_NOTIFY Notify,
CK_SESSION_HANDLE_PTR phSession
);
Supported Functionality
• Only read/write sessions are supported. Maximum number of read/write sessions is 1000.
• No read-only sessions are supported.
• Each thread must run in its own session for multi-threaded applications.
Table 32: Input Parameters
Parameter Description
Parameter Description
Parameter Description
CKR_CRYPTOKI_NOT_INITI Indicates that the function cannot be executed because the Cryptoki
ALIZED library has not yet been initialized by a call to C_Initialize.
C_CloseSession
CK_DEFINE_FUNCTION(CK_RV, C_CloseSession)(
CK_SESSION_HANDLE hSession
);
Parameter Description
Parameter Description
Parameter Description
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_CloseAllSessions
CK_DEFINE_FUNCTION(CK_RV, C_CloseAllSessions)(
CK_SLOT_ID slotID
);
Parameter Description
Parameter Description
C_GetSessionInfo
CK_DEFINE_FUNCTION(CK_RV, C_GetSessionInfo)(
CK_SESSION_HANDLE hSession,
CK_SESSION_INFO_PTR pInfo
);
Parameter Description
Parameter Description
Parameter Description
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_Login
Passes user credentials to login into a token. The credentials can be PIN only for all domain access, include
a user name and password to secure the session access based on key group permissions. Credentials are
entered during Key Agent registration.
CK_DEFINE_FUNCTION(CK_RV, C_Login)(
CK_SESSION_HANDLE hSession,
CK_USER_TYPE userType,
CK_UTF8CHAR_PTR pPin,
CK_ULONG ulPinLen
);
CK_DEFINE_FUNCTION(CK_RV, C_Login)
(
CK_SESSION_HANDLE hSession,
CK_USER_TYPE userType,
CK_CHAR_PTR pPin,
CK_ULONG ulPinLen
);
Parameter Description
CK_CHAR_PTR pPin Password used to register the key agent with the
Data Security Manager.
For identity based access the value must contain the
following:
• vaepin
• user
• userpassword
Parameter Description
Parameter Description
CKR_PIN_INVALID The specified PIN has invalid characters in it. This is the default
error when a check for loginforIdentity fails.
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
CKR_USER_PIN_NOT_INITIALIZED Indicates that the normal user’s PIN has not yet been
initialized.
C_Logout
Logs a user out from a token. You can call C_logout() multiple times in a row.
CK_DEFINE_FUNCTION(CK_RV, C_Logout)(
CK_SESSION_HANDLE hSession
);
Parameter Description
CK_SESSION_HANDLE hSession Session handle that you want to log out of.
Parameter Description
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
Supports key export on the DSM where a symmetric key is wrapped with another symmetric key on the
DSM and then exported. This function supports metadata logging.
CK_DEFINE_FUNCTION(CK_RV, C_WrapKey)(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hWrappingKey,
CK_OBJECT_HANDLE hKey,
CK_BYTE_PTR pWrappedKey,
CK_ULONG_PTR pulWrappedKeyLen
);
Parameter Description
Parameter Description
Parameter Description
Parameter Description
Parameter Description
C_UnwrapKey
Used in conjunction with C_WrapKey, where a symmetric key is wrapped with another symmetric key on
the DSM and then exported.
C_UnwrapKey completes the C_WrapKey feature, allowing the exported key to be imported to a
different DSM (or the same DSM with a different name/label) and ready for future use from the destination.
When exporting and importing the key into a new DSM the key attributes are not preserved. Only the key
material is imported. The new template specifies the key attributes.
IMPORTANT: For wrapped keys with set to Store on Server, the unwrap template must include
the CKA_THALES_CACHED_ON_HOST attribute set to false.
(CK_RV, C_UnwrapKey)
(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hUnwrappingKey,
CK_BYTE_PTR pWrappedKey,
CK_ULONG ulWrappedKeyLen,
CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG ulAttributeCount,
CK_OBJECT_HANDLE_PTR phKey
);
Parameter Description
CK_BYTE_PTR pWrappedKey Points to an array to hold the wrapped key bytes as input
Parameter Description
Parameter Description
CK_OBJECT_HANDLE_PT Returns pointer to a new handle that was imported into either the new
R phKey DSM or the old DSM with a new key name.
C_CreateObject
Imports key bytes into the DSM and creates a symmetric key on the DSM. Maximum length of the key
name is 64 characters. There is no minimum length.
CK_DEFINE_FUNCTION(CK_RV, C_CreateObject)(
CK_SESSION_HANDLE hSession,
CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG ulCount,
CK_OBJECT_HANDLE_PTR phObject
);
Parameter Description
Parameter Description
CK_OBJECT_HANDLE This parameter is filled in with the handle of the newly generated key.
hGenKey
C_DestroyObject
Deletes a key.
Warning! Use this function VERY CAREFULLY. Deleted keys cannot be recovered and
all data encrypted by that key will be lost.
CK_DEFINE_FUNCTION(CK_RV, C_DestroyObject)(
CK_SESSION_HANDLE hSession,
CK_OBJECT_HANDLE hObject
);
Parameter Description
Parameter Description
CKR_PIN_EXPIRED The specified PIN has expired, and the requested operation
cannot be carried out.
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_FindObjectsInit
Initializes a search for a token and session objects that match a template. We only support searching for a
key by the CKA_LABEL, which corresponds to the key name on the DSM. The search template must have
CKA_LABEL as its required attribute.
CK_DEFINE_FUNCTION(CK_RV, C_FindObjectsInit)(
CK_SESSION_HANDLE hSession,
CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG ulCount
);
Parameter Description
The following code shows various attributes that can be searched for:
CK_ATTRIBUTE findKeyTemplatePass[] =
{
{CKA_LABEL, ksid, ksid_len},
{CKA_CLASS, &keyType, sizeof(keyType)}
};
switch(keyidType)
{
case keyIdLabel:
findKeyTemplatePass[0].type = CKA_LABEL;
break;
case keyIdUuid:
findKeyTemplatePass[0].type = CKA_THALES_OBJECT_UUID;
break;
case keyIdMuid:
findKeyTemplatePass[0].type = CKA_THALES_OBJECT_MUID;
break;
case keyIdImport:
findKeyTemplatePass[0].type = CKA_THALES_OBJECT_IKID;
break;
case keyIdAlias:
findKeyTemplatePass[0].type = CKA_THALES_OBJECT_ALIAS;
break;
}
Parameter Description
Parameter Description
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that
the function was invoked.
C_FindObjects
Finds an object on the DSM. The only attribute currently supported is KEY_LABEL, which corresponds to the
key name on the DSM. Returns at most 1 key.
CK_DEFINE_FUNCTION(CK_RV, C_FindObjects)(
CK_SESSION_HANDLE hSession,
CK_OBJECT_HANDLE_PTR phObject,
CK_ULONG ulMaxObjectCount,
CK_ULONG_PTR pulObjectCount
);
NOTE: The DSM honors only the public key name. To query for a public key, pass in
the public key name and CKO_PUBLIC_KEY. To query for the private key, pass in the
public key name and CKO_PRIVATE_KEY.
NOTE: Searching for a key’s handle with C_FindObject may not produce accurate
results immediately in the same session. To ensure accuracy, wait until the key cache
expires.
Parameter Description
Parameter Description
Parameter Description
CK_ULONG_PTR pulObjectCount This is always 1 the first time the API finds a match.
Subsequent calls return a uplObjectCount of 0,
indicating no other objects matched that key name.
Parameter Description
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_FindObjectsFinal
CK_DEFINE_FUNCTION(CK_RV, C_FindObjectsFinal)(
CK_SESSION_HANDLE hSession
);
Parameter Description
NOTE: If searching for a versioned key on its alias, the alias must not contain spaces
or non-alphanumeric characters.
Parameter Description
Parameter Description
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that
the function was invoked.
C_GetAttributeValue
Gets attribute value of a specific Security Object. Argument specifies the Security Object ID.
Parameter Description
CK_ATTRIBUTE_PTR pTemplate Template containing the attributes to search for. Points to the
CK_ATTRIBUTE structure.
Parameter Description
CK_ATTRIBUTE_PTR pTemplate This parameter is filled in with the values for the attributes
searched for.
There are five custom attributes:
• CKA_LABEL
• CKA_THALES_OBJECT_UUID
• CKA_THALES_OBJECT_MUID
• CKA_THALES_OBJECT_IKID
• CKA_THALES_OBJECT_ALIAS.
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
CKR_SESSION_CLOSED The session was closed during the execution of the function.
Parameter Description
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_SetAttributeValue
Sets attribute value of a specific Security Object. The argument specifies the Security Object ID.
CK_DEFINE_FUNCTION(CK_RV, C_SetAttributeValue)(
CK_SESSION_HANDLE hSession,
CK_OBJECT_HANDLE hObject,
CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG ulCount,
CK_ATTRIBUTE setAttrsTemplate[],
CK_ATTRIBUTE setAttrsTemplateSymm[]
);
Parameter Description
Parameter Description
CK_ATTRIBUTE Contains = {
setAttrsTemplate[]
{CKA_THALES_KEY_STATE, &state,
sizeof(KeyState) }
};
typedef enum {
KeyStatePreActive = 0,
KeyStateActive = 1,
KeyStateSuspended = 2,
KeyStateDeactivated = 3,
KeyStateCompromised = 4,
KeyStateDestroyed = 5
} KeyState;
Must not be used together with
setAttrsTemplateSymm[]. The NIST diagram of key
states is included below this table.
Parameter Description
CKR_ATTRIBUTE_READ_ONLY An attempt was made to set a value for an attribute which may not be
set or modified.
CKR_CRYPTOKI_NOT_INITIALIZED Indicates that the function cannot be executed because the Cryptoki
library has not yet been initialized by a call to C_Initialize.
Parameter Description
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the function
was invoked.
CKR_SESSION_READ_ONLY The specified session was unable to accomplish the desired action
because it is a read-only session.
CKR_TOKEN_WRITE_PROTECTED The requested action could not be performed because the token is
write-protected.
CKR_USER_NOT_LOGGED_IN The desired action cannot be performed because the appropriate user
(or an appropriate user) is not logged in.
C_GenerateKey
Generates a symmetric key. Maximum length of the key name is 64 characters. There is no minimum
length.
By default, keys are stored on the host or on the DSM. If you don’t want them stored on the host, log on to
the DSM Console, click the Keys tab and select the key name from the Name list. From the Edit Agent Keys
window, in the Key Type drop-down menu, select Stored on Server.
CK_DEFINE_FUNCTION(CK_RV, C_GenerateKey)(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG ulCount,
CK_OBJECT_HANDLE_PTR phKey
);
Supported Functionality
AES-128 and AES-256 symmetric encryption keys are supported.
Parameter Description
CK_MECHANISM_PTR pMechanism Key generation mechanism; must have the following values:
{CKM_AES_KEY_GEN, NULL_PTR, 0};
CKA_VORM_CACHED_ON_HOST Determines if the DSM should allow the key to leave the DSM
to be cached on the client.
CKA_VORM_CACHED_TIME How long the key stays in the local key cache before it is re-
fetched from the DSM. Time in minutes.
NOTE: When the CKA_VORM_CACHED_TIME property is set
to Zero ( 0 ), the key is cached forever on the local host for that
session.
NOTE: If automatic key rotation is set, the key will rotate 24 hours before the
specified rotation period. This behavior is expected.
NOTE: State changes are supported only by explicitly setting the new state, never by
changing the dates.
Parameter Description
Parameter Description
Parameter Description
CKR_PIN_EXPIRED The specified PIN has expired, and the requested operation
cannot be carried out.
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_GenerateKeyPair
Generates an asymmetric key pair. Arguments specify RSA type and length of the key pair.
CK_DEFINE_FUNCTION(CK_RV, C_GenerateKeyPair)(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
CK_ATTRIBUTE_PTR pPublicKeyTemplate,
CK_ULONG ulPublicKeyAttributeCount,
CK_ATTRIBUTE_PTR pPrivateKeyTemplate,
CK_ULONG ulPrivateKeyAttributeCount,
CK_OBJECT_HANDLE_PTR phPublicKey,
CK_OBJECT_HANDLE_PTR phPrivateKey
);
Supported Functionality
RSA-1024 and RSA-2048 asymmetric key pairs are supported.
Parameter Description
CK_MECHANISM_PTR pMechanism Key generation mechanism must have the following values:
{ CKM_RSA_PKCS_KEY_PAIR_GEN, NULL_PTR, 0 };
Parameter Description
Parameter Description
Parameter Description
CKR_PIN_EXPIRED The specified PIN has expired, and the requested operation
cannot be carried out.
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
CK_DEFINE_FUNCTION(CK_RV, C_DigestInit)(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
);
Parameter Description
Parameter Description
Parameter Description
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_Digest
Compute data digest in a single part. Must call C_DigestInit before calling C_Digest.
CK_DEFINE_FUNCTION(CK_RV, C_DigestInit)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pPart,
CK_ULONG ulPartLen,
CK_BYTE_PTR pDigest,
CK_ULONG_PTR pulDigestLen
);
Parameter Description
Parameter Description
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_DigestKey
Specifies HMAC key for digest operation. Must call C_DigestInit before calling C_DigestKey.
CK_DEFINE_FUNCTION(CK_RV, C_DigestKey)(
CK_SESSION_HANDLE hSession,
CK_OBJECT_HANDLE hKey
);
NOTE: This function does not work when key is set to Store on Server. The key
must be set to Cached on Host.
NOTE: You can call C_DigestKey only once and directly after C_DigestInit.
Parameter Description
Parameter Description
Parameter Description
CKR_KEY_FUNCTION_NOT_PERMITTED
-CKR_KEY_INDIGESTIBLE The supplied key‘s size is outside the range of key sizes.
CKR_KEY_SIZE_RANGE
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that
the function was invoked.
C_DigestUpdate
Continues a multi-part digest operation. Must call C_DigestInit before calling C_DigestUpdate. Can
optionally call C_DigestKey before calling C_DigestUpdate.
CK_DEFINE_FUNCTION(CK_RV, C_DigestUpdate)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pPart,
CK_ULONG ulPartLen
);
Parameter Description
Parameter Description
Parameter Description
CKR_KEY_SIZE_RANGE The supplied key‘s size is outside the range of key sizes.
CKR_KEY_TYPE_INCONSISTENT The specified key is not the correct type of key to use with
the specified mechanism.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_DigestFinal
Finishes a multi-part digest operation. This works only with the local key cache. Not supported if crypto is
done remotely on the DSM.
CK_DEFINE_FUNCTION(CK_RV, C_DigestFinal)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pDigest,
CK_ULONG_PTR pulDigestLen
);
Parameter Description
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
CKR_KEY_SIZE_RANGE The supplied key‘s size is outside the range of key sizes.
CKR_KEY_TYPE_INCONSISTENT The specified key is not the correct type of key to use with
the specified mechanism.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
CK_DEFINE_FUNCTION(CK_RV, C_SignInit)(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey
);
Parameter Description
CK_OBJECT_HANDLE hKey Handle to the RSA private key. The key that this handle
references can be symmetric, asymmetric, or an opaque
object.
Parameter Description
Parameter Description
CKR_KEY_SIZE_RANGE The supplied key‘s size is outside the range of key sizes.
CKR_KEY_TYPE_INCONSISTENT The specified key is not the correct type of key to use with
the specified mechanism.
CKR_PIN_EXPIRED The specified PIN has expired, and the requested operation
cannot be carried out.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_Sign
CK_DEFINE_FUNCTION(CK_RV, C_Sign)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pData,
CK_ULONG ulDataLen,
CK_BYTE_PTR pSignature,
CK_ULONG_PTR pulSignatureLen
);
Parameter Description
Parameter Description
CK_BYTE The CK_BYTE structure where pSignature points is filled in with the
signed data.
Parameter Description
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
C_VerifyInit
CK_DEFINE_FUNCTION(CK_RV, C_VerifyInit)
(CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey);
Parameter Description
hKey Handle for the public key of the key pair used for verification.
Parameter Description
Parameter Description
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that
the function was invoked.
C_Verify
Performs a single-part verification operation. To perform verification, the signature is verified with the
key, the handle of which is provided in C_Verify_Init and compared with the pData.
CK_DEFINE_FUNCTION(CK_RV, C_Verify)
(CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pData,
CK_ULONG ulDataLen,
CK_BYTE_PTR pSignature,
CK_ULONG ulSignatureLen);
Parameter Description
Parameter Description
Encryption Functions
.....................................................................
C_EncryptInit
CK_DEFINE_FUNCTION(CK_RV, C_EncryptInit)(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey
);
Parameter Description
CK_MECHANISM_PTR pMechanism The pointer to the structure that specifies the encryption
mechanism.
We support the following mechanisms:
CKM_AES_ECB
CKM_AES_CBC
CKM_AES_CBC_PAD
CKM_AES_CTR
CKM_THALES_FPE (in Java, use: 0x80004001L)
CKM_THALES_FF1 (in Java, use: 0x80004002L)
CKM_RSA_PKCS
CKM_AES_GCM
Note: For CKM_THALES_FPE, the IV contains the following field
values:
• tweak (8 bytes)
• character set. ASCII or Unicode characters. The following
Unicode encodings are supported: UTF-8, UTF-16, UTF-32,
big-endian, or little-endian byte order. Be sure there are no
duplicate characters in the character set.
• radix (character set size ). The size can be from 2 to 65535.
For more information, see samples.
For CKM_THALES_FF1, the IV contains the same 3 field values,
except that the tweak is not fixed size: it can range from 0 to 232
bytes.
Note: FPE, CTR, and FF1 do not work when key is set to Store
on Server. The key must be set to Cached on Host.
NOTE: Not every header version supports every encryption mechanism. Refer to the
table titled “Header Compatibility with Encryption Methods” earlier in this manual.
Parameter Description
Parameter Description
CKR_KEY_SIZE_RANGE The supplied key‘s size is outside the range of key sizes.
CKR_KEY_TYPE_INCONSISTENT The specified key is not the correct type of key to use with
the specified mechanism.
CKR_PIN_EXPIRED The specified PIN has expired, and the requested operation
cannot be carried out.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that
the function was invoked.
C_Encrypt
Encrypts single part data. Must call C_EncryptInit before calling C_Encrypt.
CK_DEFINE_FUNCTION(CK_RV, C_Encrypt)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pData,
CK_ULONG ulDataLen,
CK_BYTE_PTR pEncryptedData,
CK_ULONG_PTR pulEncryptedDataLen
);
Parameter Description
Parameter Description
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_EncryptUpdate
Continues a multi-part encryption. This works only with the local key cache. Not supported if crypto is done
remotely on the DSM.
CK_DEFINE_FUNCTION(CK_RV, C_EncryptUpdate)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pPart,
CK_ULONG ulPartLen,
CK_BYTE_PTR pEncryptedPart,
CK_ULONG_PTR pulEncryptedPartLen
);
Parameter Description
Parameter Description
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
C_EncryptFinal
Finishes a multi-part encryption. This works only with the local key cache. Not supported if encryption is
done remotely on the DSM.
CK_DEFINE_FUNCTION(CK_RV, C_EncryptFinal)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pLastEncryptedPart,
CK_ULONG_PTR pulEncryptedPartLen
);
Parameter Description
Parameter Description
Parameter Description
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
Decryption Functions
.....................................................................
C_DecryptInit
CK_DEFINE_FUNCTION(CK_RV, C_DecryptInit)(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey
);
Parameter Description
Parameter Description
CK_MECHANISM_PTR pMechanism Pointer to the mechanism for decryption. Must match the
mechanism used to encrypt, including the correct IV if using
CKM_AES_CBC or CKM_AES_CBC_PAD or the correct nonce
and counter concatenated if using CKM_AES_CTR.
We support the following mechanisms:
CKM_AES_ECB
CKM_AES_CBC
CKM_AES_CBC_PAD
CKM_AES_CTR
CKM_THALES_FPE (in Java, use: 0x80004001L)
CKM_THALES_FF1 (in Java, use: 0x80004002L)
CKM_RSA_PKCS
CKM_AES_GCM
Note: For CKM_THALES_FPE, the IV contains the following
field values:
• tweak (8 bytes)
• character set (ASCII characters 0-127)
• radix (character set size ). For more information see
samples.
For CKM_THALES_FF1, the IV contains the same field values,
except that the tweak is not a fixed size: it can range from 0 to
232 bytes.
CK_OBJECT_HANDLE hKey Handle of the decryption key; (same as encryption key for
symmetric encryption).
CK_GCM_PARAMS For GCM, this parameter must include the length of the tag in
ulEncryptedPartLen bytes, in addition to the ciphertext length.
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
CKR_KEY_SIZE_RANGE The supplied key‘s size is outside the range of key sizes.
CKR_KEY_TYPE_INCONSISTENT The specified key is not the correct type of key to use with
the specified mechanism.
CKR_PIN_EXPIRED The specified PIN has expired, and the requested operation
cannot be carried out.
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_Decrypt
Decrypts encrypted data in a single part. The operation must have been initialized by a prior call to
C_DecryptInit.
CK_DEFINE_FUNCTION(CK_RV, C_Decrypt)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pEncryptedData,
CK_ULONG ulEncryptedDataLen,
CK_BYTE_PTR pData,
CK_ULONG_PTR pulDataLen
);
Parameter Description
CK_ULONG_PTR pulDataLen Pointer to the length of the buffer for the decrypted text.
First call: Pointer to decrypted buffer length. Decrypted buffer
length is zero for metadata logging.
Second call: actual buffer length used for decrypted data;
length of the written plaintext.
CK_GCM_PARAMS The first bytes of length are specified in the ulTagBits field
and pEncryptedData must contain the tag. Also for GCM, if
the decryption can't be validated, the error
CKR_ENCRYPTED_DATA_INVALID is returned.
Parameter Description
pData When input parameter pData is NULL, this function returns a calculated
output buffer length value pointed to by pulDataLen. For C program
only.
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_DecryptUpdate
Decrypts multi-part encrypted data. The operation must have been initialized by a prior call to
C_DecryptInit. This works only with the local key cache. Not supported if crypto is done remotely on the
DSM.
CK_DEFINE_FUNCTION(CK_RV, C_DecryptUpdate)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pEncryptedPart,
CK_ULONG ulEncryptedPartLen,
CK_BYTE_PTR pPart,
CK_ULONG_PTR pulPartLen
);
Parameter Description
CK_BYTE_PTR pEncryptedData Pointer to the encrypted data. For GCM, on the first call to
C_DecryptUpdate, this parameter includes the first bytes of
length specified in the ulTagBits field in bytes and
pEncryptedPart must contain the tag.
CK_ULONG ulEncryptedDataLen Length of the encrypted data. For GCM, his parameter must
include the length of the tag in bytes, in addition to the
ciphertext length.
Parameter Description
Parameter Description
pData When input parameter pData is NULL, this function returns a calculated output
buffer length value pointed to by pulDataLen. For C program only.
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
Parameter Description
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
C_DecryptFinal
Finishes a multi-part decryption. This works only with the local key cache. Not supported if crypto is done
remotely on the DSM.
CK_DEFINE_FUNCTION(CK_RV, C_DecryptFinal)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pLastPart,
CK_ULONG_PTR pulLastPartLen
);
Parameter Description
Parameter Description
Parameter Description
Parameter Description
CKR_BUFFER_TOO_SMALL The output of the function is too large to fit in the supplied
buffer.
CKR_SESSION_CLOSED The session was closed during the execution of the function.
CKR_SESSION_HANDLE_INVALID The specified session handle was invalid at the time that the
function was invoked.
Return Values
Parameter Description
Parameter Description
C_SeedRandom
Generate token random numbers by mixing additional seed material into the token random number
generator.
Parameter Description