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 OmemoKeyUtil<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> extends Object
Modifier and Type | Class and Description |
---|---|
class |
OmemoKeyUtil.Bundle
Bundle related methods.
|
Modifier and Type | Field and Description |
---|---|
OmemoKeyUtil.Bundle |
BUNDLE |
Constructor and Description |
---|
OmemoKeyUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
addInBounds(int value,
int added)
Add integers modulo MAX_VALUE.
|
abstract OmemoDevice |
addressAsOmemoDevice(T_Addr address)
Convert a crypto-lib specific contact object into an OmemoDevice.
|
abstract T_Bundle |
bundleFromOmemoBundle(OmemoBundleVAxolotlElement bundle,
OmemoDevice contact,
int keyId)
Build a crypto-lib specific PreKeyBundle (T_Bundle) using a PreKey from the OmemoBundleElement 'bundle'.
|
abstract OmemoSession<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> |
createOmemoSession(OmemoManager omemoManager,
OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore,
OmemoDevice from)
Create a new crypto-specific Session object.
|
abstract OmemoSession<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> |
createOmemoSession(OmemoManager omemoManager,
OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore,
OmemoDevice device,
T_IdKey identityKey)
Create a new concrete OmemoSession with a contact.
|
abstract T_ECPub |
ellipticCurvePublicKeyFromBytes(byte[] data)
Deserialize an elliptic curve public key from bytes.
|
abstract T_IdKeyPair |
generateOmemoIdentityKeyPair()
Generate a new IdentityKeyPair.
|
abstract HashMap<Integer,T_PreKey> |
generateOmemoPreKeys(int startId,
int count)
Generate 'count' new PreKeys beginning with id 'startId'.
|
abstract T_SigPreKey |
generateOmemoSignedPreKey(T_IdKeyPair identityKeyPair,
int signedPreKeyId)
Generate a new signed preKey.
|
abstract OmemoFingerprint |
getFingerprint(T_IdKey identityKey)
Return the fingerprint of an identityKey.
|
abstract byte[] |
identityKeyForBundle(T_IdKey identityKey)
Prepare an identityKey for transport in an OmemoBundleElement (serialize it).
|
abstract T_IdKey |
identityKeyFromBytes(byte[] data)
Deserialize an identityKey from a byte array.
|
abstract T_IdKey |
identityKeyFromPair(T_IdKeyPair pair)
Extract the public identityKey from an identityKeyPair.
|
abstract T_IdKeyPair |
identityKeyPairFromBytes(byte[] data)
Deserialize an identityKeyPair from a byte array.
|
abstract byte[] |
identityKeyPairToBytes(T_IdKeyPair identityKeyPair)
serialize an identityKeyPair into bytes.
|
abstract byte[] |
identityKeyToBytes(T_IdKey identityKey)
Serialize an identityKey into bytes.
|
abstract T_Addr |
omemoDeviceAsAddress(OmemoDevice contact)
Convert an OmemoDevice to a crypto-lib specific contact format.
|
abstract byte[] |
preKeyForBundle(T_PreKey preKey)
Prepare a preKey for transport in an OmemoBundleElement.
|
abstract T_PreKey |
preKeyFromBytes(byte[] bytes)
Deserialize a preKey from a byte array.
|
T_ECPub |
preKeyPublicFromBytes(byte[] data)
Deserialize a public preKey from bytes.
|
abstract byte[] |
preKeyPublicKeyForBundle(T_ECPub preKey)
Prepare an elliptic curve preKey for transport in an OmemoBundleElement.
|
HashMap<Integer,byte[]> |
preKeyPublisKeysForBundle(HashMap<Integer,T_PreKey> preKeyHashMap)
Prepare a whole bunche of preKeys for transport.
|
abstract byte[] |
preKeyToBytes(T_PreKey preKey)
Serialize a preKey into a byte array.
|
static String |
prettyFingerprint(OmemoFingerprint fingerprint) |
static String |
prettyFingerprint(String ugly)
Split the fingerprint in blocks of 8 characters with spaces between.
|
abstract T_Sess |
rawSessionFromBytes(byte[] data)
Deserialize a raw OMEMO Session from bytes.
|
abstract byte[] |
rawSessionToBytes(T_Sess session)
Serialize a raw OMEMO session into a byte array.
|
abstract T_SigPreKey |
signedPreKeyFromBytes(byte[] data)
Deserialize a signedPreKey from a byte array.
|
abstract int |
signedPreKeyIdFromKey(T_SigPreKey signedPreKey)
return the id of the given signedPreKey.
|
abstract byte[] |
signedPreKeyPublicForBundle(T_SigPreKey signedPreKey)
Prepare a public signedPreKey for transport in a bundle.
|
T_ECPub |
signedPreKeyPublicFromBytes(byte[] data)
Deserialize a public signedPreKey from bytes.
|
abstract byte[] |
signedPreKeySignatureFromKey(T_SigPreKey signedPreKey)
Extract the signature from a signedPreKey.
|
abstract byte[] |
signedPreKeyToBytes(T_SigPreKey sigPreKey)
Serialize a signedPreKey into a byte array.
|
public final OmemoKeyUtil.Bundle BUNDLE
public OmemoKeyUtil()
public abstract T_IdKeyPair identityKeyPairFromBytes(byte[] data) throws CorruptedOmemoKeyException
data
- byte arrayCorruptedOmemoKeyException
- if the key is damaged of malformedpublic abstract T_IdKey identityKeyFromBytes(byte[] data) throws CorruptedOmemoKeyException
data
- byte arrayCorruptedOmemoKeyException
- if the key is damaged or malformedpublic abstract byte[] identityKeyToBytes(T_IdKey identityKey)
identityKey
- idKeypublic abstract T_ECPub ellipticCurvePublicKeyFromBytes(byte[] data) throws CorruptedOmemoKeyException
data
- bytesCorruptedOmemoKeyException
- if the key is damaged or malformedpublic T_ECPub preKeyPublicFromBytes(byte[] data) throws CorruptedOmemoKeyException
data
- preKey as bytesCorruptedOmemoKeyException
- if the key is damaged or malformedpublic abstract byte[] preKeyToBytes(T_PreKey preKey)
preKey
- preKeypublic abstract T_PreKey preKeyFromBytes(byte[] bytes) throws IOException
bytes
- byte arrayIOException
- when something goes wrongpublic abstract HashMap<Integer,T_PreKey> generateOmemoPreKeys(int startId, int count)
startId
- start idcount
- how many keys do we want to generatepublic abstract T_SigPreKey generateOmemoSignedPreKey(T_IdKeyPair identityKeyPair, int signedPreKeyId) throws CorruptedOmemoKeyException
identityKeyPair
- identityKeyPair used to sign the preKeysignedPreKeyId
- id that the preKey will haveCorruptedOmemoKeyException
- when the identityKeyPair is invalidpublic T_ECPub signedPreKeyPublicFromBytes(byte[] data) throws CorruptedOmemoKeyException
data
- bytesCorruptedOmemoKeyException
- if the key is damaged or malformedpublic abstract T_SigPreKey signedPreKeyFromBytes(byte[] data) throws IOException
data
- byte arrayIOException
- when something goes wrongpublic abstract byte[] signedPreKeyToBytes(T_SigPreKey sigPreKey)
sigPreKey
- signedPreKeypublic abstract T_Bundle bundleFromOmemoBundle(OmemoBundleVAxolotlElement bundle, OmemoDevice contact, int keyId) throws CorruptedOmemoKeyException
bundle
- OmemoBundleElementcontact
- Contact that the bundle belongs tokeyId
- id of the preKey that will be selected from the OmemoBundleElement and that the PreKeyBundle will containCorruptedOmemoKeyException
- if some key is damaged or malformedpublic abstract byte[] signedPreKeySignatureFromKey(T_SigPreKey signedPreKey)
signedPreKey
- signedPreKeypublic abstract T_IdKeyPair generateOmemoIdentityKeyPair()
public abstract int signedPreKeyIdFromKey(T_SigPreKey signedPreKey)
signedPreKey
- keypublic abstract byte[] identityKeyPairToBytes(T_IdKeyPair identityKeyPair)
identityKeyPair
- identityKeyPairpublic abstract T_IdKey identityKeyFromPair(T_IdKeyPair pair)
pair
- keyPairpublic abstract byte[] identityKeyForBundle(T_IdKey identityKey)
identityKey
- identityKey that will be transportedpublic abstract byte[] preKeyPublicKeyForBundle(T_ECPub preKey)
preKey
- keypublic abstract byte[] preKeyForBundle(T_PreKey preKey)
preKey
- preKeypublic HashMap<Integer,byte[]> preKeyPublisKeysForBundle(HashMap<Integer,T_PreKey> preKeyHashMap)
preKeyHashMap
- HashMap of preKeyspublic abstract byte[] signedPreKeyPublicForBundle(T_SigPreKey signedPreKey)
signedPreKey
- signedPrekeypublic abstract OmemoFingerprint getFingerprint(T_IdKey identityKey)
identityKey
- identityKeypublic abstract OmemoSession<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> createOmemoSession(OmemoManager omemoManager, OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore, OmemoDevice from)
omemoManager
- omemoManager of our device.omemoStore
- omemoStore where we can save the session, get keys from etc.from
- the device we want to create the session with.public abstract OmemoSession<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> createOmemoSession(OmemoManager omemoManager, OmemoStore<T_IdKeyPair,T_IdKey,T_PreKey,T_SigPreKey,T_Sess,T_Addr,T_ECPub,T_Bundle,T_Ciph> omemoStore, OmemoDevice device, T_IdKey identityKey)
omemoManager
- omemoManager of our device.omemoStore
- omemoStoredevice
- device to establish the session withidentityKey
- identityKey of the devicepublic abstract T_Sess rawSessionFromBytes(byte[] data) throws IOException
data
- bytesIOException
- when something goes wrongpublic abstract byte[] rawSessionToBytes(T_Sess session)
session
- raw sessionpublic abstract T_Addr omemoDeviceAsAddress(OmemoDevice contact)
contact
- omemoContactpublic abstract OmemoDevice addressAsOmemoDevice(T_Addr address) throws XmppStringprepException
address
- contactXmppStringprepException
- if the address is not a valid BareJidpublic static String prettyFingerprint(OmemoFingerprint fingerprint)
public static String prettyFingerprint(String ugly)
ugly
- fingerprint as continuous stringpublic static int addInBounds(int value, int added)
value
- base integeradded
- value that is added to the base value