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 Object
| Constructor and Description |
|---|
OmemoMessageBuilder(OmemoManager omemoManager,
OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore,
byte[] aesKey,
byte[] iv)
Create a OmemoMessageBuilder.
|
OmemoMessageBuilder(OmemoManager omemoManager,
OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore,
String message)
Create a new OmemoMessageBuilder with random IV and AES key.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRecipient(OmemoDevice device)
Add a new recipient device to the message.
|
void |
addRecipient(OmemoDevice device,
boolean ignoreTrust)
Add a new recipient device to the message.
|
OmemoVAxolotlElement |
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()
Generate a new AES key used to encrypt the message.
|
byte[] |
getCiphertextMessage() |
byte[] |
getMessageKey() |
void |
setMessage(String message)
Create an AES messageKey and use it to encrypt the message.
|
public OmemoMessageBuilder(OmemoManager omemoManager, OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore, byte[] aesKey, byte[] iv) throws NoSuchPaddingException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, UnsupportedEncodingException, NoSuchProviderException, InvalidAlgorithmParameterException
omemoManager - OmemoManager of our device.omemoStore - OmemoStore.aesKey - AES key that will be transported to the recipient. This is used eg. to encrypt the body.iv - IVNoSuchPaddingExceptionBadPaddingExceptionInvalidKeyExceptionNoSuchAlgorithmExceptionIllegalBlockSizeExceptionUnsupportedEncodingExceptionNoSuchProviderExceptionInvalidAlgorithmParameterExceptionpublic OmemoMessageBuilder(OmemoManager omemoManager, OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore, String message) throws NoSuchPaddingException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException, IllegalBlockSizeException, UnsupportedEncodingException, NoSuchProviderException, InvalidAlgorithmParameterException
omemoManager - omemoManager of our device.omemoStore - omemoStore.message - Messages body.NoSuchPaddingExceptionBadPaddingExceptionInvalidKeyExceptionNoSuchAlgorithmExceptionIllegalBlockSizeExceptionUnsupportedEncodingExceptionNoSuchProviderExceptionInvalidAlgorithmParameterExceptionpublic void setMessage(String message) throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeyException, UnsupportedEncodingException, BadPaddingException, IllegalBlockSizeException
message - content of the messageNoSuchPaddingException - When no Cipher could be instantiated.NoSuchAlgorithmException - when no Cipher could be instantiated.NoSuchProviderException - when BouncyCastle could not be found.InvalidAlgorithmParameterException - when the Cipher could not be initializedInvalidKeyException - when the generated key is invalidUnsupportedEncodingException - when UTF8 is unavailableBadPaddingException - when cipher.doFinal gets wrong paddingIllegalBlockSizeException - when cipher.doFinal gets wrong Block size.public void addRecipient(OmemoDevice device) throws CryptoFailedException, UndecidedOmemoIdentityException, CorruptedOmemoKeyException
device - recipient deviceCryptoFailedException - when encrypting the messageKey failsUndecidedOmemoIdentityExceptionCorruptedOmemoKeyExceptionpublic void addRecipient(OmemoDevice device, boolean ignoreTrust) throws CryptoFailedException, UndecidedOmemoIdentityException, CorruptedOmemoKeyException
device - recipient deviceignoreTrust - ignore current trust state? Useful for keyTransportMessages that are sent to repair a sessionCryptoFailedExceptionUndecidedOmemoIdentityExceptionCorruptedOmemoKeyExceptionpublic OmemoVAxolotlElement finish()
public static byte[] generateKey() throws NoSuchAlgorithmException
NoSuchAlgorithmExceptionpublic static byte[] generateIv()
public byte[] getCiphertextMessage()
public byte[] getMessageKey()