|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.onewire.application.sha.SHAiButtonUser | +--com.dalsemi.onewire.application.sha.SHAiButtonUser18
Class representing DS1963S (or DS2421), family-code 0x18, SHA iButtons as a user token in SHA Transactions.
SHATransaction
,
SHAiButtonCopr
,
SHAiButtonUser33
Constructor Summary | |
SHAiButtonUser18(byte[] coprBindData,
byte[] coprBindCode,
byte[] fileName,
int fileNameExt,
OneWireContainer18 owc,
boolean formatDevice,
byte[] authSecret)
Initialize a DS1963S as a fresh user iButton for a given SHA service. |
|
SHAiButtonUser18(byte[] coprBindCode,
byte[] fileName,
int fileNameExt,
OneWireContainer18 owc)
Creates a valid SHAiButtonUser object. |
|
SHAiButtonUser18(SHAiButtonCopr copr)
Creates a mostly unitialized SHAiButtonUser object. |
|
SHAiButtonUser18(SHAiButtonCopr copr,
OneWireContainer18 owc)
Creates a valid SHAiButtonUser object. |
|
SHAiButtonUser18(SHAiButtonCopr copr,
OneWireContainer18 owc,
boolean formatDevice,
byte[] authSecret)
Initialize a DS1963S as a fresh user iButton for a given SHA service. |
Method Summary | |
byte |
getAuthorizationCommand()
Returns a byte representing the appropriate authorization command for the coprocessor to use to authenticate this user. |
void |
getFullBindCode(byte[] l_fullBindCode,
int offset)
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. |
int |
getWriteCycleCounter()
Returns the value of the write cycle counter for the page where the account data is stored. |
boolean |
hasWriteCycleCounter()
Returns true if this buttons account data is stored
on a page that has a write cycle counter. |
boolean |
readAccountData(byte[] dataBuffer,
int offset)
Reads the account data off the SHAiButton using a standard READ command. |
int |
readAccountData(byte[] chlg,
int chlgStart,
byte[] dataBuffer,
int dataStart,
byte[] mac,
int macStart)
Reads the account data off the SHAiButton using a READ_AUTHENTICATE command. |
boolean |
setiButton18(OneWireContainer18 owc)
Modifies this SHA iButton so that it refers to another DS1963S container. |
boolean |
setiButtonUser(byte[] address)
Modifies this SHA iButton so that it refers to another device. |
boolean |
setiButtonUser(DSPortAdapter adapter,
byte[] address)
Modifies this SHA iButton so that it refers to another 1963S. |
boolean |
writeAccountData(byte[] dataBuffer,
int offset)
Writes the account data to the SHAiButton. |
Methods inherited from class com.dalsemi.onewire.application.sha.SHAiButtonUser |
getAccountFilename, getAccountPageNumber, getAddress, getAddress, getAddress, getForceOverdrive, refreshDevice, setForceOverdrive, toString |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SHAiButtonUser18(SHAiButtonCopr copr, OneWireContainer18 owc, boolean formatDevice, byte[] authSecret) throws OneWireException, OneWireIOException
Initialize a DS1963S 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.
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.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
adapterSHAiButtonUser18(SHAiButtonCopr,OneWireContainer18)
,
SHAiButtonUser18(SHAiButtonCopr)
public SHAiButtonUser18(byte[] coprBindData, byte[] coprBindCode, byte[] fileName, int fileNameExt, OneWireContainer18 owc, boolean formatDevice, byte[] authSecret) throws OneWireException, OneWireIOException
Initialize a DS1963S 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.
coprBindData
- The Coprocessor Bind Data, used to create a unique
secret for this user token.coprBindCode
- The Coprocessor Bind Code without the user-specific
information, used to create a unique secret for this user token.fileName
- The file name for the account info.fileNameExt
- The file extenstion for the account infoowc
- 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.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
adapterSHAiButtonUser18(SHAiButtonCopr,OneWireContainer18)
,
SHAiButtonUser18(SHAiButtonCopr)
public SHAiButtonUser18(SHAiButtonCopr copr, OneWireContainer18 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".
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.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
adapterSHAiButtonUser18(SHAiButtonCopr,OneWireContainer18,boolean,byte[])
,
SHAiButtonUser18(SHAiButtonCopr)
public SHAiButtonUser18(byte[] coprBindCode, byte[] fileName, int fileNameExt, OneWireContainer18 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".
coprBindCode
- The Coprocessor Bind Code without the user-specific
information.fileName
- The file name of the account filefileNameExt
- The file extenstion of the account fileowc
- The DS1963S iButton that this object will refer to.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
adapterSHAiButtonUser18(SHAiButtonCopr,OneWireContainer18,boolean,byte[])
,
SHAiButtonUser18(SHAiButtonCopr)
public SHAiButtonUser18(SHAiButtonCopr copr)
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.
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.SHAiButtonUser18(SHAiButtonCopr,OneWireContainer18,boolean,byte[])
,
SHAiButtonUser18(SHAiButtonCopr)
Method Detail |
public boolean setiButton18(OneWireContainer18 owc) throws OneWireException, OneWireIOException
Modifies this SHA iButton so that it refers to another DS1963S 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.
owc
- The OneWireContainer18
this object will refer to.true
if a valid account service file exists on
this OneWireContainer18
.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
adapterpublic boolean setiButtonUser(DSPortAdapter adapter, byte[] address) throws OneWireException, OneWireIOException
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.
setiButtonUser
in class SHAiButtonUser
adapter
- The adapter that the device can be found on.address
- The address of the 1-Wire devicetrue
if a valid account service file exists on
this OneWireContainer18
.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
adapterpublic boolean setiButtonUser(byte[] address) throws OneWireException, OneWireIOException
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.
setiButtonUser
in class SHAiButtonUser
address
- The address of the 1-Wire devicetrue
if a valid account service file exists on
this OneWireContainer18
.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
adapterpublic int getWriteCycleCounter() throws OneWireException, OneWireIOException
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.
getWriteCycleCounter
in class SHAiButtonUser
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
adapterpublic boolean hasWriteCycleCounter()
true
if this buttons account data is stored
on a page that has a write cycle counter.hasWriteCycleCounter
in class SHAiButtonUser
true
if account page has write cycle counter.public void getFullBindCode(byte[] l_fullBindCode, int offset)
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:
(bindCode+0), (bindCode+1), (bindCode+2), (bindCode+3), (svcPageNum), (deviceAN+0), (deviceAN+1), (deviceAN+2), (deviceAN+3), (deviceAN+4), (deviceAN+5), (deviceAN+6), (bindCode+4), (bindCode+5), (bindCode+6)
getFullBindCode
in class SHAiButtonUser
bindCode
- the 7-byte binding code from coprocessor's service filefullBindCode
- 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.public byte getAuthorizationCommand()
Returns a byte representing the appropriate authorization command for the coprocessor to use to authenticate this user. For a DS1963S, the authentication command is VALIDATE_PAGE.
getAuthorizationCommand
in class SHAiButtonUser
public boolean writeAccountData(byte[] dataBuffer, int offset) throws OneWireException, OneWireIOException
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.
writeAccountData
in class SHAiButtonUser
dataBuffer
- the buffer to copy the account data fromoffset
- the index into the buffer where copying should beginOneWireIOException
- 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
adapterpublic boolean readAccountData(byte[] dataBuffer, int offset) throws OneWireException, OneWireIOException
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.
readAccountData
in class SHAiButtonUser
dataBuffer
- the buffer to copy the account data intooffset
- the index into the buffer where copying should beginOneWireIOException
- 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
adapterpublic int readAccountData(byte[] chlg, int chlgStart, byte[] dataBuffer, int dataStart, byte[] mac, int macStart) throws OneWireException, OneWireIOException
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
readAccountData
in class SHAiButtonUser
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 intodataStart
- the index into the buffer where copying should beginmac
- the buffer to copy the resulting Message Authentication CodemacStart
- the index into the mac buffer to start copyingOneWireIOException
- 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |