CmCryptSim2
Description
CmCryptSim2 encrypts or decrypts data with direct or indirect encryption (see Encryption Modes) by using the Firm Security Box (FSB) entry of the desired Firm Code.
|
Triple Mode Redundancy-related information (TMR)
|
Syntax
int CMAPIENTRY CmCryptSim2(HCMSysEntry hcmse, CMULONG flCtrl, CMCRYPTSIM2 *pcmCryptSim, void* pvDest, CMUINT cbDest)
Parameter
hcmse contains a handle opened by CmAccess / CmAccess2. Access Mode must be Entry Access to the FSB entry of the desired Firm Code. If the Firm Code is an evaluation Firm Code, the access can be SubSystem Access. A matching entry in the CmLicensor/CmFirm.wbc file has to exist in both cases.
flCtrl contains the encryption or decryption command. Following commands are supported:
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
CMBASECRYPT2.
|
CMBASECRYPT2 stores all needed parameters needed for every possible en- or decryption. Syntax
Parameter mflCtrl contains commands and flags influencing the en- or decryption. The parameter can use the following flags: Used Key:
Used Encryption Algorithm:
•d (private key) in SecretData ExtType 130 •p (secret prime) in SecretData ExtType 131 •q (secret prime) in SecretData ExtType 132 CM_CRYPT_RSA requires a CmContainer Firmware version 1.11 CRC calculation: The algorithm CRC-32 is used to calculate the CRC checksum of the data.
mulKeyExtType specifies the key source, if the encryption is done with a Hidden Data or a Secret Data. mulEncryptionCode contains the Encryption Code set by the user. mulEncryptionCodeOptions contains one or more of the following flags:
mulFeatureCode specifies the Feature Code mapping for the existing Feature Map. The operation fails, if the Feature Code contains bits which do not exist in the Feature Map. mcmReleaseDate specifies the Release Date in a
|
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 CMBASECRYPT2.
CM_CRYPT_AES_ENC_CBC executes the indirect encryption using the AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that cbDest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
cbDest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If cbDest equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If cbDest equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
CM_CRYPT_AES_DEC_CBC executes the indirect decryption using the AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that cbDest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
cbDest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If cbDest equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If cbDest equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
CM_CRYPT_AES_ENC_CBC_DIRECT executes the encryption using the original AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that cbDest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
cbDest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If cbDest equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If cbDest equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
It does not use any CodeMeter license, therefore use NULL for hcmse. The AES key has to be placed in mabDirectAesKey, the initialization vector in mabInitKey - both see CMBASECRYPT2.
CM_CRYPT_AES_DEC_CBC_DIRECT executes the decryption using the original AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that cbDest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
cbDest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If cbDest equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If cbDest equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
It does not use any CodeMeter license, therefore use NULL for hcmse. The AES key has to be placed in mabDirectAesKey, the initialization vector in mabInitKey - both see CMBASECRYPT2.
|
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). |
pcmCryptSim sets some needed data for the en-/decryption process (see
CMCRYPTSIM2).
|
CMCRYPTSIM2 contains all needed parameters for an simulated encryption with a Firm-Security-Box (FSB).
Parameter mflCtrl specifies the type of the Firm Item. The following flags can be set:
mulFirmCode specifies the Firm Code used for the simulated encryption. mulProductCode specifies the Product Code used for the simulated encryption. mulReserve is reserved for future purposes. mcmBaseCrypt contains all needed parameters for an encryption (see CMBASECRYPT). mabInitKey contains the key for the indirect encryption (see Encryption Modes) mcbExtFirmKey contains the length of the data stored in mabExtFirmKey. This must be one of the following values: 0, 16, 20 or 32. mabExtFirmKey contains a external key for the simulated encryption. This can only be the data of a Hidden Data or Secret Data of a CmContainer entry with the normal en-/decryption. maulReserved is reserved for future purposes. Note Currently, the setting of an external Firm Key is only possible for CmActLicenses due to a restriction in the Firmware. For Firm Codes of hardware (e.g. 10, 100000 - 4999999) this is not possible. CMCRYPTSIM2 is supported since CodeMeter Version 4.30.
|
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.
Notes
The key source in CMCRYPTSIM2::mcmcrypt::mflCtrl can only be the Firm Key. Other key sources like Hidden Data or Secret Data cannot be simulated by a FSB.
This function is only for Licensor site because a FSB is required.
CmCryptSim2() is supported since CodeMeter version 4.30.
Syntax
This method is overloaded, i.e. the same method name is used with different type of parameters or different set of parameters.
|
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). |
Method 1:
public bool CmCryptSim2(HCMSysEntry hcmse, CmCryptOption Ctrl, CmCryptSim2 CryptSim, byte[] Dest, int StartIndex, uint DestLen)
|
This method overload encrypts and decrypts data in bytes as specified in the dest field of the method.
Method 2:
public bool CmCryptSim2(HCMSysEntry hcmse, CmCryptOption Ctrl, CmCryptSim2 CryptSim, byte[] Dest) 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.
Parameter
hcmse contains a handle opened by CmAccess / CmAccess2. Access Mode must be Entry Access to the FSB entry of the desired Firm Code. If the Firm Code is an evaluation Firm Code, the access can be SubSystem Access. A matching entry in the CmLicensor/CmFirm.wbc file has to exist in both cases.
flCtrl contains the encryption or decryption command. Following commands are supported:
hcmse contains a handle opened by CmAccess / CmAccess2. Access Mode must be Entry Access to the FSB entry of the desired Firm Code. If the Firm Code is an evaluation Firm Code, the access can be SubSystem Access. A matching entry in the CmLicensor/CmFirm.wbc file has to exist in both cases.
CmCryptOption contains the encryption or decryption command. Following commands are supported:
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
CmBaseCrypt2.
|
CmBaseCrypt2 stores all needed parameters needed for every possible en- or decryption. Syntax
Parameter CmBaseCrypt.Option contains commands and flags influencing the en- or decryption. The parameter can use the following flags: Used Key:
Used Encryption Algorithm:
•d (private key) in SecretData ExtType 130 •p (secret prime) in SecretData ExtType 131 •q (secret prime) in SecretData ExtType 132 Rsa requires a CmContainer Firmware version 1.11 CRC calculation: The algorithm CRC-32 is used to calculate the CRC checksum of the data.
KeyExtType specifies the key source, if the encryption is done with a Hidden Data or a Secret Data. EncryptionCode contains the Encryption Code set by the user. EncCodeOption contains one or more of the following flags:
FeatureCode specifies the Feature Code mapping for the existing Feature Map. The operation fails, if the Feature Code contains bits which do not exist in the Feature Map. ReleaseDate specifies the Release Date in a
Crc contains the CRC value of the current operation. It depends on the CalcCrc or ChkCrc flags, if this value is set or checked. |
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 CmBaseCrypt2.
|
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). |
AesEncryptCbc executes the indirect encryption using the AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that Dest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
Dest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If Dest equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If Dest equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
AesDecryptCbc executes the indirect decryption using the AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that Dest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
Dest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If Dest equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If Dest equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
AesEncryptCbcDirect executes the encryption using the original AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that Dest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
Dest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If Dest equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If Dest equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
It does not use any CodeMeter license, therefore use NULL for hcmse. The AES key has to be placed in DirectAesKey, the initialization vector in InitKey - both see class
CmCrypt2).
|
CMCRYPT2 contains all needed parameters for an encryption with a CmContainer using CmCrypt2 Syntax
Parameter BaseCrypt contains all needed parameters for an encryption (see CmBaseCrypt2). DirectAesKey contains the AES key for an encryption/decryption without CmContainer using original AES. This is only used for CmCrypt2 with the flags CmCryptOption.AesEncryptCbcDirect or AesDecryptCbcDirect (see also Encryption Modes). InitKey contains the key for the indirect encryption (see Encryption Modes). For an encryption/decryption without hardware using CmCrypt2 with the flags CmCryptOption.AesEncryptCbcDirect or AesDecryptCbcDirect use this member to set the initialization vector (IV). Reserved is reserved for future purposes.
|
AesDecryptCbcDirect executes the decryption using the original AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that Dest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
Dest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If Dest equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If Dest equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
It does not use any CodeMeter license, therefore use NULL for hcmse. The AES key has to be placed in DirectAesKey, the initialization vector in InitKey - both see CmCrypt2.
CryptSim sets some needed data for the en-/decryption process (see class
CmCryptSim2).
|
CmCryptSim2 contains all needed parameters for an simulated encryption with a Firm-Security-Box (FSB).
Parameter BaseCrypt contains all needed parameters for an encryption (see class CmBaseCrypt2). Ctrl specifies the type of the Firm Item. The following flags can be set:
FirmCode specifies the Firm Code used for the simulated encryption. ProductCode specifies the Product Code used for the simulated encryption. ExtFirmKeyLen contains a external key for the simulated encryption. This can only be the data of a Hidden Data or Secret Data of a CmContainer entry with the normal en-/decryption. InitKey contains the key for the indirect encryption (see Encryption Modes) Note Currently, the setting of an external Firm Key is only possible for CmActLicenses due to a restriction in the Firmware. For Firm Codes of hardware (e.g. 10, 100000 - 4999999) this is not possible. Class CmCryptSim2 is supported since CodeMeter Version 4.30.
|
Dest contains the data to en-/decrypt.
Return
This function returns true. If an error occurred, false will be returned.
Notes
The key source in in CmCryptSim2:Ctrl can only be the Firm Key. Other key sources like Hidden Data or Secret Data cannot be simulated by a FSB.
This function is only for Licensor site because a FSB is required.
CmCryptSim2() is supported since CodeMeter Version 4.30.
Syntax
import cmapi
handle.CmCryptSim2(flCtrl: int, pcmCryptSim: cmapi.CMCRYPTSIM2,
pvDest: bytes) -> bytes
throws CodeMeterApiFailedException()
Parameter
handle is the handle opened by CmAccess2. Access Mode must be Entry Access to the FSB entry of the desired Firm Code. If the Firm Code is an evaluation Firm Code, the access can be SubSystem Access. A matching entry in the CmLicensor/CmFirm.wbc file has to exist in both cases.
flCtrl contains the encryption or decryption command. Following commands are supported:
cmapi.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 cmapi.CM_CRYPT_AES) or between 0 and 32 bytes (for cmapi.CM_CRYPT_ECIES and cmapi.CM_CRYPT_ECIES_STD) - see structure
cmapi.CMBASECRYPT2.
|
CMBASECRYPT2 stores all needed parameters needed for every possible en- or decryption. Syntax
Parameter mflCtrl contains commands and flags influencing the en- or decryption. The parameter can use the following flags: Used Key:
Used Encryption Algorithm:
•d (private key) in SecretData ExtType 130 •p (secret prime) in SecretData ExtType 131 •q (secret prime) in SecretData ExtType 132 CM_CRYPT_RSA requires a CmContainer Firmware version 1.11 CRC calculation: The algorithm CRC-32 is used to calculate the CRC checksum of the data.
mulKeyExtType specifies the key source, if the encryption is done with a Hidden Data or a Secret Data. mulEncryptionCode contains the Encryption Code set by the user. mulEncryptionCodeOptions contains one or more of the following flags:
mulFeatureCode specifies the Feature Code mapping for the existing Feature Map. The operation fails, if the Feature Code contains bits which do not exist in the Feature Map. mcmReleaseDate specifies the Release Date in a
|
cmapi.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 cmapi.CM_CRYPT_AES) or between 0 and 32 bytes (for cmapi.CM_CRYPT_ECIES and cmapi.CM_CRYPT_ECIES_STD) - see CMBASECRYPT2.
cmapi.CM_CRYPT_AES_ENC_CBC executes the indirect encryption using the AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that pvDest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
cbDest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If the size equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If the size equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
cmapi.CM_CRYPT_AES_DEC_CBC executes the indirect decryption using the AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that pvDest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
pvDest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If the size equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If the size equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
cmapi.CM_CRYPT_AES_ENC_CBC_DIRECT executes the encryption using the original AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that pvDest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
pvDest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If the size equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If the size equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
It does not use any CodeMeter license, therefore use NULL for hcmse. The AES key has to be placed in mabDirectAesKey, the initialization vector in mabInitKey - both see CMBASECRYPT2.
cmapi.CM_CRYPT_AES_DEC_CBC_DIRECT executes the decryption using the original AES block cipher algorithm with CBC.
By default, the method CTS is used. CTS stands for ciphertext stealing, i.e. swapping the final two ciphertext blocks, also in the case that pvDest is a multiple of the blocksize.
Moreover, CTS allows unpadded data, that has a length not a multiple of the block site (16 bytes), to be encrypted to the same length of the cipher text.
|
pvDest must always be equal to or larger than 16 bytes. The initialization vector (IV) is never stolen. If the size equals 16 bytes, the encryption results corresponds to the encryption using standard AES CBC without CTS. If the size equals 16 bytes and the initialization vector (IV) equals a value of 0, the encryption result corresponds to ECB. |
It does not use any CodeMeter license, therefore use NULL for hcmse. The AES key has to be placed in mabDirectAesKey, the initialization vector in mabInitKey - both see cmapi.CMBASECRYPT2.
|
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). |
pcmCryptSim sets some needed data for the en-/decryption process (see
cmapi.CMCRYPTSIM2).
|
cmapi.CMCRYPTSIM2 contains all needed parameters for an simulated encryption with a Firm-Security-Box (FSB).
Parameter mflCtrl specifies the type of the Firm Item. The following flags can be set:
mulFirmCode specifies the Firm Code used for the simulated encryption. mulProductCode specifies the Product Code used for the simulated encryption. mulReserve is reserved for future purposes. mcmBaseCrypt contains all needed parameters for an encryption (see cmapi.CMBASECRYPT). mabInitKey contains the key for the indirect encryption (see Encryption Modes) mcbExtFirmKey contains the length of the data stored in mabExtFirmKey. This must be one of the following values: 0, 16, 20 or 32. mabExtFirmKey contains a external key for the simulated encryption. This can only be the data of a Hidden Data or Secret Data of a CmContainer entry with the normal en-/decryption. maulReserved is reserved for future purposes. Note Currently, the setting of an external Firm Key is only possible for CmActLicenses due to a restriction in the Firmware. For Firm Codes of hardware (e.g. 10, 100000 - 4999999) this is not possible. CMCRYPTSIM2 is supported since CodeMeter Version 4.30.
|
pvDest contains the data to en-/decrypt.
Return
This function returns the number of en-/decrypted bytes. If an error occurred, an exception is thrown.
Notes
The key source in cmapi.CMCRYPTSIM2::mcmcrypt::mflCtrl can only be the Firm Key. Other key sources like Hidden Data or Secret Data cannot be simulated by a FSB.
This function is only for Licensor site because a FSB is required.
CmCryptSim2() is supported since CodeMeter version 4.30.