Class SessionRecord
- java.lang.Object
-
- org.signal.libsignal.protocol.state.SessionRecord
-
- All Implemented Interfaces:
NativeHandleGuard.Owner
public class SessionRecord extends java.lang.Object implements NativeHandleGuard.Owner
A SessionRecord encapsulates the state of an ongoing session.
-
-
Constructor Summary
Constructors Constructor Description SessionRecord()SessionRecord(byte[] serialized)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidarchiveCurrentState()Move the current SessionState into the list of "previous" session states, and replace the current SessionState with a fresh reset instance.booleancurrentRatchetKeyMatches(ECPublicKey key)protected voidfinalize()static SessionRecordfromSingleSessionState(byte[] sessionStateBytes)byte[]getAliceBaseKey()IdentityKeygetLocalIdentityKey()intgetLocalRegistrationId()byte[]getReceiverChainKeyValue(ECPublicKey senderEphemeral)IdentityKeygetRemoteIdentityKey()intgetRemoteRegistrationId()byte[]getSenderChainKeyValue()intgetSessionVersion()booleanhasSenderChain()static SessionRecordinitializeAliceSession(IdentityKeyPair identityKey, ECKeyPair baseKey, IdentityKey theirIdentityKey, ECPublicKey theirSignedPreKey, ECPublicKey theirRatchetKey)static SessionRecordinitializeBobSession(IdentityKeyPair identityKey, ECKeyPair signedPreKey, ECKeyPair ephemeralKey, IdentityKey theirIdentityKey, ECPublicKey theirBaseKey)booleanneedsPniSignature()Returns true if this session was initialized needing a PNI signature and has not received a reply.byte[]serialize()voidsetNeedsPniSignature(boolean needsPniSignature)Marks whether this session needs a PNI signature included in outgoing messages.longunsafeNativeHandleWithoutGuard()
-
-
-
Constructor Detail
-
SessionRecord
public SessionRecord()
-
SessionRecord
public SessionRecord(byte[] serialized) throws InvalidMessageException- Throws:
InvalidMessageException
-
-
Method Detail
-
finalize
protected void finalize()
- Overrides:
finalizein classjava.lang.Object
-
fromSingleSessionState
public static SessionRecord fromSingleSessionState(byte[] sessionStateBytes) throws InvalidMessageException
- Throws:
InvalidMessageException
-
archiveCurrentState
public void archiveCurrentState()
Move the current SessionState into the list of "previous" session states, and replace the current SessionState with a fresh reset instance.
-
getSessionVersion
public int getSessionVersion()
-
getRemoteRegistrationId
public int getRemoteRegistrationId()
-
getLocalRegistrationId
public int getLocalRegistrationId()
-
getRemoteIdentityKey
public IdentityKey getRemoteIdentityKey()
-
getLocalIdentityKey
public IdentityKey getLocalIdentityKey()
-
hasSenderChain
public boolean hasSenderChain()
-
needsPniSignature
public boolean needsPniSignature()
Returns true if this session was initialized needing a PNI signature and has not received a reply.Precondition: `this.hasSenderChain()`
-
setNeedsPniSignature
public void setNeedsPniSignature(boolean needsPniSignature)
Marks whether this session needs a PNI signature included in outgoing messages.Precondition: `this.hasSenderChain()`
-
currentRatchetKeyMatches
public boolean currentRatchetKeyMatches(ECPublicKey key)
-
serialize
public byte[] serialize()
- Returns:
- a serialized version of the current SessionRecord.
-
getReceiverChainKeyValue
public byte[] getReceiverChainKeyValue(ECPublicKey senderEphemeral)
-
getSenderChainKeyValue
public byte[] getSenderChainKeyValue()
-
getAliceBaseKey
public byte[] getAliceBaseKey()
-
initializeAliceSession
public static SessionRecord initializeAliceSession(IdentityKeyPair identityKey, ECKeyPair baseKey, IdentityKey theirIdentityKey, ECPublicKey theirSignedPreKey, ECPublicKey theirRatchetKey)
-
initializeBobSession
public static SessionRecord initializeBobSession(IdentityKeyPair identityKey, ECKeyPair signedPreKey, ECKeyPair ephemeralKey, IdentityKey theirIdentityKey, ECPublicKey theirBaseKey)
-
unsafeNativeHandleWithoutGuard
public long unsafeNativeHandleWithoutGuard()
- Specified by:
unsafeNativeHandleWithoutGuardin interfaceNativeHandleGuard.Owner
-
-