CmGetSecureData
Description
CmGetSecureData reads encrypted Extended Protected Data or Hidden Data from a CmContainer entry. The retrieved encrypted data has to be decrypted individually.
|
Triple Mode Redundancy-related information (TMR)
|
Syntax
int CMAPIENTRY CmGetSecureData(HCMSysEntry hcmse, CMSECUREDATA *pcmSecureData, CMENTRYDATA *pcmEntryData);
Parameter
hcmse contains a handle opened by CmAccess / CmAccess2 (must be Entry Access).
pcmSecureData contains a
CMSECUREDATA structure.
|
CMSECUREDATA stores all needed parameters for an encrypted reading of a PIO. Syntax
Parameter mcmBaseCrypt contains all needed parameters for an encryption (see structure
musExtType contains the extended type (ID) of the PIO to read. musPioType contains the type of the PIO to read out in an encrypted way.
mabPioEncryptionKey[CM_BLOCK_SIZE] contains the PIOEK (Product Item Option Encryption Key). mulReserve is reserved for future purposes.
|
pcmEntryData contains a
CMENTRYDATA structure receiving the encrypted data.
|
CMENTRYDATA contains a dynamic added data of a Product Item with all its properties. Syntax
Parameter mflCtrl specifies the type of the dynamic added entry. It can contain one of the following flags:
For the three entry types Extended Protected Data, Hidden Data and Secret Data the index of this data type is or'ed in the upper two bytes. See remarks for a sample. mflDependency contains the dependency of the dynamic added entry. It can be have one or more of the following flags:
mulReserve is reserved for future purposes. mcbData contains the length of mabData, for text entries (CM_GF_TEXT) the number of characters, for all other types the number of stored bytes. mabData[2 * CM_MAX_STRING_LEN] contains the data of the dynamic added entry with the length stored in mcbData. For text entries (CM_GF_TEXT) the byte array contains an UCS2-LE encoded null-terminated string. Notes To check the mflCtrl you can use the CM_GF_PIO_MASK to retrieve only the data type flag, e.g. mflCtrl & CM_GF_PIO_MASK. To retrieve the index of Extended Protected Data, Hidden Data or Secret Data you need to extract the upper two bytes of mflCtrl, e.g. by mflCtrl >> 16. For an easier conversion of mabData it may be helpful to use CmConvertString().
|
Return
The return value contains the number of bytes containing the plain data returned encrypted in CMENTRYDATA::mabData. If an error occurred, 0 is returned.
Notes
For Hidden Data, the Hidden Data Access Code (HDAC) must specified and match the stored value.
Syntax
public int CmGetSecureData(HCMSysEntry hcmse, CmSecureData SecureData, out CmEntryData EntryData) |
Parameter
hcmse contains a handle opened by CmAccess / CmAccess2 (must be Entry Access).
SecureData contains a
CmSecureData class).
|
CmSecureData stores all needed parameters for an encrypted reading of a PIO. Syntax
Parameter BaseCrypt contains all needed parameters for an encryption (see class
ExtType contains the extended type (ID) of the PIO to read. PioType contains the type of the PIO to read out in an encrypted way. The following options of the enum GlobalEntryOption exist:
PioEncryptionKey contains the PIOEK (Product Item Option Encryption Key).
|
EntryData contains a
CmEntryData class receiving the encrypted data.
|
CmEntryData contains a dynamic added data of a Product Item with all its properties. Syntax
Parameter Ctrl specifies the type of the dynamic added entry from the enum GlobalEntryOption. It can contain one of the following flags:
For the three entry types Extended Protected Data, Hidden Data and Secret Data the index of this data type is or'ed in the upper two bytes. See remarks for a sample. Dependency contains the dependency of the dynamic added entry from the enum GlobalProductCodeOption. It can be have one or more of the following flags:
DataLen contains the length of Data, for text entries (Text) the number of characters, for all other types the number of stored bytes. Data contains the data of the dynamic added entry with the length stored in DataLen. For text entries (Text) the byte array contains an UCS2-LE encoded null-terminated string. Notes To check the Ctrl you can use the CM_GF_PIO_MASK to retrieve only the data type flag, e.g. Ctrl & PioMask. To retrieve the index of Extended Protected Data, Hidden Data or Secret Data you need to extract the upper two bytes of Ctrl, e.g. by Ctrl >> 16. For an easier conversion of Data it may be helpful to use System.Text.Encoding.Unicode.GetString().
|
Return
The return value contains the number of bytes containing the plain data returned encrypted in CMENTRYDATA:abData. If an error occurred, 0 is returned.
Notes
For Hidden Data, the Hidden Data Access Code (HDAC) must specified and match the stored value.
Syntax
import cmapi
handle.CmGetSecureData(pcmSecureData: CMSECUREDATA) -> CMENTRYDATA
throws CodeMeterApiFailedException()
Parameter
handle is the handle opened by CmAccess2 (must be Entry Access).
pcmSecureData contains a
cmapi.CMSECUREDATA structure.
|
CMSECUREDATA stores all needed parameters for an encrypted reading of a PIO. Syntax
Parameter mcmBaseCrypt contains all needed parameters for an encryption (see class
musExtType contains the extended type (ID) of the PIO to read. musPioType contains the type of the PIO to read out in an encrypted way.
mabPioEncryptionKey[CM_BLOCK_SIZE] contains the PIOEK (Product Item Option Encryption Key). mulReserve is reserved for future purposes.
|
pcmEntryData contains a
cmapi.CMENTRYDATA structure receiving the encrypted data.
|
CMENTRYDATA contains a dynamic added data of a Product Item with all its properties. Syntax
Parameter mflCtrl specifies the type of the dynamic added entry. It can contain one of the following flags:
For the three entry types Extended Protected Data, Hidden Data and Secret Data the index of this data type is or'ed in the upper two bytes. See remarks for a sample. mflDependency contains the dependency of the dynamic added entry. It can be have one or more of the following flags:
mulReserve is reserved for future purposes. mcbData contains the length of mabData, for text entries (cmapi.CM_GF_TEXT) the number of characters, for all other types the number of stored bytes. mabData[2 * CM_MAX_STRING_LEN] contains the data of the dynamic added entry with the length stored in mcbData. For text entries (cmapi.CM_GF_TEXT) the byte array contains an UCS2-LE encoded null-terminated string. Notes To check the mflCtrl you can use the cmapi.CM_GF_PIO_MASK to retrieve only the data type flag, e.g. mflCtrl & cmapi.CM_GF_PIO_MASK. To retrieve the index of Extended Protected Data, Hidden Data or Secret Data you need to extract the upper two bytes of mflCtrl, e.g. by mflCtrl >> 16.
|
Notes
For Hidden Data, the Hidden Data Access Code (HDAC) must specified and match the stored value.