CmCreateSequence
Description
CmCreateSequence calculates a signature to program any kind of entry in a CmDongle. All security mechanisms are handled by this function. The needed security library (on Windows: CmSecurityLS32.dll), licensor file (CmLicensor.wbc) and Firm Security Box (FSB) must be available. CmCreateSequence can calculate the security sequences for the following tasks:
•Adding a new Firm Item into a CmDongle.
•Updating an existing Firm Item in a CmDongle.
•Deleting an existing Firm Item from a CmDongle.
•Adding a new Product Item to an existing Firm Item in a CmDongle.
•Updating an existing Product Item in a CmDongle.
•Deleting an existing Product Item from a CmDongle.
•(Un-)Locking a CmDongle.
|
Triple Mode Redundancy-related information (TMR)
|
Syntax
int CMAPIENTRY CmCreateSequence(HCMSysEntry hcmse, CMULONG flCtrl, CMCREATEITEM *pcmCreateItem, void *pvCtrl, CMUINT cbCtrl)
Parameter
hcmse contains a handle opened by CmAccess / CmAccess2. The Access Mode must be Entry Access to a FSB Entry for a regular license. The handle is related to a CmLocal or a CmLAN subsystem with a connected Firm Security Box (FSB). If the license is an evaluation license not needing any security mechanisms like a FSB, the access can be Box Access. To update the IFI of a local CmDongle the access can also be Box Access. The access can be performed to the CmDongle to be programmed or updated. A matching entry in the CmLicensor/CmFirm.wbc file has to exist in both cases.
flCtrl contains one of the following commands:
CM_GF_ADD_FIRMITEM calculates the sequence for adding a Firm Item into a CmDongle. pvCtrl is pointing to a
CMPROGRAM_ADD_FIRMITEM structure.
Structure CMPROGRAM_ADD_FIRMITEM CMPROGRAM_ADD_FIRMITEM contains all needed information to add a Firm Item to a CmDongle. The following parameters of the structure are encrypted: musFirm ItemTypeEncrypted to mabSessionId (inclusive). This member defines a sequence of 64 bytes which are encrypted by AES-CBC. The key and the CBC initialization vector depends on the addressed Firm Code and of parameters of the addressed CmDongle. Syntax
Parameter musFirmItemReference contains the reserved Firm Item Reference received with CmReserveFirmItem(). musFirmItemTypePlain specifies the type of the Firm Item. The following flags can be set:
mabPublicLicensorKey contains 64 bytes of ECC Licensor Key which is required to decrypt the specified data via the private Box Key, Serial Key, Firm Common Key and Serial Number of the addressed CmDongle. musFirmItemTypeEncrypted (encrypted) specifies the type of the Firm Item. The following flags can be set:
This value must be equal to musFirmItemTypePlain! musFirmAccessCounter (encrypted) contains the initial value of the Firm Access Counter. If this member is set to 0xFFFF (the recommended value), this counter is not decremented by an encryption which targets this counter. mulFirmUpdateCounter (encrypted) contains the initial value of the Firm Update Counter. The recommended value is 0. mulFirmPreciseTime (encrypted) contains the new Firm Precise Time in seconds since 1st January 2000, 0:00:00. If the value is not used, 0 must be specified, which sets this field to the Running Box Clock value. mulReserved (encrypted) should be set to 0. Reserved for future purposes. mabFirmKey (encrypted) contains the secret Firm Key, which has a fixed length of 32 bytes. mabSessionId (encrypted) contains the Session ID received with CmReserveFirmItem(). mcchText contains the initial length of the Firm Item Text of the Firm Item to program. mausText contains the initial Firm Item Text of the Firm Item to program.
|
CM_GF_UPDATE_FIRMITEM calculates the sequence for updating a Firm Item in a CmDongle. pvCtrl is pointing to a
CMPROGRAM_UPDATE_FIRMITEM structure.
CM_GF_DELETE_FIRMITEM calculates the sequence for deleting a Firm Item from a CmDongle. pvCtrl is pointing to a
CMPROGRAM_DELETE_FIRMITEM structure.
Structure CMPROGRAM_DELETE_FIRMITEM CMPROGRAM_DELETE_FIRMITEM contains all parameters needed for deleting a complete Firm Item. Syntax
Parameter musFirmItemReference contains the Reference of the Firm Item which has to be removed. mabTrailingValidationBlock contains a 16-byte TVB (Trailing Validation Block), which must be valid to execute the operation. This TVB is ignored, if the addressed Firm Item was directly created with CmReserveFirmItem().
|
CM_GF_ADD_PRODUCTITEM calculates the sequence for adding a Product Item into a CmDongle. pvCtrl is pointing to a
CMPROGRAM_ADD_PRODUCTITEM structure.
Structure CMPROGRAM_ADD_PRODUCTITEM CMPROGRAM_ADD_PRODUCTITEM contains all needed information to add a Product Item to a CmDongle. All parameters are encrypted. Syntax
Parameter musFirmItemReference (encrypted) contains the Reference of the Firm Item for which the Product Item is to be added. If this is 1, the IFI (Implicit Firm Item) is used. The addressed item must not have set the type. 0 is either not permitted. musProductItemSuccessorReference (encrypted) contains the Reference of the Product Item, which will be the successor of the newly added Product Item. If this value is 0 the Product Item is created at the end of the Product Item list. If musFirmItemReference specifies 0 for the IFI, the Product Item may be individually addressed by setting 2 for User Product Item (UPI). 1 for the Common Product Item (CPI) is not permitted because this must be always the first Product Item of the IFI. mabProductItemOptionBuffer (encrypted) contains a byte sequence of variable length which specifies the added Product Code and all further Product Item Options. The sequence is defined by one or more subsequent CMCPIO_... structures. The parameter is filled with CmCreateProductItemOption() and finalized with CmCreateSequence(). The complete list is encrypted by AES-CBC. Finally, a 16-bytes TVB (Trailing Validation Block) is added, which is the encrypted SHA-256 hash of the preceding padded byte sequence.
|
CM_GF_UPDATE_PRODUCTITEM calculates the sequence for updating a Product Item in a CmDongle. pvCtrl is pointing to a
CMPROGRAM_UPDATE_PRODUCTITEM structure.
Structure CMPROGRAM_UPDATE_PRODUCTITEM CMPROGRAM_UPDATE_PRODUCTITEM contains all needed parameters to update a Product Item. Syntax
Parameter musFirmItemReference contains the reference of the Firm Item in which the Product Item should be updated. musProduct ItemReference contains the reference of the Product Item, which should be updated. musCtrl contains flags set internally by the driver. mabProductItemOptionBuffer contains a byte sequence of variable length which specifies the added Product Code and all further Product Item Options. The sequence is defined by one or more subsequent CMCPIO_... structures. The parameter is filled with CmCreateProductItemOption() and finialized with CmCreateSequence(). The complete list is encrypted by AES-CBC. Finally, a 16-bytes TVB (Trailing Validation Block) is added, which is the encrypted SHA-256 hash of the preceding padded byte sequence.
|
CM_GF_DELETE_PRODUCTITEM calculates the sequence for deleting a Product Item in a CmDongle. pvCtrl is pointing to a
CMPROGRAM_DELETE_PRODUCTITEM structure.
Structure CMPROGRAM_DELETE_PRODUCTITEM CMPROGRAM_DELETE_PRODUCTITEM contains the parameters for deleting a Product Item. Syntax
Parameter musFirmItemReference contains the reference of the Firm Item in which the Product Item is deleted. musProductItemReference contains the reference of the Product Item which is to be deleted. mabTrailingValidationBlock contains the Trailing Validation Block (TVB) which checks, if the delete operation is valid.
|
CM_GF_SET_BOXLOCK calculates the sequence for locking or unlocking a complete CmDongle. pvCtrl is pointing to a (see structure
CMPROGRAM_BOXLOCK structure.
|
CMPROGRAM_BOXLOCK contains all parameters to lock or unlock a CmDongle. Syntax
Parameter mflCtrl specifies, if the CmDongle should be locked or unlocked. CM_BL_LOCK specifies that the CmDongle should be locked. CM_BL_UNLOCK specifies that the CmDongle should be unlocked. mulReserve is reserved for future purposes. mabUserKey contains the new User Common Key which must match the CmDongle internally increased UKI (User Key Identifier) to lock the CmDongle against use.
|
CM_GF_ADD_ENABLBLOCK calculates the sequence for adding a new Enable Block Item to a Firm Item. pvCtrl is pointing to a
CMENABLING_WRITEADD structure.
|
CM_GF_UPDATE_ENABLEBLOCK calculates the sequence for updating an existing Enable Block Item in a Firm Item. pvCtrl is pointing to a
CMENABLING_WRITEUPDATE structure.
|
CM_GF_DELETE_ENABLEBLOCK calculates the sequence for deleting an existing Enable Block Item from a Firm Item. pvCtrl is pointing to a
CMENABLING_WRITEDELETE structure.
Structure CMENABLING_WRITEDELETE CMENABLING_WRITEDELETE describes the request sequence for deleting a Enable Block Item (EBI). command. Syntax
Parameter musFirmItemReference contains the reference of the Firm Item which defines the Enabling Block. If this is 0, the IFI (Implicit Firm Item) is used. mbEnableBlockIndex contains the index of the Enabling Block which is deleted. This must be a value between 0 and 30. mabTrailingValidationBlock contains the Trailing Validation Block (TVB), which checks whether the delete operation is valid. This is an AES encryption of the SHA-256 hash of the preceding bytes.
|
CM_GF_ATTACH_ENABLEBLOCK calculates the sequence for attaching an existing Enable Block Item in a Firm Item. pvCtrl is pointing to a
CMENABLING_WRITEATTACHDETACH structure.
Structure CMENABLING_WRITEATTACHDETACH CMENABLING_WRITEATTACHDETACH describes the request sequence for attaching or detaching a Enable Block Item (EBI). Syntax
Parameter mbEnableBlockIndex contains the index of the Enabling Block Item which is attached. The subsequent bytes are encrypted by AES-CBC or Triple-DES-CBC. They have a fixed length of 32 bytes. musFirmItemReference contains the reference of the Firm Item in which the Enabling Block is attached. If this is 0, the IFI (Implicit Firm Item) is used. musProductItemReference contains the Reference of the Product Item in which the Enabling Block is attached. If the Enabling Block should be attached to the Firm Item, this member must be set to 0. If musFirmItemReference specifies 0, the Product Item may be individually addressed by setting Common Product Item (CPI) or User product item (UPI). mulFirmUpdateCounter contains the current value of the Firm Update Counter of the Firm Item which owns the Enabling Block. mcmEnableLookupEntry contains the Enabling Lookup Entry which defines the attachment. If the mbEnableLevel member is set to CM_ELUE_DETACH, the Enabling Lookup Entry is deleted. mabTrailingValidationBlock contains the TVB (Trailing Validation Block), which contains the current hash sequence (16 bytes) to validate that the sequence is correctly encrypted. Notes All parameters set by the user to this structure must be set in Little Endian format! Normally this must be noticed on Big Endian CPU's like the Apple Macintosh. On PC's (x86) the parameters (16 & 32 Bit) are stored in Little Endian so that the user has nothing to mentioned (Little/Big Endian).
|
CM_GF_DETACH_ENABLEBLOCK calculates the sequence for detaching an existing Enable Block Item in a Firm Item. pvCtrl is pointing to a CMENABLING_WRITEATTACHDETACH structure.
pcmCreateItem points to a
CMCREATEITEM structure containing additional information for sequence calculation. The parameter mulFirmUpdateCounter will contain the updated value after the programming sequence is calculated.
|
CMCREATEITEM contains data needed to calculate a programming sequence with a Firm Security Box (FSB) to add, update or delete an entry of a CmDongle. Syntax
Parameter mulFirmCode contains the Firm Code to add, update or delete in an entry of a CmDongle. mulFirmItemType specifies the type of a Firm Item. This can be one of the following values:
mcmBoxInfoUser contains the data of the CmDongle the entry should be add, update or delete. mulFirmUpdateCounter contains the Firm Update Counter, if a Firm Item. This parameter must be set in all programming tasks except adding a Firm Item. mulProductCode contains the Product Code for calculating a sequence to update or delete a Product Item. midOem contains the OEM ID for calculating a sequence to lock or unlock a CmDongle. mulFirmwareBuild contains the Firmware Build number for calculating a sequence to activate a Field Update.
|
pvCtrl contains a structure depending on the flCtrl flag (see above).
cbCtrl contains the number of bytes of the structure stored in pvCtrl.
Return
The return value contains the length of the calculated sequence stored in pvCtrl. If an error occurred, 0 is returned. If cbCtrl is smaller than the return value, then no data in pvCtrl is set and the error code CMERROR_BUFFER_OVERFLOW is set.
Notes
One or more calls of the function CmCreateProductItemOption have to be issued to build the full sequence to program a Product Item Option using the commands CM_GF_ADD_PRODUCTITEM and CM_GF_UPDATE_PRODUCTITEM. CmCreateSequence is the final call and receives the created sequence.
This function is for Licensor site because a FSB is needed. The only exception is the programming of a User's Product Item in the Implicit Firm Item (IFI). In this case the function can also be used on User site.
Syntax
public byte[] CmCreateSequence(HCMSysEntry hcmse, GlobalProgrammingOption Option, ref CmCreateItem CreateItem, object Ctrl)
|
Parameter
hcmse contains a handle opened by CmAccess / CmAccess2. The Access Mode must be Entry Access to a FSB Entry for a regular license. The handle is related to a CmLocal or a CmLAN subsystem with a connected Firm Security Box (FSB). If the license is an evaluation license not needing any security mechanisms like a FSB, the access can be Box Access. To update the IFI of a local CmDongle the access can also be Box Access. The access can be performed to the CmDongle to be programmed or updated. A matching entry in the CmLicensor/CmFirm.wbc file has to exist in both cases.
Option contains one of the following commands:
AddFirmItem calculates the sequence for adding a Firm Item into a CmDongle. Ctrl is pointing to a
CmProgramAddFirmItem class.
|
CmProgramAddFirmItem contains all needed information to add a Firm Item to a CmDongle. The following parameters of the structure are encrypted: musFirm ItemTypeEncrypted to mabSessionId (inclusive). This member defines a sequence of 64 bytes which are encrypted by AES-CBC. The key and the CBC initialization vector depends on the addressed Firm Code and of parameters of the addressed CmDongle. Syntax
Parameter FirmItemReference contains the reserved Firm Item Reference received with CmReserveFirmItem(). FirmItemTypePlain specifies the type of the Firm Item. The following flags using the global enum GlobalActionOption can be set:
PublicLicensorKey contains 64 bytes of ECC Licensor Key which is required to decrypt the specified data via the private Box Key, Serial Key, Firm Common Key and Serial Number of the addressed CmDongle. FirmItemTypeEncrypted (encrypted) specifies the type of the Firm Item. The following flags using the global enum GlobalActionOption can be set:
This value must be equal to FirmItemTypePlain! FirmAccessCounter (encrypted) contains the initial value of the Firm Access Counter. If this member is set to 0xFFFF (the recommended value), this counter is not decremented by an encryption which targets this counter. FirmUpdateCounter (encrypted) contains the initial value of the Firm Update Counter. The recommended value is 0. FirmPreciseTime (encrypted) contains the new Firm Precise Time in seconds since 1st January 2000, 0:00:00. If the value is not used, 0 must be specified, which sets this field to the Running Box Clock value. FirmKey (encrypted) contains the secret Firm Key, which has a fixed length of 32 bytes. SessionId (encrypted) contains the Session ID received with CmReserveFirmItem(). Text contains the text of the Firm Item Text of the Firm Item to program.
|
UpdateFirmItem calculates the sequence for updating a Firm Item in a CmDongle. Ctrl is pointing to a
CmProgramUpdateFirmItem class.
|
CmProgramUpdateFirmItem contains all needed parameters to update a Firm Item. Syntax
Parameter FirmItemReference contains the Firm Item Reference of the Firm Item. Ctrl specifies the flags, which parameters should be updated.
FirmAccessCounter (encrypted) contains the initial value of the Firm Access Counter. If this member is set to 0xFFFF (the recommended value), this counter is not decremented by an encryption which targets this counter. FirmUpdateCounter (encrypted) contains the initial value of the Firm Update Counter. The recommended value is 0. FirmPreciseTime (encrypted) contains the new Firm Precise Time in seconds since 1st January 2000, 0:00:00. If the value is not used, 0 must be specified, which sets this field to the Running Box Clock value. Text contains the text of the Firm Item Text of the Firm Item to program.
|
DeleteFirmItem calculates the sequence for deleting a Firm Item from a CmDongle. Ctrl is pointing to a
CmProgramDeleteFirmItem class.
|
CmProgramDeleteFirmItem contains all parameters needed for deleting a complete Firm Item. Syntax
Parameter FirmItemReference contains the Reference of the Firm Item which has to be removed. TrailingValidationBlock contains a 16-byte TVB (Trailing Validation Block), which must be valid to execute the operation. This TVB is ignored, if the addressed Firm Item was directly created with CmReserveFirmItem().
|
AddProductItem calculates the sequence for adding a Product Item into a CmDongle. Ctrl is pointing to a
CmProgramAddProductItem class.
|
CmProgramAddProductItem contains all needed information to add a Product Item to a CmDongle. All parameters are encrypted. Syntax
Parameter FirmItemReference (encrypted) contains the Reference of the Firm Item for which the Product Item is to be added. If this is 1, the IFI (Implicit Firm Item) is used. The addressed item must not have set the type. 0 is either not permitted. ProductItemSuccessorReference (encrypted) contains the Reference of the Product Item, which will be the successor of the newly added Product Item. If this value is 0, the Product Item is created at the end of the Product Item list. If musFirmItemReference specifies 0 for the IFI, the Product Item may be individually addressed by setting 2 for User Product Item (UPI). 1 for the Common Product Item (CPI) is not permitted because this must be always the first Product Item of the IFI.
|
UpdateProductItem calculates the sequence for updating a Product Item in a CmDongle. Ctrl is pointing to a
CmProgramUpdateProductItem class.
Class CmProgramUpdateProductItem CmProgramUpdateProductItem contains all needed parameters to update a Product Item. Syntax
Parameter FirmItemReference contains the reference of the Firm Item in which the Product Item should be updated. ProductItemReference contains the reference of the Product Item, which should be updated. Ctrl contains flags set internally by the driver.
|
DeleteProductItem calculates the sequence for deleting a Product Item in a CmDongle. Ctrl is pointing to a
CmProgramDeleteProductItem class.
Class CmProgramDeleteProductItem CmProgramDeleteProductItem contains the parameters for deleting a Product Item. Syntax
Parameter FirmItemReference contains the reference of the Firm Item in which the Product Item is deleted. ProductItemReference contains the reference of the Product Item which is to be deleted. TrailingValidationBlock contains the Trailing Validation Block (TVB) which checks, if the delete operation is valid.
|
SetBoxControl calculates the sequence for locking or unlocking a complete CmDongle. Ctrl is pointing to a
CmProgramBoxControl class.
|
CmProgramBoxControl contains the parameters to program the CmDongle control registers. Syntax
Parameter Ctrl specifies the kind of the programming of the CmDongle control registers. Absolute specifies that the control registers is programmed absolutely. Switch specifies that the control registers is programmed in the switch mode. IndicatorFlags contains the two bytes to program or switch.
|
SetBoxLock calculates the sequence for locking or unlocking a complete CmDongle. Ctrl is pointing to a
CmProgramBoxLock class.
|
CmProgramBoxLock contains all parameters to lock or unlock a CmDongle. Syntax
Parameter Ctrl specifies, if the CmDongle should be locked or unlocked. Lock specifies that the CmDongle should be locked. Unlock specifies that the CmDongle should be unlocked. UserKey contains the new User Common Key, which must match the CmDongle internally increased UKI (User Key Identifier) to lock the CmDongle against use.
|
SetFirmKey programs a Firm Key into an already programmed FSB entry in a CmDongle. Ctrl is a 32 element byte array. hcmse must be Entry Access.
SetUserKey tba.
AddEnableBlock calculates the sequence for adding a new Enable Block Item to a Firm Item. Ctrl is a
CmEnablingWriteAdd class.
|
UpdateEnableBlock calculates the sequence for updating an existing Enable Block Item in a Firm Item. Ctrl is a
CmEnablingWriteUpdate class.
|
DeleteEnableBlock calculates the sequence for deleting an existing Enable Block Item from a Firm Item. Ctrl is a
CmEnablingWriteDelete class.
|
CmEnablingWriteDelete describes the request sequence for deleting a Enable Block Item (EBI). command. Syntax
Parameter FirmItemReference contains the reference of the Firm Item which defines the Enabling Block. If this is 0, the IFI (Implicit Firm Item) is used. EnableBlockIndex contains the index of the Enabling Block which is deleted. This must be a value between 0 and 30. TrailingValidationBlock contains the Trailing Validation Block (TVB), which checks whether the delete operation is valid. This is an AES encryption of the SHA-256 hash of the preceding bytes.
|
AttachEnableBlock calculates the sequence for attaching an existing Enable Block Item in a Firm Item. Ctrl is a
CmEnablingWriteAttachDetach class.
Class CmEnablingWriteAttachDetach CmEnablingWriteAttachDetach describes the request sequence for attaching or detaching a Enable Block Item (EBI). Syntax
Parameter EnableLookupEntry contains the Enabling Lookup Entry which defines the attachment. EnableBlockIndex contains the index of the Enabling Block Item which is attached. The subsequent bytes are encrypted by AES-CBC or Triple-DES-CBC. They have a fixed length of 32 bytes. FirmItemReference contains the reference of the Firm Item in which the Enabling Block is attached. If this is 0, the IFI (Implicit Firm Item) is used. ProductItemReference contains the Reference of the Product Item in which the Enabling Block is attached. If the Enabling Block should be attached to the Firm Item, this member must be set to 0. If musFirmItemReference specifies 0, the Product Item may be individually addressed by setting Common Product Item (CPI) or User product item (UPI). FirmUpdateCounter contains the current value of the Firm Update Counter of the Firm Item which owns the Enabling Block. TrailingValidationBlock contains the TVB (Trailing Validation Block), which contains the current hash sequence (16 bytes) to validate that the sequence is correctly encrypted. Notes All parameters set by the user to this structure must be set in Little Endian format! Normally this must be noticed on Big Endian CPU's like the Apple Macintosh. On PC's (x86) the parameters (16 & 32 Bit) are stored in Little Endian so that the user has nothing to mentioned (Little/Big Endian).
|
DetachEnableBlock calculates the sequence for detaching an existing Enable Block Item in a Firm Item. Ctrl is a CmEnablingWriteAttachDetach class.
CreateItem points to a
CmCreateItem class containing additional information for sequence calculation. The parameter FirmUpdateCounter will contain the updated value after the programming sequence is calculated.
|
CmCreateItem contains data needed to calculate a programming sequence with a Firm Security Box (FSB) to add, update or delete an entry of a CmDongle. Syntax
Parameter BoxInfoUser contains the data of the CmDongle the entry should be add, update or delete. FirmCode contains the Firm Code to add, update or delete in an entry of a CmDongle. mulFirmItemType specifies the type of the Firm Item. The following flags using the global enum GlobalActionOption can be set:
FirmUpdateCounter contains the Firm Update Counter, if a Firm Item. This parameter must be set in all programming tasks except adding a Firm Item. ProductCode contains the Product Code for calculating a sequence to update or delete a Product Item. OemId contains the OEM ID for calculating a sequence to lock or unlock a CmDongle. FirmwareBuild contains the Firmware Build number for calculating a sequence to activate a Field Update.
|
Ctrl contains a class depending on the Ctrl flag (see above).
Return
The return value contains calculated sequence stored in Ctrl.
Notes
One or more calls of the function CmCreateProductItemOption have to be issued to build the full sequence to program a Product Item Option using the commands AddProductItem and UpdateProductItem. CmCreateSequence is the final call and receives the created sequence.
This function is for Licensor site because a FSB is needed. The only exception is the programming of a User's Product Item in the Implicit Firm Item (IFI). In this case the function can also be used on User site.
Not implemented.