public class SessionCipher
extends java.lang.Object
SessionBuilder,
this class can be used for all encrypt/decrypt operations within
that session.| Modifier and Type | Field and Description |
|---|---|
static java.lang.Object |
SESSION_LOCK |
| Constructor and Description |
|---|
SessionCipher(SessionStore sessionStore,
PreKeyStore preKeyStore,
SignedPreKeyStore signedPreKeyStore,
IdentityKeyStore identityKeyStore,
SignalProtocolAddress remoteAddress)
Construct a SessionCipher for encrypt/decrypt operations on a session.
|
SessionCipher(SignalProtocolStore store,
SignalProtocolAddress remoteAddress) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(PreKeySignalMessage ciphertext)
Decrypt a message.
|
byte[] |
decrypt(PreKeySignalMessage ciphertext,
DecryptionCallback callback)
Decrypt a message.
|
byte[] |
decrypt(SignalMessage ciphertext)
Decrypt a message.
|
byte[] |
decrypt(SignalMessage ciphertext,
DecryptionCallback callback)
Decrypt a message.
|
CiphertextMessage |
encrypt(byte[] paddedMessage)
Encrypt a message.
|
int |
getRemoteRegistrationId() |
int |
getSessionVersion() |
public SessionCipher(SessionStore sessionStore, PreKeyStore preKeyStore, SignedPreKeyStore signedPreKeyStore, IdentityKeyStore identityKeyStore, SignalProtocolAddress remoteAddress)
SessionBuilder.sessionStore - The SessionStore that contains a session for this recipient.remoteAddress - The remote address that messages will be encrypted to or decrypted from.public SessionCipher(SignalProtocolStore store, SignalProtocolAddress remoteAddress)
public CiphertextMessage encrypt(byte[] paddedMessage) throws UntrustedIdentityException
paddedMessage - The plaintext message bytes, optionally padded to a constant multiple.UntrustedIdentityExceptionpublic byte[] decrypt(PreKeySignalMessage ciphertext) throws DuplicateMessageException, LegacyMessageException, InvalidMessageException, InvalidKeyIdException, InvalidKeyException, UntrustedIdentityException
ciphertext - The PreKeySignalMessage to decrypt.InvalidMessageException - if the input is not valid ciphertext.DuplicateMessageException - if the input is a message that has already been received.LegacyMessageException - if the input is a message formatted by a protocol version that
is no longer supported.InvalidKeyIdException - when there is no local PreKeyRecord
that corresponds to the PreKey ID in the message.InvalidKeyException - when the message is formatted incorrectly.UntrustedIdentityException - when the IdentityKey of the sender is untrusted.public byte[] decrypt(PreKeySignalMessage ciphertext, DecryptionCallback callback) throws DuplicateMessageException, LegacyMessageException, InvalidMessageException, InvalidKeyIdException, InvalidKeyException, UntrustedIdentityException
ciphertext - The PreKeySignalMessage to decrypt.callback - A callback that is triggered after decryption is complete,
but before the updated session state has been committed to the session
DB. This allows some implementations to store the committed plaintext
to a DB first, in case they are concerned with a crash happening between
the time the session state is updated but before they're able to store
the plaintext to disk.InvalidMessageException - if the input is not valid ciphertext.DuplicateMessageException - if the input is a message that has already been received.LegacyMessageException - if the input is a message formatted by a protocol version that
is no longer supported.InvalidKeyIdException - when there is no local PreKeyRecord
that corresponds to the PreKey ID in the message.InvalidKeyException - when the message is formatted incorrectly.UntrustedIdentityException - when the IdentityKey of the sender is untrusted.public byte[] decrypt(SignalMessage ciphertext) throws InvalidMessageException, DuplicateMessageException, LegacyMessageException, NoSessionException, UntrustedIdentityException
ciphertext - The SignalMessage to decrypt.InvalidMessageException - if the input is not valid ciphertext.DuplicateMessageException - if the input is a message that has already been received.LegacyMessageException - if the input is a message formatted by a protocol version that
is no longer supported.NoSessionException - if there is no established session for this contact.UntrustedIdentityExceptionpublic byte[] decrypt(SignalMessage ciphertext, DecryptionCallback callback) throws InvalidMessageException, DuplicateMessageException, LegacyMessageException, NoSessionException, UntrustedIdentityException
ciphertext - The SignalMessage to decrypt.callback - A callback that is triggered after decryption is complete,
but before the updated session state has been committed to the session
DB. This allows some implementations to store the committed plaintext
to a DB first, in case they are concerned with a crash happening between
the time the session state is updated but before they're able to store
the plaintext to disk.InvalidMessageException - if the input is not valid ciphertext.DuplicateMessageException - if the input is a message that has already been received.LegacyMessageException - if the input is a message formatted by a protocol version that
is no longer supported.NoSessionException - if there is no established session for this contact.UntrustedIdentityExceptionpublic int getRemoteRegistrationId()
public int getSessionVersion()