Description
CmExecuteRemoteUpdate executes a firmware update of the CodeMeter Chip, as specified in the given Wibu Binary file, for the given box.
Syntax
int CmExecuteFieldUpdate (const CMBOXINFO * pcmBoxInfo, const unsigned char * pbWbb, unsigned int cbSize)
|
The FieldUpdate WBB File in pbWbb has to contain a single staged or a double staged FieldUpdate. It has to correspond with the mulFirmwareBuild and the musSiliconRevision of the specified box, as returned by CmGetInfo (..., CM_GEI_CHIPINFO, ...). The update's serial number range has to cover the mulSerialNumber of pcmBoxInfo. Only CodeMeter Chips of type 0x97 or larger (see musChipType in CMCHIPINFO ) can be updated with this function. |
Parameter
pcmBoxInfo contains the
CMBOXINFO structure that specifies the dongle which is to be updated.
Structure CMBOXINFO This structure contains information on a CmContainer. Syntax
Parameter mbMajorVersion contains the major version of the CmContainer. mbMinorVersion contains the minor version of the CmContainer. musBoxMask contains the box mask of the CmContainer. mulSerialNumber contains the serial number of the CmContainer. musBoxKeyId contains the ID of the used BoxKey of the CmContainer. musUserKeyId contains the ID of the used UserKey of the CmContainer. mabBoxPublicKey[CM_PUBLIC_KEY_LEN] contains the public Box Key of the CmContainer. mabSerialPublicKey[CM_PUBLIC_KEY_LEN] contains the public Serial Key of the CmContainer. mulReserve is reserved for future purposes. Notes The length of the mabBoxPublicKey and mabSerialPublicKey is 64 byte long. The used public key are currently 224 bits = 28 bytes long. In Elliptic Curve Cryptography the public key is a 2 dimensional point, so the x-value is stored in the first 28 bytes (0..27) and the y-value is store in byte 32..59.
|
pbWbb contains the pointer to the buffer with the WBB file.
cbSize contains the length of the WBB file.
Code
CMBOXINFO *cmbxinfo; CMBYTE *wbb; HCMSysEntry hsub; CMACCESS2 cmacc; int nb_boxes, success;
memset(&cmacc, 0, sizeof(cmacc)); cmacc.mflCtrl = CM_ACCESS_SUBSYSTEM; hsub = CmAccess2(CM_ACCESS_LOCAL, &cmacc);
if ((hsub != NULL) && (CmGetBoxes(hsub, CM_GB_DONGLE, cmbxinfo, 0) > 0)) { cmbxinfo = malloc(sizeof(CMBOXINFO) * (size_t)nb_boxes); CmGetBoxes(hsub, CM_GB_DONGLE, cmbxinfo, (size_t)nb_boxes); wbb = read_file_to_buffer(); success = CmExecuteFieldUpdate(&cmbxinfo[0], wbb, sizeof(*wbb)); if (success == 0) { printf("Error: %d\n", CmGetLastErrorCode()); } free(wbb); free(cmbxinfo); CmRelease(hsub); } |