T_IdKeyPair
- IdentityKeyPair classT_IdKey
- IdentityKey classT_PreKey
- PreKey classT_SigPreKey
- SignedPreKey classT_Sess
- Session classT_Addr
- Address classT_ECPub
- Elliptic Curve PublicKey classT_Bundle
- Bundle classT_Ciph
- Cipher classpublic abstract class OmemoSession<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> extends Object
Modifier and Type | Field and Description |
---|---|
protected T_Ciph |
cipher |
protected T_IdKey |
identityKey |
protected OmemoManager |
omemoManager |
protected OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> |
omemoStore |
protected int |
preKeyId |
protected OmemoDevice |
remoteDevice |
Constructor and Description |
---|
OmemoSession(OmemoManager omemoManager,
OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore,
OmemoDevice remoteDevice)
Another constructor used when they establish the session with us.
|
OmemoSession(OmemoManager omemoManager,
OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore,
OmemoDevice remoteDevice,
T_IdKey identityKey)
Constructor used when we establish the session.
|
Modifier and Type | Method and Description |
---|---|
abstract T_Ciph |
createCipher(OmemoDevice contact)
Create a new SessionCipher used to encrypt/decrypt keys.
|
static Message |
decryptMessageElement(OmemoElement element,
CipherAndAuthTag cipherAndAuthTag)
Use the symmetric key in cipherAndAuthTag to decrypt the payload of the omemoMessage.
|
Message |
decryptMessageElement(OmemoElement element,
int keyId)
Try to decrypt the message.
|
abstract byte[] |
decryptMessageKey(byte[] encryptedKey)
Decrypt a messageKey using our sessionCipher.
|
CipherAndAuthTag |
decryptTransportedKey(OmemoElement element,
int keyId)
Try to decrypt the transported message key using the double ratchet session.
|
abstract CiphertextTuple |
encryptMessageKey(byte[] messageKey)
Encrypt a message key for the recipient.
|
OmemoFingerprint |
getFingerprint()
Return the fingerprint of the contacts identityKey.
|
T_IdKey |
getIdentityKey()
Return the identityKey of the session.
|
int |
getPreKeyId()
Get the id of the preKey used to establish the session.
|
void |
setIdentityKey(T_IdKey identityKey)
Set the identityKey of the remote device.
|
protected final OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore
protected final OmemoDevice remoteDevice
protected final OmemoManager omemoManager
protected T_IdKey identityKey
protected int preKeyId
public OmemoSession(OmemoManager omemoManager, OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore, OmemoDevice remoteDevice, T_IdKey identityKey)
omemoManager
- OmemoManager of our deviceomemoStore
- OmemoStore where we want to store the session and get key information fromremoteDevice
- the OmemoDevice we want to establish the session withidentityKey
- identityKey of the recipientpublic OmemoSession(OmemoManager omemoManager, OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore, OmemoDevice remoteDevice)
omemoManager
- OmemoManager of our deviceomemoStore
- OmemoStore we want to store the session and their key inremoteDevice
- identityKey of the partnerpublic CipherAndAuthTag decryptTransportedKey(OmemoElement element, int keyId) throws CryptoFailedException, NoRawSessionException
element
- omemoElementkeyId
- our keyIdCryptoFailedException
- if decryption using the double ratchet failsNoRawSessionException
- if we have no session, but the element was NOT a PreKeyMessagepublic static Message decryptMessageElement(OmemoElement element, CipherAndAuthTag cipherAndAuthTag) throws CryptoFailedException
element
- omemoElement containing a payload.cipherAndAuthTag
- cipher and authentication tag.CryptoFailedException
public Message decryptMessageElement(OmemoElement element, int keyId) throws CryptoFailedException, NoRawSessionException
element
- OmemoElementkeyId
- the key we want to decrypt (usually our own device id)CryptoFailedException
NoRawSessionException
public abstract T_Ciph createCipher(OmemoDevice contact)
contact
- OmemoDevicepublic int getPreKeyId()
public abstract CiphertextTuple encryptMessageKey(byte[] messageKey) throws CryptoFailedException
messageKey
- serialized key to encryptCryptoFailedException
public abstract byte[] decryptMessageKey(byte[] encryptedKey) throws CryptoFailedException, NoRawSessionException
encryptedKey
- encrypted keyCryptoFailedException
- when decryption fails.NoRawSessionException
- when no session was found in the double ratchet librarypublic T_IdKey getIdentityKey()
public void setIdentityKey(T_IdKey identityKey)
identityKey
- identityKeypublic OmemoFingerprint getFingerprint()