NET API
HSM Dinamo
Loading...
Looking for...
No entries found
Keys

Detailed description

Managing the life cycle of cryptographic keys in HSM.

See the HSM technical documentation.

Functions

IntPtr GenerateKey (string KeyId, DinamoClient.KEY_ALG Alg, bool Exportable)
 Generates a permanent key in the HSM.
 
IntPtr GenerateKey (string KeyId, DinamoClient.KEY_ALG Alg, bool Exportable, bool Temporary)
 Generates key.
 
IntPtr GetUserKey (string KeyId)
 Returns the Handler of a key (DestroyUserKey must be called after allocation).
 
void DestroyKey (IntPtr hKey)
 Release key handle.
 
int GetKeyAlgId (string strKeyId)
 Returns the algorithm of a key.
 
int GetKeyAlgId (IntPtr hKey)
 Returns the type of a key.
 
int GetKeyPadding (IntPtr hKey)
 Returns the padding type of a key.
 
int GetUserKeyLen (string KeyId)
 Returns the size of a key.
 
int GetUserKeyLen (IntPtr hKey)
 Returns the size of a key.
 
bool IsKeyExist (string KeyId)
 
bool HasObject (string Id)
 Verifies the existence of an object.
 
void GetMapInfo (string ObjectId, ref string Obj1Id, ref string Obj2Id)
 Retrieves map information (backward compatibility)
 
void GetMapInfo (string ObjectId, ref string Obj1Id, ref int Obj1TypeId, ref string Obj2Id, ref int Obj2TypeId)
 Retrieves map information.
 
List< CertAssociationListCertAssociations (bool onlyWithAssociation=false)
 Lists the certificates and their associated private keys.
 
bool IsKeyReadLock (string KeyId)
 Test if the key is exportable.
 
bool IsKeyReadLock (IntPtr hKey)
 Test if the key is exportable.
 
bool IsKeyEncrypted (string KeyId)
 Test that the key is encrypted.
 
bool IsKeyEncrypted (IntPtr hKey)
 Test that the key is encrypted.
 
void BlockObject (string szObjectName, bool bBlock)
 Changes the lock status of an object.
 
bool IsObjectBlocked (string szObjectName)
 Recovers the locked state of an object.
 
void GenerateMap (string MapId, string Obj1Id, ALG Obj1Type, string Obj2Id, ALG Obj2Type)
 
void RemoveObject (string ObjectId)
 Removes an object from the HSM.
 
void RemoveObjectIfExists (string ObjectId)
 Removes an object from the HSM, if it exists.
 
string[] ListObjects ()
 Lists the objects of the current HSM user.
 
Int32 ListCallback (string szName, ref DinamoApi.DBLOB pParam, Int32 bFinal)
 
string[] ListObjects(ALG type)
 
byte[] ReadFile (string FileId)
 
Int32 WriteLocalFileCallback (IntPtr pbData, Int32 cbData, ref DinamoApi.DBLOB_FILE pParam, Int32 bFinal)
 
void WriteFile (string FileId, byte[] byFileData)
 Imports objects into the HSM. Certificates, PKCS#7, Keys.
 
Int32 ReadLocalFileCallback (IntPtr pbData, ref Int32 pcbData, IntPtr pParam, out Int32 pbFinal)
 
byte[] ExportKey (IntPtr hKey, IntPtr hKeyEncryptionKey, BLOB_TYPE BlobType)
 
IntPtr ImportKey (string KeyId, IntPtr hKeyEncryptionKey, byte[] byKeyBlob, BLOB_TYPE BlobType, KEY_ALG AlgId)
 
IntPtr ImportKey (string KeyId, IntPtr hKeyEncryptionKey, byte[] byKeyBlob, BLOB_TYPE BlobType, KEY_ALG AlgId, bool Exportable, bool Temporary)
 
void ImportPKCS12File (string FilePath, string Password, string KeyId, string CertId, bool Exportable)
 Imports a key/certificate from a file in PKCS#12 format into the HSM.
 
Int32 ImportPKCS12 (string FilePath, string Password, string KeyId, string CertId, bool Exportable)
 
void ImportPKCS12 (byte[] Pkcs12, string Password, string KeyId, string CertId, bool Exportable)
 Imports a key/certificate from a buffer in PKCS#12 format into the HSM.
 
