SHAiButtonUser33 Class Reference

Inherits com::dalsemi::onewire::application::sha::SHAiButtonUser.

List of all members.


Detailed Description

Class representing DS1961S (or DS2432), family-code 0x33, SHA iButtons as a user token in SHA Transactions.

See also:
SHATransaction

SHAiButtonCopr

SHAiButtonUser18

Version:
1.00
Author:
SKH

Public Member Functions

 SHAiButtonUser33 (SHAiButtonCopr copr, OneWireContainer33 owc, boolean formatDevice, byte[] authSecret) throws OneWireException, OneWireIOException
 SHAiButtonUser33 (byte[] coprBindCode, byte[] fileName, int fileNameExt, OneWireContainer33 owc, boolean formatDevice, byte[] authSecret) throws OneWireException, OneWireIOException
 SHAiButtonUser33 (SHAiButtonCopr copr, SHAiButtonCopr authCopr, OneWireContainer33 owc) throws OneWireException, OneWireIOException
 SHAiButtonUser33 (byte[] coprBindCode, byte[] fileName, int fileNameExt, OneWireContainer33 owc) throws OneWireException, OneWireIOException
 SHAiButtonUser33 (SHAiButtonCopr copr, SHAiButtonCopr authCopr)
synchronized boolean setiButton33 (OneWireContainer33 owc) throws OneWireException, OneWireIOException
synchronized boolean setiButtonUser (DSPortAdapter adapter, byte[] address) throws OneWireException, OneWireIOException
synchronized boolean setiButtonUser (byte[] address) throws OneWireException, OneWireIOException
synchronized int getWriteCycleCounter () throws OneWireException, OneWireIOException
synchronized boolean hasWriteCycleCounter ()
void getFullBindCode (byte[] l_fullBindCode, int offset)
byte getAuthorizationCommand ()
synchronized boolean writeAccountData (byte[] dataBuffer, int offset) throws OneWireException, OneWireIOException
synchronized boolean readAccountData (byte[] dataBuffer, int offset) throws OneWireException, OneWireIOException
synchronized int readAccountData (byte[] chlg, int chlgStart, byte[] dataBuffer, int dataStart, byte[] mac, int macStart) throws OneWireException, OneWireIOException
boolean refreshDevice () throws OneWireException,OneWireIOException
 Refreshes eeprom SHA devices in case of weakly-programmed bits on the account page.

Protected Member Functions

 SHAiButtonUser33 ()

Protected Attributes

OneWireContainer33 ibc33 = null
 Reference to the OneWireContainer.
SHAiButtonCopr copr = null
 Must maintain a reference to the coprocessor for generating the COPY_SCRATCHPAD authentication.

Constructor & Destructor Documentation

SHAiButtonUser33 (  )  [protected]

No default constructor for user apps. At bare minimum, you need a reference to a SHAiButtonCopr for the transaction system and a SHAiButtonCopr for generating the DS1961S write authorization for the copy-scratchpad command.

Note: These can be the same coprocessor if you're transaction system is using unsigned transaction data.

See also:
SHAiButtonUser33(SHAiButtonCopr,OneWireContainer33,boolean,byte[])

SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr,OneWireContainer33)

SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr)

SHAiButtonUser33 ( SHAiButtonCopr  copr,
OneWireContainer33  owc,
boolean  formatDevice,
byte[]  authSecret 
) throws OneWireException, OneWireIOException

Initialize a DS1961S as a fresh user iButton for a given SHA service. This constructor not only creates the service file for the user iButton using the TMEX file structure, but it also installs the master authentication secret and binds it to the iButton (making it unique for a particular button). Optionally, the device can be formatted before the service file is installed.

Note: With this constructor, the master secret is installed and bound to the iButton, so the final secret is none by the object. For that reason, a hardware coprocessor is not necessary for generating the write-authorization MAC.

Parameters:
copr The SHAiButtonCopr to which the user object is tied. This Coprocessor contains the necessary binding code and service filename, necessary for both locating a user and recreating his unique secret.
owc The DS1963S iButton that this object will refer to.
formatDevice If true, the TMEX filesystem will be formatted before the account service file is created.
authSecret The master authentication secret for the systm.
Exceptions:
OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
OneWireException on a communication or setup error with the 1-Wire adapter
See also:
SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr,OneWireContainer33)

SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr)

SHAiButtonUser33 ( byte[]  coprBindCode,
byte[]  fileName,
int  fileNameExt,
OneWireContainer33  owc,
boolean  formatDevice,
byte[]  authSecret 
) throws OneWireException, OneWireIOException

Initialize a DS1961S as a fresh user iButton for a given SHA service. This constructor not only creates the service file for the user iButton using the TMEX file structure, but it also installs the master authentication secret and binds it to the iButton (making it unique for a particular button). Optionally, the device can be formatted before the service file is installed.

Note: With this constructor, the master secret is installed and bound to the iButton, so the final secret is none by the object. For that reason, a hardware coprocessor is not necessary for generating the write-authorization MAC.

