Managing the life cycle of cryptographic keys in HSM.
See the HSM technical documentation.
Functions | |
byte[] | getUserKey (String strKeyName, int nFlags) throws TacException |
Retrieves the context of a key, as long as the current User has access, stored within the HSM. | |
byte[] | getUserKey (String strKeyName) throws TacException |
Retrieves the context of a key, as long as the current User has access, stored within the HSM. | |
byte[] | getUserKeyOffline (String strKeyName, int algId, boolean isTemporary, boolean isExportable) throws TacException |
Retrieves the context of a key, without verifying the information passed, as long as the current User has access, stored within the HSM. | |
void | deleteKey (String keyId) throws TacException |
Turn off the key. | |
void | deleteKeyIfExists (String keyId) throws TacException |
Delete the key if it exists. | |
byte[] | createKeyMaterial (int keyAlg) throws TacException |
It creates a new cryptographic key and returns its content without persisting it in the HSM. | |
void | createKey (String keyId, int keyAlg, boolean exportable) throws TacException |
It creates and stores a cryptographic key associated with an algorithm according to the parameters entered within the HSM. | |
void | createKey (String keyId, int keyAlg) throws TacException |
It creates and stores a cryptographic key associated with an algorithm according to the parameters entered within the HSM. | |
void | createKey (String keyId, int keyAlg, int dwFlags) throws TacException |
It creates and stores a cryptographic key associated with an algorithm according to the parameters entered within the HSM. | |
byte[] | exportKey (String szKey, int dwBlobType) throws TacException |
Exports an HSM key to the local machine. | |
byte[] | exportKey (String szKey, byte[] hKEKey, int dwBlobType) throws TacException |
Exports an HSM key to the local machine. | |
byte[] | exportKey (byte[] hKey, byte[] hKEKey, int dwBlobType) throws TacException |
Exports an HSM key to the local machine. | |
void | importKey (String szKey, int dwBlobType, int nAlgId, byte[] pbInData, boolean isExportable) throws TacException |
Import a key from the local machine to the HSM. | |
void | importKey (String szKey, int dwBlobType, int nAlgId, int dwFlags, byte[] pbInData, int dwInDataLen) throws TacException |
Import a key from the local machine to the HSM. | |
void | importKey (String szKey, byte[] hKEKey, int dwBlobType, int nAlgId, int dwFlags, byte[] pbInData, byte[] hKey) throws TacException |
Import a key from the local machine to the HSM. | |
byte[] | importKey (String szKey, int dwBlobType, int nAlgId, int dwFlags, byte[] pbInData) throws TacException |
Import a key from the local machine to the HSM. | |
void | importKey (String szKey, byte[] hKEKey, int dwBlobType, int nAlgId, int dwFlags, byte[] pbInData, int dwInDataLen, byte[] hKey) throws TacException |
Import a key from the local machine to the HSM. | |
void | PKCS12Import (String szPathFile, String szPassword, String szKey, String szCert, boolean isExportable) throws TacException |
Imports a key/certificate from a file in PKCS#12 format into the HSM. | |
void | importPKCS12 (String szPathFile, String szPassword, String szKey, String szCert, boolean isExportable) throws TacException |
Imports a key/certificate from a file in PKCS#12 format into the HSM. | |
void | importPKCS12 (byte[] pbPkcs12, String szPassword, String szKey, String szCert, boolean isExportable) throws TacException |
Imports a key/certificate from a buffer in PKCS#12 format into the HSM. | |
void | importPKCS12 (byte[] pbPkcs12, String szPassword, String szKey, int nKeyAttr, String szCert, String szPubKey, int nReserved) throws TacException |
Imports a key/certificate from a buffer in PKCS#12 format into the HSM. | |
byte[] | exportPKCS12 (String password, String key, String cert, String strReserved, int dwFlags) throws TacException |
Exports an HSM key and certificate in PKCS#12 format. | |
byte[] | exportPKCS12 (String password, String key, String cert) throws TacException |
Exports an HSM key and certificate in PKCS#12 format. | |
byte[] | PKCS8ExportKey (String szKeyId, String szSecret) throws TacException |
Exports an asymmetric key in a file in PKCS#8 format to the HSM. | |
void | PKCS8ImportKey (String szKeyId, String szSecret, int dwKeyAlg, byte[] bKeyEnvelope, boolean isExportable) throws TacException |
Imports an asymmetric key from a file in PKCS#8 format into the HSM. | |
int | getAlgId (byte[] ctxKey) throws TacException |
Retrieves the key's algorithm. | |
int | getAlgId (String keyId) throws TacException |
Retrieves the key's algorithm. | |
byte[] | readObject (String szObject) throws TacException |
Exports an HSM object to the local machine. | |
void | writeObject (String szObject, byte[] jbObjectData) throws TacException |
Import an object from the local machine to the HSM. | |
byte[] | getKeyHandle (String keyId) throws TacException |
Retrieves a key handle. | |
void | releaseKeyHandle (byte[] keyHandle) throws TacException |
Releases a key handle. | |
boolean | isKeyExportable (byte[] keyHandle) throws TacException |
Check that the key is exportable. | |
boolean | isKeyExportable (String keyId) throws TacException |
Check that the key is exportable. | |
void | setObjLabel (String objId, String label) throws TacException |
Defines the label attribute of the object's metadata. | |
void | createMap (String mapId, String objId1, int objId1Alg, String objId2, int objId2Alg) throws TacException |
Creates a mapping object (MAP) within the HSM. | |
String[] | listObjects () throws TacException |
Lists the HSM objects. | |
byte[] getUserKey | ( | String | strKeyName, |
int | nFlags ) throws TacException |
Retrieves the context of a key, as long as the current User has access, stored within the HSM.
This function does not create a new key.
strKeyName | Key identifier in the HSM. |
nFlags |
TacException | Exception for errors in retrieving the key context. |
byte[] getUserKey | ( | String | strKeyName | ) | throws TacException |
Retrieves the context of a key, as long as the current User has access, stored within the HSM.
This function does not create a new key.
strKeyName | Key identifier in the HSM. |
TacException | Exception for errors in retrieving the key context. |
byte[] getUserKeyOffline | ( | String | strKeyName, |
int | algId, | ||
boolean | isTemporary, | ||
boolean | isExportable ) throws TacException |
Retrieves the context of a key, without verifying the information passed, as long as the current User has access, stored within the HSM.
This function does not create a new key.
strKeyName | Key identifier in the HSM. |
algId | Key algorithm. |
isTemporary | Tells you if the key is temporary. |
isExportable | Informs whether the key is exportable. |
TacException | Exception for errors in retrieving the key context. |
void deleteKey | ( | String | keyId | ) | throws TacException |
Turn off the key.
keyId | Key identifier |
TacException |
void deleteKeyIfExists | ( | String | keyId | ) | throws TacException |
Delete the key if it exists.
It does not return an error if it does not exist.
keyId | Key identifier |
TacException |
byte[] createKeyMaterial | ( | int | keyAlg | ) | throws TacException |
It creates a new cryptographic key and returns its content without persisting it in the HSM.
keyAlg | Algorithm to be used: Symmetric Keys
|
Exception |
void createKey | ( | String | keyId, |
int | keyAlg, | ||
boolean | exportable ) throws TacException |
It creates and stores a cryptographic key associated with an algorithm according to the parameters entered within the HSM.
The key generated will be exportable.
keyId | Key identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keyAlg | Algorithm to be used: Symmetric Keys
RSA Asymmetric Keys
ECC Asymmetric Keys
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exportable | The key can be exported from the HSM if set to true. |
Exception |
void createKey | ( | String | keyId, |
int | keyAlg ) throws TacException |
It creates and stores a cryptographic key associated with an algorithm according to the parameters entered within the HSM.
The key generated will be exportable.
keyId | Key identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keyAlg | Algorithm to be used: Symmetric Keys
RSA Asymmetric Keys
ECC Asymmetric Keys
|
Exception |
void createKey | ( | String | keyId, |
int | keyAlg, | ||
int | dwFlags ) throws TacException |
It creates and stores a cryptographic key associated with an algorithm according to the parameters entered within the HSM.
keyId | Key identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
keyAlg | Algorithm to be used: Symmetric Keys
RSA Asymmetric Keys
ECC Asymmetric Keys
ECX Asymmetric Keys
HMAC Keys
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dwFlags | Additional key parameters.
In addition to the values in the previous table, you can add a key usage profile definition. You can define the key usage profile (Attribute Usage-profile), using only one of the values below. If none of the values below are specified, the key profile is set to free for any use. It is mandatory to define the usage profile when the HSM is in RM3 mode.
|
Exception |
byte[] exportKey | ( | String | szKey, |
int | dwBlobType ) throws TacException |
Exports an HSM key to the local machine.
szKey | Name of the key to be exported. |
dwBlobType | Output buffer format. See importKey for a list of supported types. |
TacException |
byte[] exportKey | ( | String | szKey, |
byte[] | hKEKey, | ||
int | dwBlobType ) throws TacException |
Exports an HSM key to the local machine.
szKey | Name of the key to be exported. |
hKEKey | Context of the key with which the key block will be encrypted - KEK (key encryption key). |
dwBlobType | Output buffer format. See importKey for a list of supported types. |
TacException |
byte[] exportKey | ( | byte[] | hKey, |
byte[] | hKEKey, | ||
int | dwBlobType ) throws TacException |
Exports an HSM key to the local machine.
hKey | Context of the key to be exported. |
hKEKey | Context of the key with which the key block will be encrypted - KEK (key encryption key). |
dwBlobType | Output buffer format. See importKey for a list of supported types. |
TacException |
void importKey | ( | String | szKey, |
int | dwBlobType, | ||
int | nAlgId, | ||
byte[] | pbInData, | ||
boolean | isExportable ) throws TacException |
Import a key from the local machine to the HSM.
szKey | Name that the imported key will have inside the HSM. | ||||||||||||||||||||||||||||||
dwBlobType | Output buffer format.
Table of TacNDJavaLib.PUBLICKEY_BLOB_HSM.
| ||||||||||||||||||||||||||||||
nAlgId | Algorithm of the imported key. See createKey. | ||||||||||||||||||||||||||||||
isExportable | Signals that the imported key will be exportable. | ||||||||||||||||||||||||||||||
pbInData | Buffer containing the key to be imported, as specified in dwBlobType. |
TacException |
void importKey | ( | String | szKey, |
int | dwBlobType, | ||
int | nAlgId, | ||
int | dwFlags, | ||
byte[] | pbInData, | ||
int | dwInDataLen ) throws TacException |
Import a key from the local machine to the HSM.
szKey | Name that the imported key will have inside the HSM. | ||||||||||||||||||||||||||||
dwBlobType | Output buffer format.
Table of TacNDJavaLib.PUBLICKEY_BLOB_HSM.
| ||||||||||||||||||||||||||||
nAlgId | Algorithm of the imported key. See createKey. | ||||||||||||||||||||||||||||
dwFlags | Additional key parameters. See createKey. | ||||||||||||||||||||||||||||
pbInData | Buffer containing the key to be imported, as specified in dwBlobType. | ||||||||||||||||||||||||||||
dwInDataLen | Size of the pbInData buffer to be imported. |
TacException |
void importKey | ( | String | szKey, |
byte[] | hKEKey, | ||
int | dwBlobType, | ||
int | nAlgId, | ||
int | dwFlags, | ||
byte[] | pbInData, | ||
byte[] | hKey ) throws TacException |
Import a key from the local machine to the HSM.
szKey | Name that the imported key will have inside the HSM. | ||||||||||||||||||||||||||||||||
hKEKey | Context of the key with which the blob of the key to be imported is encrypted - KEK (key encryption key) | ||||||||||||||||||||||||||||||||
dwBlobType | Output buffer format.
Table of TacNDJavaLib.PUBLICKEY_BLOB_HSM.
| ||||||||||||||||||||||||||||||||
nAlgId | Algorithm of the imported key. See createKey. | ||||||||||||||||||||||||||||||||
dwFlags | Additional key parameters. See createKey. | ||||||||||||||||||||||||||||||||
pbInData | Buffer containing the key to be imported, as specified in dwBlobType. | ||||||||||||||||||||||||||||||||
hKey | Context of the imported key. |
TacException |
byte[] importKey | ( | String | szKey, |
int | dwBlobType, | ||
int | nAlgId, | ||
int | dwFlags, | ||
byte[] | pbInData ) throws TacException |
Import a key from the local machine to the HSM.
szKey | Name that the imported key will have inside the HSM. | ||||||||||||||||||||||||||||||||
dwBlobType | Output buffer format.
Table of TacNDJavaLib.PUBLICKEY_BLOB_HSM.
| ||||||||||||||||||||||||||||||||
nAlgId | Algorithm of the imported key. See createKey. | ||||||||||||||||||||||||||||||||
dwFlags | Additional key parameters. See createKey. | ||||||||||||||||||||||||||||||||
pbInData | Buffer containing the key to be imported, as specified in dwBlobType. |
TacException |
void importKey | ( | String | szKey, |
byte[] | hKEKey, | ||
int | dwBlobType, | ||
int | nAlgId, | ||
int | dwFlags, | ||
byte[] | pbInData, | ||
int | dwInDataLen, | ||
byte[] | hKey ) throws TacException |
Import a key from the local machine to the HSM.
szKey | Name that the imported key will have inside the HSM. | ||||||||||||||||||||||||||||||||
hKEKey | Context of the key with which the blob of the key to be imported is encrypted - KEK (key encryption key) | ||||||||||||||||||||||||||||||||
dwBlobType | Output buffer format.
Table of TacNDJavaLib.PUBLICKEY_BLOB_HSM.
| ||||||||||||||||||||||||||||||||
nAlgId | Algorithm of the imported key. See createKey. | ||||||||||||||||||||||||||||||||
dwFlags | Additional key parameters. See createKey. | ||||||||||||||||||||||||||||||||
pbInData | Buffer containing the key to be imported, as specified in dwBlobType. | ||||||||||||||||||||||||||||||||
dwInDataLen | Size of the pbInData buffer to be imported. | ||||||||||||||||||||||||||||||||
hKey | Context of the imported key. |
TacException |
void PKCS12Import | ( | String | szPathFile, |
String | szPassword, | ||
String | szKey, | ||
String | szCert, | ||
boolean | isExportable ) throws TacException |
Imports a key/certificate from a file in PKCS#12 format into the HSM.
szKey | Name that the imported key will have inside the HSM. |
szPathFile | Location of the physical PFX file to be imported. |
szPassword | Password to open PFX file. |
szCert | Name that the imported certificate will have within the HSM. |
isExportable | Import the key in exportable form. |
TacException |
void importPKCS12 | ( | String | szPathFile, |
String | szPassword, | ||
String | szKey, | ||
String | szCert, | ||
boolean | isExportable ) throws TacException |
Imports a key/certificate from a file in PKCS#12 format into the HSM.
szPathFile | Location of the physical PFX file to be imported. |
szPassword | Password to open PFX file. |
szKey | Name that the imported key will have inside the HSM. |
szCert | Name that the imported certificate will have within the HSM. |
isExportable | Import the key in exportable form. |
TacException |
void importPKCS12 | ( | byte[] | pbPkcs12, |
String | szPassword, | ||
String | szKey, | ||
String | szCert, | ||
boolean | isExportable ) throws TacException |
Imports a key/certificate from a buffer in PKCS#12 format into the HSM.
pbPkcs12 | PKCS#12. |
szPassword | Password for PKCS#12. |
szKey | Name that the imported key will have inside the HSM. |
szCert | Name that the imported certificate will have within the HSM. |
isExportable | Import the private key in exportable form. |
TacException |
void importPKCS12 | ( | byte[] | pbPkcs12, |
String | szPassword, | ||
String | szKey, | ||
int | nKeyAttr, | ||
String | szCert, | ||
String | szPubKey, | ||
int | nReserved ) throws TacException |
Imports a key/certificate from a buffer in PKCS#12 format into the HSM.
pbPkcs12 | PKCS#12. |
szPassword | Password for PKCS#12. |
szKey | Name that the imported key will have inside the HSM. |
nKeyAttr | Attributes of the key that will be imported into the HSM. See possible options in the dwFlags parameter at Dinamo.createKey(). |
szCert | Name that the imported certificate will have within the HSM. |
szPubKey | Name that the imported public key will have inside the HSM. Can be null to not import the public key object. |
nReserved | Reserved for future use. Must be 0. |
TacException |
byte[] exportPKCS12 | ( | String | password, |
String | key, | ||
String | cert, | ||
String | strReserved, | ||
int | dwFlags ) throws TacException |
Exports an HSM key and certificate in PKCS#12 format.
password | Password for PFX protection. | ||||
key | Name of the key to be exported to PFX. | ||||
cert | Name of the certificate to be exported to PFX. | ||||
strReserved | Reserved for future use. | ||||
dwFlags | Pass 0 or one of the options in the table below.
|
TacException |
byte[] exportPKCS12 | ( | String | password, |
String | key, | ||
String | cert ) throws TacException |
Exports an HSM key and certificate in PKCS#12 format.
password | Password for PFX protection. |
key | Name of the key to be exported to PFX. |
cert | Name of the certificate to be exported to PFX. |
TacException |
byte[] PKCS8ExportKey | ( | String | szKeyId, |
String | szSecret ) throws TacException |
Exports an asymmetric key in a file in PKCS#8 format to the HSM.
szKeyId | Key identification. |
szSecret | Password for the PKCS#8 file (must be longer than 16 characters). |
TacException |
void PKCS8ImportKey | ( | String | szKeyId, |
String | szSecret, | ||
int | dwKeyAlg, | ||
byte[] | bKeyEnvelope, | ||
boolean | isExportable ) throws TacException |
Imports an asymmetric key from a file in PKCS#8 format into the HSM.
szKeyId | Key identification. | ||||||||||||||||
szSecret | Password for the PKCS#8 file (must be longer than 16 characters). | ||||||||||||||||
dwKeyAlg | Key algorithm identifier. RSA Asymmetric Keys
| ||||||||||||||||
bKeyEnvelope | Binary file format PKCS#8 | ||||||||||||||||
isExportable | Import the key in exportable form. |
TacException |
int getAlgId | ( | byte[] | ctxKey | ) | throws TacException |
Retrieves the key's algorithm.
ctxKey | Handle of the key, retrieved by getKeyHandle(). |
TacException |
int getAlgId | ( | String | keyId | ) | throws TacException |
Retrieves the key's algorithm.
keyId | Key identifier |
TacException |
byte[] readObject | ( | String | szObject | ) | throws TacException |
Exports an HSM object to the local machine.
szObject | Name of the object to be exported. |
TacException |
void writeObject | ( | String | szObject, |
byte[] | jbObjectData ) throws TacException |
Import an object from the local machine to the HSM.
szObject | Name of the object to be imported. |
jbObjectData | Data of the object to be imported. |
TacException |
byte[] getKeyHandle | ( | String | keyId | ) | throws TacException |
Retrieves a key handle.
It must be released with the releaseKey() method.
keyId | Key identifier in text format |
TacException |
void releaseKeyHandle | ( | byte[] | keyHandle | ) | throws TacException |
Releases a key handle.
keyHandle | Handle of the key retrieved by getKeyHandle(). |
TacException |
boolean isKeyExportable | ( | byte[] | keyHandle | ) | throws TacException |
Check that the key is exportable.
keyHandle | Handle of the key retrieved by getKeyHandle(). |
TacException |
boolean isKeyExportable | ( | String | keyId | ) | throws TacException |
Check that the key is exportable.
keyId | Key identifier. |
TacException |
void setObjLabel | ( | String | objId, |
String | label ) throws TacException |
Defines the label attribute of the object's metadata.
objId | Object identifier |
label | Label |
TacException |
void createMap | ( | String | mapId, |
String | objId1, | ||
int | objId1Alg, | ||
String | objId2, | ||
int | objId2Alg ) throws TacException |
Creates a mapping object (MAP) within the HSM.
mapId | Identifier of the PRT object. |
objId1 | Identifier of the object pointed to by the first slot in the PRT. |
objId1Alg | Algorithm of the object indicated by objId1Alg. It can be any type of object (see createKey) or TacNDJavaLib.ALG_OBJ_NULL. |
objId2 | Identifier of the object pointed to by the second slot in the PRT. |
objId2Alg | Algorithm of the object indicated by objId2Alg. It can be any type of object (see createKey) or TacNDJavaLib.ALG_OBJ_NULL. |
Exception |
String[] listObjects | ( | ) | throws TacException |
Lists the HSM objects.
TacException |