void ImportPKCS12 (byte[] Pkcs12, string Password, string KeyId, Int32 KeyAttr, string CertId, string PubKeyId, Int32 Reserved)
 Imports a key/certificate from a buffer in PKCS#12 format into the HSM.
 
byte[] PKCS8ExportKey (string szKeyId, string szSecret)
 
byte[] SPBExportPKCS12 (string szISPB, string szSecret)
 
byte[] ExportPKCS12 (string KeyId, string CertId, string Secret)
 Exports an HSM key and certificate in PKCS#12 format.
 
byte[] ExportPKCS12 (string KeyId, string CertId, string Secret, Int32 Flags)
 Exports an HSM key and certificate in PKCS#12 format.
 
void PKCS8ImportKey (string szKeyId, string szSecret, int dwKeyAlg, int dwAttrib, byte[] bKeyEnvelope)
 
void SPBImportPKCS12 (string szKeyId, string szSecret, string szDomain, int dwKeyAlg, int dwAttrib, string file)
 

Functions

GenerateKey() [1/2]

IntPtr GenerateKey ( string KeyId,
DinamoClient.KEY_ALG Alg,
bool Exportable )
inline

Generates a permanent key in the HSM.

Parameters
KeyIdKey identifier. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. An object identifier in HSM can have a maximum length, in characters, of DinamoApi.MAX_OBJ_NAME_LEN. When creating keys in another user's partition (permission required) the name must be fully qualified with an FQN(Full Qualified Name: partition_id/obj_id), the maximum length for an FQN is DinamoApi.MAX_OBJ_ID_FQN_LEN-1.
AlgAlgorithm to be used. Dinamo.Hsm.DinamoClient.KEY_ALG
ExportableFlag indicating the generation of an exportable key.
Return
Handle to the generated key object.
Exceptions
DinamoExceptionThrows exception in case of error.
Examples
block_object.cs, dukpt.cs, generate_hmac.cs, oath.cs and rsa_enc_dec.cs.

GenerateKey() [2/2]

IntPtr GenerateKey ( string KeyId,
DinamoClient.KEY_ALG Alg,
bool Exportable,
bool Temporary )
inline

Generates key.

Parameters
KeyIdKey identifier. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. An object identifier in HSM can have a maximum length, in characters, of DinamoApi.MAX_OBJ_NAME_LEN. When creating keys in another user's partition (permission required) the name must be fully qualified with an FQN(Full Qualified Name: partition_id/obj_id), the maximum length for an FQN is DinamoApi.MAX_OBJ_ID_FQN_LEN-1.
AlgKey algorithm. Dinamo.Hsm.DinamoClient.KEY_ALG
ExportableFlag to generate the exportable key.
TemporaryFlag to generate a temporary key. This key has a life cycle for the duration of the session.
Return
Key handle.
Exceptions
DinamoExceptionThrows exception in case of error.

GetUserKey()

IntPtr GetUserKey ( string KeyId)
inline

Returns the Handler of a key (DestroyUserKey must be called after allocation).

Parameters
KeyIdKey identifier
Return
User object handle
Exceptions
DinamoExceptionThrows exception in case of error.

DestroyKey()

void DestroyKey ( IntPtr hKey)
inline

Release key handle.

Parameters
hKeyKey handle.
Exceptions
DinamoExceptionThrows exception in case of error.
Examples
block_object.cs, eft_gen_pin.cs, eft_gen_verify_cvv.cs, eft_verify_pinblock. cs and rsa_enc_dec.cs.

GetKeyAlgId() [1/2]

int GetKeyAlgId ( string strKeyId)
inline

Returns the algorithm of a key.

Parameters
strKeyIdUser name
Return
Algorithm identifier.
Exceptions
DinamoExceptionThrows exception in case of error.

GetKeyAlgId() [2/2]

int GetKeyAlgId ( IntPtr hKey)
inline

Returns the type of a key.

Parameters
hKeyKey handle
Return
Key type
Exceptions
DinamoExceptionThrows exception in case of error.

GetKeyPadding()

int GetKeyPadding ( IntPtr hKey)
inline

Returns the padding type of a key.

Parameters
hKeyKey handle
Return
Key padding type
Exceptions
DinamoExceptionThrows exception in case of error.

GetUserKeyLen() [1/2]

int GetUserKeyLen ( string KeyId)
inline

