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 class OmemoMessageBuilder<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph>
extends java.lang.Object
Constructor and Description |
---|
OmemoMessageBuilder(OmemoDevice userDevice,
OmemoTrustCallback callback,
OmemoRatchet<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> ratchet,
byte[] aesKey,
byte[] iv,
java.lang.String message)
Create an OmemoMessageBuilder.
|
OmemoMessageBuilder(OmemoDevice userDevice,
OmemoTrustCallback callback,
OmemoRatchet<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> ratchet,
java.lang.String message)
Create an OmemoMessageBuilder.
|
Modifier and Type | Method and Description |
---|---|
void |
addRecipient(OmemoDevice contactsDevice)
Add a new recipient device to the message.
|
OmemoElement |
finish()
Assemble an OmemoMessageElement from the current state of the builder.
|
static byte[] |
generateIv()
Generate a 16 byte initialization vector for AES encryption.
|
static byte[] |
generateKey(java.lang.String keyType,
int keyLength)
Generate a new AES key used to encrypt the message.
|
public OmemoMessageBuilder(OmemoDevice userDevice, OmemoTrustCallback callback, OmemoRatchet<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> ratchet, byte[] aesKey, byte[] iv, java.lang.String message) throws javax.crypto.NoSuchPaddingException, javax.crypto.BadPaddingException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, javax.crypto.IllegalBlockSizeException, java.security.InvalidAlgorithmParameterException
userDevice
- our OmemoDevicecallback
- trustCallback for querying trust decisionsratchet
- our OmemoRatchetaesKey
- aes message key used for message encryptioniv
- initialization vector used for message encryptionmessage
- message we want to sendjavax.crypto.NoSuchPaddingException
- if the requested padding mechanism is not availble.javax.crypto.BadPaddingException
- if the input data is not padded properly.java.security.InvalidKeyException
- if the key is invalid.java.security.NoSuchAlgorithmException
- if no such algorithm is available.javax.crypto.IllegalBlockSizeException
- if the input data length is incorrect.java.security.InvalidAlgorithmParameterException
- if the provided arguments are invalid.public OmemoMessageBuilder(OmemoDevice userDevice, OmemoTrustCallback callback, OmemoRatchet<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> ratchet, java.lang.String message) throws javax.crypto.NoSuchPaddingException, javax.crypto.BadPaddingException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, javax.crypto.IllegalBlockSizeException, java.io.UnsupportedEncodingException, java.security.InvalidAlgorithmParameterException
userDevice
- our OmemoDevicecallback
- trustCallback for querying trust decisionsratchet
- our OmemoRatchetmessage
- message we want to sendjavax.crypto.NoSuchPaddingException
- if the requested padding mechanism is not availble.javax.crypto.BadPaddingException
- if the input data is not padded properly.java.security.InvalidKeyException
- if the key is invalid.java.security.NoSuchAlgorithmException
- if no such algorithm is available.javax.crypto.IllegalBlockSizeException
- if the input data length is incorrect.java.io.UnsupportedEncodingException
- if the encoding is not supported.java.security.InvalidAlgorithmParameterException
- if the provided arguments are invalid.public void addRecipient(OmemoDevice contactsDevice) throws NoIdentityKeyException, CorruptedOmemoKeyException, UndecidedOmemoIdentityException, UntrustedOmemoIdentityException, java.io.IOException
contactsDevice
- device of the recipientNoIdentityKeyException
- if we have no identityKey of that device. Can be fixed by fetching and
processing the devices bundle.CorruptedOmemoKeyException
- if the identityKey of that device is corrupted.UndecidedOmemoIdentityException
- if the user hasn't yet decided whether to trust that device or not.UntrustedOmemoIdentityException
- if the user has decided not to trust that device.java.io.IOException
- if an I/O error occured.public OmemoElement finish()
public static byte[] generateKey(java.lang.String keyType, int keyLength) throws java.security.NoSuchAlgorithmException
keyType
- Key TypekeyLength
- Key Length in bitjava.security.NoSuchAlgorithmException
- if no such algorithm is available.public static byte[] generateIv()