Datasheet
AN156
7 of 23
certificate to the data page. The current value of the write cycle counter is then incremented by 1, since
the data that it will be verified with is about to be written.
The certificate’s signature is produced on the coprocessor using the Sign Data command. The command
has a few variable inputs. The first of which is the data page that is to be signed. In this case, that page is
the actual account file (as constructed in Figure 9), which is written to the signing page of the
scratchpad. The rest of the inputs are all stored on the scratchpad of the coprocessor (referred to as the
coprocessor’s “signing scratchpad”). The first parameter stored on the scratchpad is the value of the write
cycle counter for the part. Next is the page number of the user token’s memory pages that hold the
account file. This is followed by least significant 56 bits of the user token’s address (64-bit Rom ID
minus the CRC8). The last parameter is the 3-byte constant challenge set when the coprocessor was
initialized.
Retrieving Write-Cycle Counter from DS1963S Figure 10
Setting up the Coprocessor’s Scratchpad for Data Signing Figure 11
SHAiButtonCopr Helper Method for Signing Data Figure 12
The helper method shown in Figure 12 can be broken down into the necessary container methods used to
implement signing data. Figure 13 illustrates the process for creating a data signature.
byte[] signScratchpad = new byte[32];
/* assign the wcc to the coprocessor’s “signing” scratchpad */
signScratchpad[8] = (wcc&0x0ff);
signScratchpad[9] = ((wcc>>=8)&0x0ff);
signScratchpad[10] = ((wcc>>=8)&0x0ff);
signScratchpad[11] = ((wcc>>=8)&0x0ff);
/* get the page number of the account file */
signScratchpad[12] = (byte)acctPage;
/* get the Rom ID of the user token */
System.arraycopy(owc18.getAddress(),0,signScratchpad, 13, 7);
/* get the signing challenge */
System.arraycopy(signingChlg, 0, signScratchpad, 20, 3);
/* sign the data with the coprocessor and return the mac right in the data */
copr.createDataSignature(acctData, signScratchpad, acctData, 2);
/* if using a DS1963S, need to get the value of the write-cycle counter. Doing a
* read authenticated page on the device will accomplish this. */
owc18.readAuthenticatedPage(acctPage, rawData, 0);
/* get the value of the write cycle counter for DS1963S user token only */
int wcc = (rawData[35]&0x0ff);
wcc = (wcc << 8) | (rawData[34]&0x0ff);
wcc = (wcc << 8) | (rawData[33]&0x0ff);
wcc = (wcc << 8) | (rawData[32]&0x0ff);
wcc += 1; // and increment it since we are going to write to the device










