Package net.i2p.router.crypto.ratchet
Class RatchetTagSet
- java.lang.Object
-
- net.i2p.router.crypto.ratchet.RatchetTagSet
-
- All Implemented Interfaces:
TagSetHandle
class RatchetTagSet extends Object implements TagSetHandle
A tagset class for one direction, either inbound or outbound. For outbound, uses very little memory. Tags and keys are generated on demand. See proposal 144. For inbound, generates the tags in advance, maintaining minSize lookahead. Keys are generated as required. Caller must synch on all methods.- Since:
- 0.9.44
-
-
Constructor Summary
Constructors Constructor Description RatchetTagSet(HKDF hkdf, HandshakeState state, SessionKey rootKey, SessionKey data, long date, int id)
Outbound NSR TagsetRatchetTagSet(HKDF hkdf, SessionKey rootKey, SessionKey data, long date, int id)
Outbound ES TagsetRatchetTagSet(HKDF hkdf, SessionTagListener lsnr, HandshakeState state, SessionKey rootKey, SessionKey data, long date, int id, int minSize, int maxSize)
Inbound NSR TagsetRatchetTagSet(HKDF hkdf, SessionTagListener lsnr, PublicKey remoteKey, SessionKey rootKey, SessionKey data, long date, int id, int minSize, int maxSize)
Inbound ES Tagset
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
SessionKeyAndNonce
consume(RatchetSessionTag tag)
inbound onlyRatchetSessionTag
consumeNext()
For outbound only.SessionKeyAndNonce
consumeNextKey()
For outbound only.boolean
getAcked()
For inbound, returns true after first consume() call.SessionKey
getAssociatedKey()
The identifier for the session.long
getCreated()
For inbound and outbound: creation timelong
getDate()
For inbound and outbound: last used timeHandshakeState
getHandshakeState()
For inbound/outbound NSR only, else null.int
getID()
for debuggingint
getOriginalSize()
for debuggingPublicKey
getRemoteKey()
The far-end's public key.int
remaining()
tags remainingvoid
setAcked()
For outbound only, call when we can use it.void
setDate(long when)
For inbound and outbound: last used timeint
size()
unused tags generatedString
toString()
-
-
-
Constructor Detail
-
RatchetTagSet
public RatchetTagSet(HKDF hkdf, HandshakeState state, SessionKey rootKey, SessionKey data, long date, int id)
Outbound NSR Tagset- Parameters:
date
- For outbound: creation time
-
RatchetTagSet
public RatchetTagSet(HKDF hkdf, SessionKey rootKey, SessionKey data, long date, int id)
Outbound ES Tagset- Parameters:
date
- For outbound: creation time
-
RatchetTagSet
public RatchetTagSet(HKDF hkdf, SessionTagListener lsnr, HandshakeState state, SessionKey rootKey, SessionKey data, long date, int id, int minSize, int maxSize)
Inbound NSR Tagset- Parameters:
date
- For inbound: creation time
-
RatchetTagSet
public RatchetTagSet(HKDF hkdf, SessionTagListener lsnr, PublicKey remoteKey, SessionKey rootKey, SessionKey data, long date, int id, int minSize, int maxSize)
Inbound ES Tagset- Parameters:
date
- For inbound: creation time
-
-
Method Detail
-
clear
public void clear()
-
getRemoteKey
public PublicKey getRemoteKey()
The far-end's public key. Valid for NSR and inbound ES tagsets. Returns null for outbound ES tagsets.
-
getAssociatedKey
public SessionKey getAssociatedKey()
The identifier for the session. Not used for cryptographic operations after setup.
-
getHandshakeState
public HandshakeState getHandshakeState()
For inbound/outbound NSR only, else null. MUST be cloned before processing NSR.
-
getDate
public long getDate()
For inbound and outbound: last used time
-
setDate
public void setDate(long when)
For inbound and outbound: last used time
-
getCreated
public long getCreated()
For inbound and outbound: creation time
-
getOriginalSize
public int getOriginalSize()
for debugging
-
size
public int size()
unused tags generated- Returns:
- 0 for outbound
-
remaining
public int remaining()
tags remaining- Returns:
- 0 - 65535
-
consume
public SessionKeyAndNonce consume(RatchetSessionTag tag)
inbound only- Returns:
- associated SessionKey or null if not found.
-
consumeNext
public RatchetSessionTag consumeNext()
For outbound only. Call before consumeNextKey();- Returns:
- a tag or null if we ran out
-
consumeNextKey
public SessionKeyAndNonce consumeNextKey()
For outbound only. Call after consumeNextTag();- Returns:
- a key and nonce, non-null
-
setAcked
public void setAcked()
For outbound only, call when we can use it.
-
getAcked
public boolean getAcked()
For inbound, returns true after first consume() call. For outbound, returns true after set.
-
getID
public int getID()
for debugging
-
-