Package net.i2p.data
Class SessionKey
- java.lang.Object
-
- net.i2p.data.SimpleDataStructure
-
- net.i2p.data.SessionKey
-
- All Implemented Interfaces:
DataStructure
- Direct Known Subclasses:
SessionKeyAndNonce
public class SessionKey extends SimpleDataStructure
Defines the SessionKey as defined by the I2P data structure spec. A session key is a 32 byte Integer. To create one with random data, use I2PAppContext.keyGenerator().generateSessionKey().- Author:
- jrandom
-
-
Field Summary
Fields Modifier and Type Field Description static SessionKey
INVALID_KEY
A key with all zeroes in the datastatic int
KEYSIZE_BYTES
-
Fields inherited from class net.i2p.data.SimpleDataStructure
_data
-
-
Constructor Summary
Constructors Constructor Description SessionKey()
SessionKey(byte[] data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getPreparedKey()
retrieve an internal representation of the session key, as known by the AES engine used.int
length()
The legal length of the byte array in this data structurevoid
setData(byte[] data)
Sets the data.void
setPreparedKey(Object obj)
-
Methods inherited from class net.i2p.data.SimpleDataStructure
calculateHash, equals, fromBase64, fromByteArray, getData, hashCode, read, readBytes, toBase64, toByteArray, toString, writeBytes
-
-
-
-
Field Detail
-
KEYSIZE_BYTES
public static final int KEYSIZE_BYTES
- See Also:
- Constant Field Values
-
INVALID_KEY
public static final SessionKey INVALID_KEY
A key with all zeroes in the data
-
-
Method Detail
-
length
public int length()
Description copied from class:SimpleDataStructure
The legal length of the byte array in this data structure- Specified by:
length
in classSimpleDataStructure
-
setData
public void setData(byte[] data)
Sets the data.- Overrides:
setData
in classSimpleDataStructure
- Parameters:
data
- 32 bytes, or null- Throws:
IllegalArgumentException
- if data is not the legal number of bytes (but null is ok)RuntimeException
- if data already set.
-
getPreparedKey
public Object getPreparedKey()
retrieve an internal representation of the session key, as known by the AES engine used. this can be reused safely
-
setPreparedKey
public void setPreparedKey(Object obj)
-
-