- All Implemented Interfaces:
it.auties.protobuf.model.ProtobufMessage
,it.auties.protobuf.model.ProtobufObject
public final class Keys
extends Controller<Keys>
implements it.auties.protobuf.model.ProtobufMessage
This controller holds the cryptographic-related data regarding a WhatsappWeb session
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final UUID
(package private) final List
<CompanionSyncKey> App state keys(package private) boolean
Whether the client has already sent its business certificate (mobile api only)(package private) SignedDeviceIdentity
The bytes of the encodedSignedDeviceIdentityHMAC
received during the auth process(package private) SignalKeyPair
The companion secret key(package private) final byte[]
The device id for the mobile api(package private) final SignalKeyPair
The ephemeral key pair(package private) final String
The phone id for the mobile api(package private) final Map
<Jid, SenderPreKeys> (package private) final List
<CompanionPatch> Hash state(package private) final byte[]
The recovery token for the mobile api(package private) final SignalKeyPair
The signed identity key(package private) boolean
Whether the client received the initial app sync (web api only)(package private) final SignalKeyPair
The secret key pair used for buffer messages(package private) final List
<SignalPreKeyPair> Whether these keys have generated pre keys assigned to them(package private) final AtomicLong
Read counter for IV(package private) byte[]
Session dependent keys to write and read cyphered messages(package private) boolean
Whether the client was registered(package private) final Integer
The client id(package private) final Map
<SenderKeyName, SenderKeyRecord> Sender keys for signal implementation(package private) final Map
<SessionAddress, Session> Sessions map(package private) byte[]
The signed key of the companion's device This value will be null until it gets synced by whatsapp(package private) Long
The timestampSeconds of the signed key companion's device(package private) final SignalSignedKeyPair
The signed pre key(package private) final AtomicLong
Write counter for IV(package private) byte[]
Session dependent keys to write and read cyphered messagesFields inherited from class it.auties.whatsapp.controller.Controller
alias, clientType, serializer, uuid
-
Constructor Summary
ConstructorsConstructorDescriptionKeys
(UUID uuid, PhoneNumber phoneNumber, ClientType clientType, Collection<String> alias, Integer registrationId, SignalKeyPair noiseKeyPair, SignalKeyPair ephemeralKeyPair, SignalKeyPair identityKeyPair, SignalKeyPair companionKeyPair, SignalSignedKeyPair signedKeyPair, byte[] signedKeyIndex, Long signedKeyIndexTimestamp, List<SignalPreKeyPair> preKeys, String fdid, byte[] deviceId, UUID advertisingId, byte[] identityId, SignedDeviceIdentity companionIdentity, Map<SenderKeyName, SenderKeyRecord> senderKeys, List<CompanionSyncKey> appStateKeys, Map<SessionAddress, Session> sessions, List<CompanionPatch> hashStates, Map<Jid, SenderPreKeys> groupsPreKeys, boolean registered, boolean businessCertificate, boolean initialAppSync) -
Method Summary
Modifier and TypeMethodDescriptionaddAppKeys
(Jid jid, Collection<AppStateSyncKey> keys) Adds the provided keys to the app state keysaddPreKey
(SignalPreKeyPair preKey) Adds the provided pre key to the pre keysvoid
addRecipientsWithPreKeys
(Jid group, Collection<Jid> recipients) void
addRecipientWithPreKeys
(Jid group, Jid recipient) boolean
void
Clears the signal keys associated with this objectReturns the companion identity of this session Only available for web sessionscompanionIdentity
(SignedDeviceIdentity companionIdentity) This function sets the companionIdentity field to the value of the companionIdentity parameter, serializes the object, and returns the object.byte[]
deviceId()
void
dispose()
Disposes this objectbyte[]
Returns the encoded idfdid()
findAppKeyById
(Jid jid, byte[] id) Queries the app state key that matchesid
findHashStateByName
(Jid device, PatchType patchType) Queries the hash state that matchesname
.Queries the trusted key that matchesid
Queries the firstSenderKeyRecord
that matchesname
findSessionByAddress
(SessionAddress address) Queries theSession
that matchesaddress
findSignedKeyPairById
(int id) Queries the trusted key that matchesid
getAppKeys
(Jid jid) Get any available app keygetLatestAppKey
(Jid jid) Get any available app keyboolean
hasGroupKeys
(Jid group, Jid recipient) boolean
Checks if the client sent pre keys to the serverboolean
hasSession
(SessionAddress address) Checks whether a session already whatsappOldEligible for the given addressboolean
hasTrust
(SessionAddress address, byte[] identityKey) Checks whetheridentityKey
is trusted foraddress
byte[]
boolean
int
Returns the id of the last available pre keystatic Keys
newKeys
(UUID uuid, Long phoneNumber, Collection<String> alias, ClientType clientType) preKeys()
Returns all the registered pre keysputSession
(SessionAddress address, Session record) Adds the provided address and record to the known sessionsputState
(Jid device, CompanionHashState state) Adds the provided hash state to the known oneslong
readCounter
(boolean increment) Returns read counterOptional
<byte[]> readKey()
boolean
int
void
serialize
(boolean async) Serializes this objectsessions()
setBusinessCertificate
(boolean businessCertificate) setCompanionIdentity
(SignedDeviceIdentity companionIdentity) setCompanionKeyPair
(SignalKeyPair companionKeyPair) setInitialAppSync
(boolean initialAppSync) setReadKey
(byte[] readKey) setRegistered
(boolean registered) setSignedKeyIndex
(byte[] signedKeyIndex) setSignedKeyIndexTimestamp
(Long signedKeyIndexTimestamp) setWriteKey
(byte[] writeKey) Optional
<byte[]> toString()
Six part keys representationlong
writeCounter
(boolean increment) Returns write counterOptional
<byte[]> writeKey()
Methods inherited from class it.auties.whatsapp.controller.Controller
addAlias, alias, clientType, deleteSession, phoneNumber, removeAlias, removeAlias, serializer, setPhoneNumber, setSerializer, toJson, uuid
-
Field Details
-
registrationId
The client id -
noiseKeyPair
The secret key pair used for buffer messages -
ephemeralKeyPair
The ephemeral key pair -
identityKeyPair
The signed identity key -
companionKeyPair
SignalKeyPair companionKeyPairThe companion secret key -
signedKeyPair
The signed pre key -
signedKeyIndex
byte[] signedKeyIndexThe signed key of the companion's device This value will be null until it gets synced by whatsapp -
signedKeyIndexTimestamp
Long signedKeyIndexTimestampThe timestampSeconds of the signed key companion's device -
preKeys
Whether these keys have generated pre keys assigned to them -
fdid
The phone id for the mobile api -
deviceId
final byte[] deviceIdThe device id for the mobile api -
advertisingId
-
identityId
final byte[] identityIdThe recovery token for the mobile api -
companionIdentity
SignedDeviceIdentity companionIdentityThe bytes of the encodedSignedDeviceIdentityHMAC
received during the auth process -
senderKeys
Sender keys for signal implementation -
appStateKeys
App state keys -
sessions
Sessions map -
hashStates
Hash state -
groupsPreKeys
-
registered
boolean registeredWhether the client was registered -
businessCertificate
boolean businessCertificateWhether the client has already sent its business certificate (mobile api only) -
initialAppSync
boolean initialAppSyncWhether the client received the initial app sync (web api only) -
writeCounter
Write counter for IV -
readCounter
Read counter for IV -
writeKey
byte[] writeKeySession dependent keys to write and read cyphered messages -
readKey
byte[] readKeySession dependent keys to write and read cyphered messages
-
-
Constructor Details
-
Keys
public Keys(UUID uuid, PhoneNumber phoneNumber, ClientType clientType, Collection<String> alias, Integer registrationId, SignalKeyPair noiseKeyPair, SignalKeyPair ephemeralKeyPair, SignalKeyPair identityKeyPair, SignalKeyPair companionKeyPair, SignalSignedKeyPair signedKeyPair, byte[] signedKeyIndex, Long signedKeyIndexTimestamp, List<SignalPreKeyPair> preKeys, String fdid, byte[] deviceId, UUID advertisingId, byte[] identityId, SignedDeviceIdentity companionIdentity, Map<SenderKeyName, SenderKeyRecord> senderKeys, List<CompanionSyncKey> appStateKeys, Map<SessionAddress, Session> sessions, List<CompanionPatch> hashStates, Map<Jid, SenderPreKeys> groupsPreKeys, boolean registered, boolean businessCertificate, boolean initialAppSync)
-
-
Method Details
-
newKeys
public static Keys newKeys(UUID uuid, Long phoneNumber, Collection<String> alias, ClientType clientType) -
encodedRegistrationId
public byte[] encodedRegistrationId()Returns the encoded id- Returns:
- a non-null byte array
-
clearReadWriteKey
public void clearReadWriteKey()Clears the signal keys associated with this object -
hasPreKeys
public boolean hasPreKeys()Checks if the client sent pre keys to the server- Returns:
- true if the client sent pre keys to the server
-
findSenderKeyByName
Queries the firstSenderKeyRecord
that matchesname
- Parameters:
name
- the non-null name to search- Returns:
- a non-null SenderKeyRecord
-
findSessionByAddress
Queries theSession
that matchesaddress
- Parameters:
address
- the non-null address to search- Returns:
- a non-null Optional SessionRecord
-
findSignedKeyPairById
Queries the trusted key that matchesid
- Parameters:
id
- the id to search- Returns:
- a non-null signed key pair
- Throws:
IllegalArgumentException
- if no element can be found
-
findPreKeyById
Queries the trusted key that matchesid
- Parameters:
id
- the non-null id to search- Returns:
- a non-null pre key
-
findAppKeyById
Queries the app state key that matchesid
- Parameters:
jid
- the non-null jid of the app keyid
- the non-null id to search- Returns:
- a non-null Optional app state dataSync key
-
findHashStateByName
Queries the hash state that matchesname
. Otherwise, creates a new one.- Parameters:
device
- the non-null devicepatchType
- the non-null name to search- Returns:
- a non-null hash state
-
hasTrust
Checks whetheridentityKey
is trusted foraddress
- Parameters:
address
- the non-null addressidentityKey
- the nullable identity key- Returns:
- true if any match is found
-
hasSession
Checks whether a session already whatsappOldEligible for the given address- Parameters:
address
- the address to check- Returns:
- true if a session for that address already whatsappOldEligible
-
putSession
Adds the provided address and record to the known sessions- Parameters:
address
- the non-null addressrecord
- the non-null record- Returns:
- this
-
putState
Adds the provided hash state to the known ones- Parameters:
device
- the non-null devicestate
- the non-null hash state- Returns:
- this
-
addAppKeys
Adds the provided keys to the app state keys- Parameters:
jid
- the non-null jid of the app keykeys
- the keys to add- Returns:
- this
-
getLatestAppKey
Get any available app key- Returns:
- a non-null app key
-
getAppKeys
Get any available app key- Returns:
- a non-null app key
-
addPreKey
Adds the provided pre key to the pre keys- Parameters:
preKey
- the key to add- Returns:
- this
-
writeCounter
public long writeCounter(boolean increment) Returns write counter- Parameters:
increment
- whether the counter should be incremented after the call- Returns:
- an unsigned long
-
readCounter
public long readCounter(boolean increment) Returns read counter- Parameters:
increment
- whether the counter should be incremented after the call- Returns:
- an unsigned long
-
lastPreKeyId
public int lastPreKeyId()Returns the id of the last available pre key- Returns:
- an integer
-
companionIdentity
This function sets the companionIdentity field to the value of the companionIdentity parameter, serializes the object, and returns the object.- Parameters:
companionIdentity
- The identity of the companion device.- Returns:
- The object itself.
-
companionIdentity
Returns the companion identity of this session Only available for web sessions- Returns:
- an optional
-
preKeys
Returns all the registered pre keys- Returns:
- a non-null collection
-
addRecipientWithPreKeys
-
addRecipientsWithPreKeys
-
hasGroupKeys
-
dispose
public void dispose()Description copied from class:Controller
Disposes this object- Specified by:
dispose
in classController<Keys>
-
serialize
public void serialize(boolean async) Description copied from class:Controller
Serializes this object- Specified by:
serialize
in classController<Keys>
- Parameters:
async
- whether the operation should be executed asynchronously
-
registrationId
public int registrationId() -
noiseKeyPair
-
ephemeralKeyPair
-
identityKeyPair
-
signedKeyPair
-
signedKeyIndex
-
signedKeyIndexTimestamp
-
companionKeyPair
-
fdid
-
deviceId
public byte[] deviceId() -
advertisingId
-
identityId
public byte[] identityId() -
senderKeys
-
appStateKeys
-
sessions
-
hashStates
-
groupsPreKeys
-
registered
public boolean registered() -
businessCertificate
public boolean businessCertificate() -
initialAppSync
public boolean initialAppSync() -
writeCounter
-
readCounter
-
writeKey
-
readKey
-
setCompanionKeyPair
-
setSignedKeyIndex
-
setSignedKeyIndexTimestamp
-
setCompanionIdentity
-
setRegistered
-
setBusinessCertificate
-
setInitialAppSync
-
setWriteKey
-
setReadKey
-
toString
Six part keys representation
-