Returns the size of a key.

Parameters
KeyIdKey identification
Return
Key size in bits
Exceptions
DinamoExceptionThrows exception in case of error.

GetUserKeyLen() [2/2]

int GetUserKeyLen ( IntPtr hKey)
inline

Returns the size of a key.

Parameters
hKeyKey handle
Return
Key size in bits
Exceptions
DinamoExceptionThrows exception in case of error.

IsKeyExist()

bool IsKeyExist ( string KeyId)
inline
Obsolete
This API is discontinued. Please use hasObject().
Examples
oath.cs.

HasObject()

bool HasObject ( string Id)
inline

Verifies the existence of an object.

Parameters
IdObject identifier in the HSM.
Return
True if the object exists
Exceptions
DinamoExceptionThrows exception in case of error.

GetMapInfo() [1/2]

void GetMapInfo ( string ObjectId,
ref string Obj1Id,
ref string Obj2Id )
inline

Retrieves map information (backward compatibility)

Parameters
ObjectIdMap name
Obj1IdName of the object in the first slot
Obj2IdName of the object in the second slot
Exceptions
DinamoExceptionThrows exception in case of error.

GetMapInfo() [2/2]

void GetMapInfo ( string ObjectId,
ref string Obj1Id,
ref int Obj1TypeId,
ref string Obj2Id,
ref int Obj2TypeId )
inline

Retrieves map information.

Parameters
ObjectIdMap name
Obj1IdName of the object in the first slot
Obj1TypeIdObject type in the first slot
Obj2IdName of the object in the second slot
Obj2TypeIdObject type in the second slot
Exceptions
DinamoExceptionThrows exception in case of error.

ListCertAssociations()

List< CertAssociation > ListCertAssociations ( bool onlyWithAssociation = false)
inline

Lists the certificates and their associated private keys.

Parameters
onlyWithAssociationTrue if you only want certificates with associated keys
Return
Returns a list of certificate associations with their respective private keys.
Exceptions
DinamoExceptionThrows exception in case of error.
Examples
list_association.cs.

IsKeyReadLock() [1/2]

bool IsKeyReadLock ( string KeyId)
inline

Test if the key is exportable.

Parameters
KeyIdKey name
Return
True if the key is exportable
Exceptions
DinamoExceptionThrows exception in case of error.

IsKeyReadLock() [2/2]

bool IsKeyReadLock ( IntPtr hKey)
inline

Test if the key is exportable.

Parameters
hKeyKey handle
Return
True if the key is exportable
Exceptions
DinamoExceptionThrows exception in case of error.

IsKeyEncrypted() [1/2]

bool IsKeyEncrypted ( string KeyId)
inline

Test that the key is encrypted.

Parameters
KeyIdKey name
Return
True if the key is encrypted
Exceptions
DinamoExceptionThrows exception in case of error.

IsKeyEncrypted() [2/2]

bool IsKeyEncrypted ( IntPtr hKey)
inline

Test that the key is encrypted.

Parameters
hKeyKey handle
Return
True if the key is encrypted
Exceptions
DinamoExceptionThrows exception in case of error.

BlockObject()

void BlockObject ( string szObjectName,
bool bBlock )
inline

Changes the lock status of an object.

Parameters
szObjectNameObject name
bBlocktrue for locked and false for unlocked
Exceptions
DinamoExceptionThrows exception in case of error.
Examples
block_object.cs.

IsObjectBlocked()

bool IsObjectBlocked ( string szObjectName)
inline

Recovers the locked state of an object.

Parameters
szObjectNameObject name
Return
true if locked and false if unlocked.
Exceptions
DinamoExceptionThrows exception in case of error.
Examples
block_object.cs.

GenerateMap()

void GenerateMap ( string MapId,
string Obj1Id,
ALG Obj1Type,
string Obj2Id,
ALG Obj2Type )
inline

RemoveObject()

void RemoveObject ( string ObjectId)
inline

Removes an object from the HSM.

Parameters
ObjectIdObject name
Exceptions
DinamoExceptionThrows exception in case of error.
Examples
block_object.cs, dukpt.cs, eft_gen_pin.cs, eft_gen_verify_cvv.cs, eft_verify_pinblock.cs, generate_hmac.cs, generate_hmac_lau.cs and rsa_enc_dec.cs.

RemoveObjectIfExists()