Parameters:
coprBindCode The Coprocessor Bind Code without the information.
fileName The file name from the Coprocessor.
fileNameExt The file extenstion from the Coprocessor
owc The DS1963S iButton that this object will refer to.
formatDevice If true, the TMEX filesystem will be formatted before the account service file is created.
authSecret The master authentication secret for the systm.
Exceptions:
OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
OneWireException on a communication or setup error with the 1-Wire adapter
See also:
SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr,OneWireContainer33)

SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr)

Creates a valid SHAiButtonUser object. If the service file, whose name is taken from the SHAiButtonCopr, is not found on the user iButton, a OneWireException is thrown with the message "Invalid SHA user".

Note: The same coprocessor can be used for write-authorization as authentication if you're transaction system is using unsigned transaction data.

Parameters:
copr The SHAiButtonCopr to which the user object is tied. This Coprocessor contains the necessary binding code and service filename, necessary for both locating a user and recreating his unique secret.
authCopr The SHAiButtonCopr used to generate the write-authorization MAC for the copy-scratchpad command of the DS1961S.
owc The DS1961S iButton that this object will refer to.
Exceptions:
OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
OneWireException on a communication or setup error with the 1-Wire adapter
See also:
SHAiButtonUser33(SHAiButtonCopr,OneWireContainer33,boolean,byte[])

SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr)

SHAiButtonUser33 ( byte[]  coprBindCode,
byte[]  fileName,
int  fileNameExt,
OneWireContainer33  owc 
) throws OneWireException, OneWireIOException

Creates a valid SHAiButtonUser object. If the service file, whose name is taken from the SHAiButtonCopr, is not found on the user iButton, a OneWireException is thrown with the message "Invalid SHA user".

Note: The same coprocessor can be used for write-authorization as authentication if you're transaction system is using unsigned transaction data.

Parameters:
coprBindCode The Coprocessor Bind Code without the information.
fileName The file name from the Coprocessor.
fileNameExt The file extenstion from the Coprocessor
authCopr The SHAiButtonCopr used to generate the write-authorization MAC for the copy-scratchpad command of the DS1961S.
owc The DS1961S iButton that this object will refer to.
Exceptions:
OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
OneWireException on a communication or setup error with the 1-Wire adapter
See also:
SHAiButtonUser33(SHAiButtonCopr,OneWireContainer33,boolean,byte[])

SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr)

Creates a mostly unitialized SHAiButtonUser object. This constructor merely copies the coprocessors 7 byte binding code into a local cache and stores the name of the account service file used for all user iButtons.

Since this constructor leaves data unitialized, you should be very careful with the use of it. It is expected that after calling this constructor, the user will call setiButton to finish the initialization process. On memory-starved platforms, this should help optimize memory usage.

Note: The same coprocessor can be used for write-authorization as authentication if you're transaction system is using unsigned transaction data.

Parameters:
copr The SHAiButtonCopr to which the user object is tied. This Coprocessor contains the necessary binding code and service filename, necessary for both locating a user and recreating his unique secret.
authCopr The SHAiButtonCopr used to generate the write-authorization MAC for the copy-scratchpad command of the DS1961S.
See also:
SHAiButtonUser33(SHAiButtonCopr,OneWireContainer33,boolean,byte[])

SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr,OneWireContainer33)


Member Function Documentation

synchronized boolean setiButton33 ( OneWireContainer33  owc  )  throws OneWireException, OneWireIOException

Modifies this SHA iButton so that it refers to another DS1961S container. This function only copies the reference to the OneWireContainer, copes the reference to it's 1-Wire address, and then asserts that the iButton contains a valid acccount info file associated with the system.

Parameters:
owc The OneWireContainer33 this object will refer to.
Returns:
true if a valid account service file exists on this OneWireContainer33.
Exceptions:
OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
OneWireException on a communication or setup error with the 1-Wire adapter

synchronized boolean setiButtonUser ( DSPortAdapter  adapter,
byte[]  address 
) throws OneWireException, OneWireIOException [virtual]

Modifies this SHA iButton so that it refers to another 1963S. If this object already has an appropriate instance of OneWireContainer, that instance is updated with the new address.

Parameters:
adapter The adapter that the device can be found on.
address The address of the 1-Wire device
Returns:
true if a valid account service file exists on this OneWireContainer18.
Exceptions:
OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
OneWireException on a communication or setup error with the 1-Wire adapter

Implements SHAiButtonUser.

synchronized boolean setiButtonUser ( byte[]  address  )  throws OneWireException, OneWireIOException [virtual]

Modifies this SHA iButton so that it refers to another device. If this object does not already has an appropriate instance of OneWireContainer, it returns false immediately, because there is no adapter info available. Otherwise, it reuses the same adapter.

Parameters:
address The address of the 1-Wire device
Returns:
true if a valid account service file exists on this OneWireContainer18.
Exceptions:
OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
OneWireException on a communication or setup error with the 1-Wire adapter

Implements SHAiButtonUser.

synchronized int getWriteCycleCounter (  )  throws OneWireException, OneWireIOException [virtual]

