Datasheet

AN156
13 of 23
3.0 SHA Applications with the 1-Wire Public Domain Kit
The solution for SHA Applications in the 1-Wire Public Domain Kit introduces a few new modules into
the development kit. Figure 24 is a listing of the new modules.
SHA API Functions Figure 24
SHA18.C (Device Layer)
ReadScratchpadSHA18 – Reads the scratchpad of DS1963S with CRC16 verification.
WriteScratchpadSHA18 – Writes the scratchpad of DS1963S with CRC16 verification.
CopyScratchpadSHA18 – Copies the scratchpad of DS1963S with verification.
MatchScratchpadSHA18 – Matches the contents of the scratchpad with given MAC.
EraseScratchpadSHA18 – Erases the scratch of DS1963S.
ReadAuthPageSHA18 – Performs a Read Authenticated Page command on DS1963S.
ReadMemoryPageSHA18 – Reads a page of memory from DS1963S.
WriteDataPageSHA18 – Writes a page of memory to DS1963S.
SHAFunction18 – Executes a given SHA function on DS1963S (i.e. Sign Data Page, Auth. Host)
InstallSystemSecret18Installs a master secret onto DS1963S.
BindSecretToiButton18 – Creates unique DS1963S secret with master secret and binding data.
CopySecretSHA18 – Copies 8-bytes of a SHA result into secret memory.
SHAIB.C (Protocol Layer)
SelectSHA – Accesses SHA Device on 1-Wire Net and forces overdrive.
FindNewSHA – Loops to find all SHA Devices on 1-Wire Net while blocking for arrivals.
FindUserSHA – Finds all SHA devices with the specified user account file.
FindCoprSHA – Finds all SHA devices with the specified coprocessor file.
GetCoprFromRawData – Loads service setup data from raw bytes, probably from a file.
CreateChallenge – Creates a random challenge using the Generate Challenge SHA command.
AnswerChallenge – Writes challenge to scratchpad of a user token and reads the account info.
VerifyAuthResponse – Verifies the authentication response of a user token.
CreateDataSignature – Creates a data signature using Sign Data Page SHA command.
SHADEBIT.C (Transaction Layer)
InstallServiceData – Formats the user token and installs a new certificate.
UpdateServiceData – Signs certificate information and writes it to the user token.
VerifyUser – Challenges user token with random challenge and verifies the response.
VerifyData – Verifies the certificate signature.
ExecuteTransaction – Debits user’s account balance and verifies that user received the update.
In the file SHAIB.H, there are 3 structures that define the coprocessor, the user, and the certificate. Figure
25 shows the format of the certificate.
struct DebitFile Figure 25
typedef struct { // See AN151 for certificate details
uchar fileLength; // length of this file
uchar dataTypeCode; // data type code – 0x01 for dynamic, 0x02 for static
uchar signature[20]; // 20-byte data signature for this certificate
uchar convFactor[2]; // country code and multiplier
uchar balanceBytes[3]; // account balance
uchar transID[2]; // transaction ID
uchar contPtr; // file continuation pointer
uchar crc16[2]; // crc16 of file
} DebitFile;