cookie CmCrypt

Description

CmCrypt encrypts or decrypts data with direct or indirect encryption (see Encryption Modes) via a CmContainer entry.

tmr_02

Triple Mode Redundancy-related information (TMR)

  • C, C++
  • C#
  • Python

Syntax

int CMAPIENTRY CmCrypt(HCMSysEntry hcmse, CMULONG flCtrl, CMCRYPT *pcmCrypt, void* pvDest, CMUINT cbDest)

Parameter

hcmse contains a handle opened by CmAccess / CmAccess2. Access Mode must be Entry Access to the Firm Code : Product Code entry used for en-/decryption.

flCtrl contains the encryption or decryption command. Following commands are supported:

nav_open CM_CRYPT_DIRECT_ENC executes the direct symmetric encryption via a CmContainer entry. The length of bytes to encrypt must be exactly 16 bytes (for CM_CRYPT_AES) or between 0 and 32 bytes (for CM_CRYPT_ECIES and CM_CRYPT_ECIES_STD) - see structure hmtoggle_plus1 CMBASECRYPT.

nav_open CM_CRYPT_DIRECT_DEC executes the direct symmetric decryption via a CmContainer entry. The length of bytes to decrypt must be exactly 16 bytes (for CM_CRYPT_AES) or between 0 and 32 bytes (for CM_CRYPT_ECIES and CM_CRYPT_ECIES_STD) - see CMBASECRYPT.

nav_open CM_CRYPT_AES_ENC_CBC executes the indirect encryption using the AES block cipher algorithm with CBC. The length of the sequence to encrypt must be at least 16 bytes.

nav_open CM_CRYPT_AES_DEC_CBC executes the indirect decryption using the AES block cipher algorithm with CBC. The length of the sequence to decrypt must be at least 16 bytes.

information_weiss_klein26

Wibu-Systems recommends this mode since CBC is the most commonly used mode of operation.

Although CodeMeter supports also other older cryptographic modes. However, their use is not recommended.

For more information see the technical guideline TR-02102-1 "Cryptographic Mechanisms: Recommendations and Key Lengths" (courtesy translation) edited by the German Federal Office for Information Security, BSI (Bundesamt für Sicherheit in der Informationstechnik) (BSI).

pcmCrypt sets some needed data for the en-/decryption process (see structure hmtoggle_plus1 CMCRYPT).

pvDest contains the data to en-/decrypt.

cbDest contains the number of bytes to en-/decrypt stored in pvDest.  

Return

This function returns the number of en-/decrypted bytes. If an error occurred, 0 will be returned.

Syntax

This method is overloaded, i.e. the same method name is used with different type of parameters or different set of parameters.

information_weiss_klein26

Wibu-Systems recommends the CBC mode of operation.

Although CodeMeter supports also other older cryptographic modes. However, their use is not recommended.

For more information see the technical guideline TR-02102-1 "Cryptographic Mechanisms: Recommendations and Key Lengths" (courtesy translation) edited by the German Federal Office for Information Security, BSI (Bundesamt für Sicherheit in der Informationstechnik) (BSI).

Method 1:

public bool CmCrypt(HCMSysEntry hcmse, CmCryptOption Ctrl, CmCrypt Crypt, byte[] Dest, int StartIndex, uint DestLen)

This method overload encrypts and decrypts data in bytes with a StartIndex and DestLen as the total size of the destination buffer.

Method 2:

public bool CmCrypt(HCMSysEntry hcmse, CmCryptOption Ctrl, CmCrypt Crypt, byte[] Dest)

This method overload encrypts and decrypts data in bytes as specified in the dest field of the method.

Parameter

hcmse contains a handle opened by CmAccess / CmAccess2. Access Mode must be Entry Access to the Firm Code : Product Code entry used for en-/decryption.

CmCryptOption contains the encryption or decryption command. Following commands are supported:

nav_open DirectEncryption executes the direct symmetric encryption via a CmContainer entry. The length of bytes to encrypt must be exactly 16 bytes (for Aes) or between 0 and 32 bytes (for Ecies and EciesStd) - see class hmtoggle_plus1 CmBaseCrypt.

nav_open DirectDecryption executes the direct symmetric decryption via a CmContainer entry. The length of bytes to decrypt must be exactly 16 bytes (for Aes) or between 0 and 32 bytes (for Ecies and EciesStd) - see class CmBaseCrypt.

nav_open AesEncryptCbc executes the indirect encryption using the AES block cipher algorithm with CBC. The length of the sequence to encrypt must be at least 16 bytes.

nav_open AesDecryptCbc executes the indirect decryption using the AES block cipher algorithm with CBC. The length of the sequence to decrypt must be at least 16 bytes.

pcmCrypt sets some needed data for the en-/decryption process (see class hmtoggle_plus1 CmCrypt).

Dest contains the data to be encrypted or decrypted.

Return

This function returns true. If an error occurred, false will be returned.

 

Not implemented.