Returns the value of the write cycle counter for the page where the account data is stored. If the write cycle counter has ever been retrieved, this returns the cached value. Otherwise, this method reads the value from the part.

Since the DS1961S has no "write cycle counters", this function always returns -1.

Returns:
the value of the write cycle counter for the account data page.
Exceptions:
OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
OneWireException on a communication or setup error with the 1-Wire adapter

Implements SHAiButtonUser.

synchronized boolean hasWriteCycleCounter (  )  [virtual]

Returns true if this buttons account data is stored on a page that has a write cycle counter.

Since the DS1961S has no "write cycle counters", this function always returns false.

Returns:
true if account page has write cycle counter.

Implements SHAiButtonUser.

void getFullBindCode ( byte[]  l_fullBindCode,
int  offset 
) [virtual]

This function creates the full 15-byte binding data for the coprocessor to use to recreate this user's secret on the copr's workspace page. This function is located in the SHAiButtonUser class to support binding codes for user buttons who use alternate techniques (such as the DS1961S) for secret computation.

For the DS1963S user iButton, the format of the full bind code is as follows:

      ( 0x0000FF ), ( 0x0000FF ), ( 0x0000FF ), ( 0x0000FF ),
      (svcPageNum), (deviceAN+0), (deviceAN+1), (deviceAN+2),
      (deviceAN+3), (deviceAN+4), (deviceAN+5), (deviceAN+6),
      ( 0x0000FF ), ( 0x0000FF ), ( 0x0000FF )
   

Parameters:
bindCode the 7-byte binding code from coprocessor's service file
fullBindCode the 15-byte full binding code to to be copied into the coprocessor's scratchpad. There should be 15 bytes available starting from the offset.
offset the offset into fullBindCode where copying should begin.

Implements SHAiButtonUser.

byte getAuthorizationCommand (  )  [virtual]

Returns a byte representing the appropriate authorization command for the coprocessor to use to authenticate this user. For a DS1961S, the authentication command is AUTH_HOST.

Returns:
byte indicating appropriate command for authenticating user

Implements SHAiButtonUser.

synchronized boolean writeAccountData ( byte[]  dataBuffer,
int  offset 
) throws OneWireException, OneWireIOException [virtual]

Writes the account data to the SHAiButton. First, this function asserts that the account page number is known. The account data is copied from dataBuffer starting at the offset. If there are less than 32 bytes available to copy, this function only copies the bytes that are available.

Note that for the DS1961S user button, an authorization MAC must be generated for the copy-scratchpad command. Since the scratchpad is only 8 bytes long, this must be done 4 times to write a page of data. So, this function only writes (in 8 byte blocks) the bytes that have changed.

Parameters:
dataBuffer the buffer to copy the account data from
offset the index into the buffer where copying should begin
Returns:
whether or not the data write succeeded
Exceptions:
OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.
OneWireException on a communication or setup error with the 1-Wire adapter

Implements SHAiButtonUser.

synchronized boolean readAccountData ( byte[]  dataBuffer,
int  offset 
) throws OneWireException, OneWireIOException [virtual]

Reads the account data off the SHAiButton using a standard READ command. First, this function asserts that the account page number is known as well as the length of the account file. The 32 byte account data page is copied into dataBuffer starting at the given offset.

Parameters:
dataBuffer the buffer to copy the account data into
offset the index into the buffer where copying should begin
Returns:
whether or not the read was successful

Implements SHAiButtonUser.

synchronized int readAccountData ( byte[]  chlg,
int  chlgStart,
byte[]  dataBuffer,
int  dataStart,
byte[]  mac,
int  macStart 
) throws OneWireException, OneWireIOException [virtual]

Reads the account data off the SHAiButton using a READ_AUTHENTICATE command. First, this function asserts that the account page number is known as well as the length of the account file. Then it copies the 3 byte challenge to the scratchpad before sending the command for READ_AUTHENTICATE. The 32 byte account data page is copied into dataBuffer starting at dataStart.

In addition to the account data, this function also returns a calculated MAC. The MAC requires 20 bytes after the start index. The return value is the write cycle counter value for the account data page

Parameters:
chlg the buffer containing a 3-byte random challenge.
chlgStart the index into the buffer where the 3 byte challenge begins.
dataBuffer the buffer to copy the account data into
dataStart the index into the buffer where copying should begin
mac the buffer to copy the resulting Message Authentication Code
macStart the index into the mac buffer to start copying
Returns:
the value of the write cycle counter for the page

Implements SHAiButtonUser.

boolean refreshDevice (  )  throws OneWireException,OneWireIOException

Refreshes eeprom SHA devices in case of weakly-programmed bits on the account page.

Returns:
true if the refresh was successful

Reimplemented from SHAiButtonUser.


Member Data Documentation

SHAiButtonCopr copr = null [protected]

Must maintain a reference to the coprocessor for generating the COPY_SCRATCHPAD authentication.

This is what is referred to as the write-authorization coprocessor.


The documentation for this class was generated from the following file:

Generated on Thu Aug 28 15:42:31 2008 for 1-Wire API for .NET by  doxygen 1.5.6