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(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,
java.lang.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(java.lang.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 javax.crypto.NoSuchPaddingException, javax.crypto.BadPaddingException, java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, javax.crypto.IllegalBlockSizeException, java.io.UnsupportedEncodingException, java.security.NoSuchProviderException, java.security.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 - IVjavax.crypto.NoSuchPaddingExceptionjavax.crypto.BadPaddingExceptionjava.security.InvalidKeyExceptionjava.security.NoSuchAlgorithmExceptionjavax.crypto.IllegalBlockSizeExceptionjava.io.UnsupportedEncodingExceptionjava.security.NoSuchProviderExceptionjava.security.InvalidAlgorithmParameterExceptionpublic OmemoMessageBuilder(OmemoManager omemoManager, OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore, 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.NoSuchProviderException, java.security.InvalidAlgorithmParameterException
omemoManager - omemoManager of our device.omemoStore - omemoStore.message - Messages body.javax.crypto.NoSuchPaddingExceptionjavax.crypto.BadPaddingExceptionjava.security.InvalidKeyExceptionjava.security.NoSuchAlgorithmExceptionjavax.crypto.IllegalBlockSizeExceptionjava.io.UnsupportedEncodingExceptionjava.security.NoSuchProviderExceptionjava.security.InvalidAlgorithmParameterExceptionpublic void setMessage(java.lang.String message) throws javax.crypto.NoSuchPaddingException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.InvalidAlgorithmParameterException, java.security.InvalidKeyException, java.io.UnsupportedEncodingException, javax.crypto.BadPaddingException, javax.crypto.IllegalBlockSizeException
message - content of the messagejavax.crypto.NoSuchPaddingException - When no Cipher could be instantiated.java.security.NoSuchAlgorithmException - when no Cipher could be instantiated.java.security.NoSuchProviderException - when BouncyCastle could not be found.java.security.InvalidAlgorithmParameterException - when the Cipher could not be initializedjava.security.InvalidKeyException - when the generated key is invalidjava.io.UnsupportedEncodingException - when UTF8 is unavailablejavax.crypto.BadPaddingException - when cipher.doFinal gets wrong paddingjavax.crypto.IllegalBlockSizeException - 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 java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmExceptionpublic static byte[] generateIv()
public byte[] getCiphertextMessage()
public byte[] getMessageKey()