void RemoveObjectIfExists ( string ObjectId)
inline

Removes an object from the HSM, if it exists.

Parameters
ObjectIdObject name
Exceptions
DinamoExceptionThrows exception in case of error.
Examples
bchain_ckd.cs, bchain_eddsa_sign.cs, bchain_get_address.cs, bchain_get_pub. cs and bchain_sign_hash.cs.

ListObjects() [1/2]

string[] ListObjects ( )
inline

Lists the objects of the current HSM user.

Return
Array containing the names of objects.
Exceptions
DinamoExceptionThrows exception in case of error.

ListCallback()

Int32 ListCallback ( string szName,
ref DinamoApi.DBLOB pParam,
Int32 bFinal )
inline

ListObjects() [2/2]

string[] ListObjects ( ALG type)
inline

ReadFile()

byte[] ReadFile ( string FileId)
inline
Examples
read_file.cs.

WriteLocalFileCallback()

Int32 WriteLocalFileCallback ( IntPtr pbData,
Int32 cbData,
ref DinamoApi.DBLOB_FILE pParam,
Int32 bFinal )
inline

WriteFile()

void WriteFile ( string FileId,
byte[] byFileData )
inline

Imports objects into the HSM. Certificates, PKCS#7, Keys.

Parameters
FileIdKey identifier. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. An object identifier in HSM can have a maximum length, in characters, of DinamoApi.MAX_OBJ_NAME_LEN. When creating keys in another user's partition (permission required) the name must be fully qualified with an FQN(Full Qualified Name: partition_id/obj_id), the maximum length for an FQN is DinamoApi.MAX_OBJ_ID_FQN_LEN-1.
byFileDataobject in the
Exceptions
DinamoExceptionThrows exception in case of error.

ReadLocalFileCallback()

Int32 ReadLocalFileCallback ( IntPtr pbData,
ref Int32 pcbData,
IntPtr pParam,
out Int32 pbFinal )
inline

ExportKey()

byte[] ExportKey ( IntPtr hKey,
IntPtr hKeyEncryptionKey,
BLOB_TYPE BlobType )
inline
Examples
rsa_enc_dec.cs.

ImportKey() [1/2]

IntPtr ImportKey ( string KeyId,
IntPtr hKeyEncryptionKey,
byte[] byKeyBlob,
BLOB_TYPE BlobType,
KEY_ALG AlgId )
inline

ImportKey() [2/2]

IntPtr ImportKey ( string KeyId,
IntPtr hKeyEncryptionKey,
byte[] byKeyBlob,
BLOB_TYPE BlobType,
KEY_ALG AlgId,
bool Exportable,
bool Temporary )
inline

ImportPKCS12File()

void ImportPKCS12File ( string FilePath,
string Password,
string KeyId,
string CertId,
bool Exportable )
inline

Imports a key/certificate from a file in PKCS#12 format into the HSM.

Parameters
FilePathLocation of the physical PFX file to be imported.
PasswordPassword to open PFX file.
KeyIdName that the imported key will have within the HSM. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. An object identifier in the HSM can have a maximum length, in characters, of DinamoApi.MAX_OBJ_NAME_LEN. When creating keys in another user's partition (permission required) the name must be fully qualified with an FQN(Full Qualified Name: partition_id/obj_id), the maximum length for an FQN is DinamoApi.MAX_OBJ_ID_FQN_LEN-1.
CertIdName that the imported certificate will have within the HSM. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. An object identifier in the HSM can have a maximum length, in characters, of DinamoApi.MAX_OBJ_NAME_LEN. When creating keys in another user's partition (permission required) the name must be fully qualified with an FQN(Full Qualified Name: partition_id/obj_id), the maximum length for an FQN is DinamoApi.MAX_OBJ_ID_FQN_LEN-1.
ExportableImport the key in exportable form.
Exceptions
DinamoExceptionThrows exception in case of error.

ImportPKCS12() [1/3]

Int32 ImportPKCS12 ( string FilePath,
string Password,
string KeyId,
string CertId,
bool Exportable )
inline
Obsolete
This API is discontinued. Please use ImportPKCS12File().
Examples
import_export_pkcs12.cs.

ImportPKCS12() [2/3]

void ImportPKCS12 ( byte[] Pkcs12,
string Password,
string KeyId,
string CertId,
bool Exportable )
inline

