java.lang.Object
net.i2p.data.SimpleDataStructure
net.i2p.data.PublicKey
net.i2p.router.crypto.ratchet.NextSessionKey
- All Implemented Interfaces:
DataStructure
X25519 public key with identifier for next session key exchange in ratchet protocol.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intWhich key in the sequence this one is.private final booleanTrue when this key is asked for, not offered.private final booleanTrue for the key sent by the other side.Fields inherited from class PublicKey
KEYSIZE_BYTESModifier and TypeFieldDescriptionstatic final intDefault key size in bytes (256 for ElGamal).Fields inherited from class SimpleDataStructure
_dataConstructor Summary
ConstructorsConstructorDescriptionNextSessionKey(byte[] data, int id, boolean isReverse, boolean isRequest) Create a NextSessionKey from raw key data.NextSessionKey(int id, boolean isReverse, boolean isRequest) Create a NextSessionKey with null data, for acks/requests only.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanEqual if the ratchet and message number match.intgetID()Which key in the sequence this one is.inthashCode()Hash code combining the id with the reverse and request flags.booleanWhether this is a request.booleanWhether this is a reverse session.toString()String representation showing type and data size.Methods inherited from class PublicKey
clearCache, create, create, getPadding, getType, getUnknownTypeCode, lengthModifier and TypeMethodDescriptionstatic voidClears the public key cache.static PublicKeycreate(byte[] data, int off) Pull from cache or return new.static PublicKeycreate(InputStream in) Pull from cache or return new.byte[]getPadding(KeyCertificate kcert) Padding portion of this (type 0) PK based on the Key Cert type given, if any.getType()Encryption type of this public key.intType code for unknown encryption types.intlength()Key length in bytes, determined by the encryption type.Methods inherited from class SimpleDataStructure
calculateHash, fromBase64, fromByteArray, getData, read, readBytes, setData, toBase64, toByteArray, writeBytesModifier and TypeMethodDescriptionSHA256 hash of the byte array, or null if data is null.voidfromBase64(String data) Data from the base64 string.voidfromByteArray(byte[] data) Does the same thing asSimpleDataStructure.setData(byte[])but null not allowed.byte[]getData()Data reference (not a copy).protected intread(InputStream in, byte[] target) Repeated reads until the buffer is full or IOException is thrown.voidreadBytes(InputStream in) Data read from the stream.voidsetData(byte[] data) The byte array data, or null.toBase64()Renders the structure into modified base 64 notation.byte[]Same thing as getData().voidwriteBytes(OutputStream out) Writes the data to the output stream.
Field Details
_id
private final int _idWhich key in the sequence this one is._isReverse
private final boolean _isReverseTrue for the key sent by the other side._isRequest
private final boolean _isRequestTrue when this key is asked for, not offered.
Constructor Details
NextSessionKey
public NextSessionKey(byte[] data, int id, boolean isReverse, boolean isRequest) Create a NextSessionKey from raw key data.- Parameters:
data- non-nullid- the session identifierisReverse- whether this is a reverse sessionisRequest- whether this is a request
NextSessionKey
public NextSessionKey(int id, boolean isReverse, boolean isRequest) Create a NextSessionKey with null data, for acks/requests only. Type will be ElG but doesn't matter. Don't call setData().- Parameters:
id- the session identifierisReverse- whether this is a reverse sessionisRequest- whether this is a request
Method Details
getID
public int getID()Which key in the sequence this one is.- Returns:
- the id as carried on the wire, 0-65535
isReverse
public boolean isReverse()Whether this is a reverse session.- Returns:
- true if this is a reverse session
isRequest
public boolean isRequest()Whether this is a request.- Returns:
- true if this is a request
hashCode
equals
toString