Package gnu.java.zrtp.zidfile
Class ZidRecord
- java.lang.Object
-
- gnu.java.zrtp.zidfile.ZidRecord
-
public class ZidRecord extends Object
This class implements the ZID record. The ZID record holds data about a peer. According to ZRTP specification we use a ZID to identify a peer. ZRTP uses the RS (Retained Secret) data to construct shared secrets.NOTE: ZIDRecord has ZIDFile as friend. ZIDFile knows about the private data of ZIDRecord - please keep both classes synchronized.
- Author:
- Werner Dittmann <Werner.Dittmann@t-online.de>
-
-
Field Summary
Fields Modifier and Type Field Description static intIDENTIFIER_LENGTHstatic intRS_LENGTH
-
Constructor Summary
Constructors Constructor Description ZidRecord()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]getBuffer()byte[]getIdentifier()Get identifier.voidgetIdentifierInto(byte[] data)Retrieve identifier from buffer into a byte array.byte[]getMiTMData()longgetPosition()byte[]getRs1()Get RS1.byte[]getRs2()Get RS2.booleanisMITMKeyAvailable()booleanisOwnZIDRecord()booleanisRs1NotExpired()Check if RS1 is still valid Returns true if RS1 is still valid, false otherwise.booleanisRs1Valid()booleanisRs2NotExpired()Check if RS2 is still valid Returns true if RS2 is still valid, false otherwise.booleanisRs2Valid()booleanisSameIdentifier(byte[] data)Compare an identifier with identifier in this record.booleanisSameRs1(byte[] data)Compare RS1 with RS1 in this record.booleanisSameRs2(byte[] data)Compare RS2 with RS2 in this record.booleanisSasVerified()protected booleanisValid()static voidmain(String[] argv)voidresetMITMKeyAvailable()voidresetOwnZIDRecord()voidresetRs1Valid()voidresetRs2Valid()voidresetSasVerified()voidsetIdentifier(byte[] id)Set identifier.voidsetMiTMData(byte[] data)voidsetMITMKeyAvailable()voidsetNewRs1(byte[] data, int expire)Sets new RS1 data and associated expiration value.voidsetOwnZIDRecord()voidsetPosition(long position)voidsetRs1Valid()voidsetRs2Valid()voidsetSasVerified()protected voidsetValid()
-
-
-
Field Detail
-
IDENTIFIER_LENGTH
public static final int IDENTIFIER_LENGTH
- See Also:
- Constant Field Values
-
RS_LENGTH
public static final int RS_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
isValid
protected boolean isValid()
-
setValid
protected void setValid()
-
getBuffer
protected byte[] getBuffer()
-
setRs1Valid
public void setRs1Valid()
-
resetRs1Valid
public void resetRs1Valid()
-
isRs1Valid
public boolean isRs1Valid()
-
setRs2Valid
public void setRs2Valid()
-
resetRs2Valid
public void resetRs2Valid()
-
isRs2Valid
public boolean isRs2Valid()
-
setMITMKeyAvailable
public void setMITMKeyAvailable()
-
resetMITMKeyAvailable
public void resetMITMKeyAvailable()
-
isMITMKeyAvailable
public boolean isMITMKeyAvailable()
-
setOwnZIDRecord
public void setOwnZIDRecord()
-
resetOwnZIDRecord
public void resetOwnZIDRecord()
-
isOwnZIDRecord
public boolean isOwnZIDRecord()
-
setSasVerified
public void setSasVerified()
-
resetSasVerified
public void resetSasVerified()
-
isSasVerified
public boolean isSasVerified()
-
getIdentifierInto
public void getIdentifierInto(byte[] data)
Retrieve identifier from buffer into a byte array.- Parameters:
data- byte array that receives the identifier.
-
getIdentifier
public byte[] getIdentifier()
Get identifier.
-
setIdentifier
public void setIdentifier(byte[] id)
Set identifier.
-
getRs1
public byte[] getRs1()
Get RS1.
-
getRs2
public byte[] getRs2()
Get RS2.
-
isSameIdentifier
public boolean isSameIdentifier(byte[] data)
Compare an identifier with identifier in this record.- Parameters:
data- byte array that containing the identifier to compare with
-
isSameRs1
public boolean isSameRs1(byte[] data)
Compare RS1 with RS1 in this record.- Parameters:
data- byte array that containing the identifier to compare with
-
isSameRs2
public boolean isSameRs2(byte[] data)
Compare RS2 with RS2 in this record.- Parameters:
data- byte array that containing the identifier to compare with
-
setNewRs1
public void setNewRs1(byte[] data, int expire)Sets new RS1 data and associated expiration value. If the expiration value is >0 or -1 the method stores the new RS1. Before it stores the new RS1 it shifts the exiting RS1 into RS2 (together with its expiration time). Then it computes the expiration time of the and stores the result together with the new RS1. If the expiration value is -1 then this RS will never expire. If the expiration value is 0 then the expiration value of a stored RS1 is cleared and no new RS1 value is stored. Also RS2 is left unchanged.- Parameters:
data- Points to the new RS1 data.expire- The expiration interval in seconds. Default is -1.
-
isRs1NotExpired
public boolean isRs1NotExpired()
Check if RS1 is still valid Returns true if RS1 is still valid, false otherwise.- Returns:
- Returns true is RS1 is not expired (valid), false otherwise.
-
isRs2NotExpired
public boolean isRs2NotExpired()
Check if RS2 is still valid Returns true if RS2 is still valid, false otherwise.- Returns:
- Returns true is RS2 is not expired (valid), false otherwise.
-
getPosition
public long getPosition()
- Returns:
- the position
-
setPosition
public void setPosition(long position)
- Parameters:
position- the position to set
-
setMiTMData
public void setMiTMData(byte[] data)
-
getMiTMData
public byte[] getMiTMData()
-
main
public static void main(String[] argv)
-
-