Imports a key/certificate from a buffer in PKCS#12 format into the HSM.

Parameters
Pkcs12PKCS#12.
PasswordPassword for PKCS#12.
KeyIdName that the imported key will have within the HSM. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. An object identifier in the HSM can have a maximum length, in characters, of DinamoApi.MAX_OBJ_NAME_LEN. When creating keys in another user's partition (permission required) the name must be fully qualified with an FQN(Full Qualified Name: partition_id/obj_id), the maximum length for an FQN is DinamoApi.MAX_OBJ_ID_FQN_LEN-1.
CertIdName that the imported certificate will have within the HSM. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. An object identifier in the HSM can have a maximum length, in characters, of DinamoApi.MAX_OBJ_NAME_LEN. When creating keys in another user's partition (permission required) the name must be fully qualified with an FQN(Full Qualified Name: partition_id/obj_id), the maximum length for an FQN is DinamoApi.MAX_OBJ_ID_FQN_LEN-1.
ExportableImport the key in exportable form.
Exceptions
DinamoExceptionThrows exception in case of error.

ImportPKCS12() [3/3]

void ImportPKCS12 ( byte[] Pkcs12,
string Password,
string KeyId,
Int32 KeyAttr,
string CertId,
string PubKeyId,
Int32 Reserved )
inline

Imports a key/certificate from a buffer in PKCS#12 format into the HSM.

Parameters
Pkcs12PKCS#12.
PasswordPassword for PKCS#12.
KeyIdName that the imported key will have within the HSM. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. An object identifier in the HSM can have a maximum length, in characters, of DinamoApi.MAX_OBJ_NAME_LEN. When creating keys in another user's partition (permission required) the name must be fully qualified with an FQN(Full Qualified Name: partition_id/obj_id), the maximum length for an FQN is DinamoApi.MAX_OBJ_ID_FQN_LEN-1.
KeyAttrAttributes of the key to be imported into the HSM. Additional parameters of the key.
Value Meaning
DinamoAPI.EXPORTABLE_KEY The key can be exported from the HSM.
CertIdName that the imported certificate will have within the HSM. This identifier must not contain spaces or special characters. Uppercase and lowercase characters are case-sensitive. An object identifier in the HSM can have a maximum length, in characters, of DinamoApi.MAX_OBJ_NAME_LEN. When creating keys in another user's partition (permission required) the name must be fully qualified with an FQN(Full Qualified Name: partition_id/obj_id), the maximum length for an FQN is DinamoApi.MAX_OBJ_ID_FQN_LEN-1.
PubKeyIdName that the imported public key will have inside the HSM. Can be null to not import the public key object.
ReservedReserved for future use. Must be 0.
Exceptions
DinamoException

PKCS8ExportKey()

byte[] PKCS8ExportKey ( string szKeyId,
string szSecret )
inline

SPBExportPKCS12()

byte[] SPBExportPKCS12 ( string szISPB,
string szSecret )
inline

ExportPKCS12() [1/2]

byte[] ExportPKCS12 ( string KeyId,
string CertId,
string Secret )
inline

Exports an HSM key and certificate in PKCS#12 format.

Parameters
KeyIdName of the key to be exported.
CertIdName of the certificate to be exported.
SecretPassword protection for PKCS#12.
Exceptions
DinamoExceptionThrows exception in case of error.
Examples
import_export_pkcs12.cs.

ExportPKCS12() [2/2]

byte[] ExportPKCS12 ( string KeyId,
string CertId,
string Secret,
Int32 Flags )
inline

Exports an HSM key and certificate in PKCS#12 format.

Parameters
KeyIdName of the key to be exported.
CertIdName of the certificate to be exported.
SecretPassword protection for PKCS#12.
FlagsPass 0 or one of the options in the table below.
Attribute Value
DN_EXPORT_P12_LEGACY It exports the key and certificate and generates the PKCS#12 file in software.
Exceptions
DinamoExceptionThrows exception in case of error.

PKCS8ImportKey()

void PKCS8ImportKey ( string szKeyId,
string szSecret,
int dwKeyAlg,
int dwAttrib,
byte[] bKeyEnvelope )
inline

SPBImportPKCS12()

void SPBImportPKCS12 ( string szKeyId,
string szSecret,
string szDomain,
int dwKeyAlg,
int dwAttrib,
string file )
inline