Search in sources :

Example 6 with DiscoveryRequest

use of org.whispersystems.signalservice.internal.contacts.entities.DiscoveryRequest in project Signal-Android by signalapp.

the class ContactDiscoveryCipher method createDiscoveryRequest.

public static DiscoveryRequest createDiscoveryRequest(List<String> addressBook, Map<String, RemoteAttestation> remoteAttestations) {
    byte[] queryDataKey = Util.getSecretBytes(32);
    byte[] queryData = buildQueryData(addressBook);
    AESEncryptedResult encryptedQueryData = AESCipher.encrypt(queryDataKey, null, queryData);
    byte[] commitment = CryptoUtil.sha256(queryData);
    Map<String, QueryEnvelope> envelopes = new HashMap<>(remoteAttestations.size());
    for (Map.Entry<String, RemoteAttestation> entry : remoteAttestations.entrySet()) {
        envelopes.put(entry.getKey(), buildQueryEnvelope(entry.getValue().getRequestId(), entry.getValue().getKeys().getClientKey(), queryDataKey));
    }
    return new DiscoveryRequest(addressBook.size(), commitment, encryptedQueryData.iv, encryptedQueryData.data, encryptedQueryData.mac, envelopes);
}
Also used : QueryEnvelope(org.whispersystems.signalservice.internal.contacts.entities.QueryEnvelope) HashMap(java.util.HashMap) AESEncryptedResult(org.whispersystems.signalservice.internal.contacts.crypto.AESCipher.AESEncryptedResult) DiscoveryRequest(org.whispersystems.signalservice.internal.contacts.entities.DiscoveryRequest) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

DiscoveryRequest (org.whispersystems.signalservice.internal.contacts.entities.DiscoveryRequest)6 HashMap (java.util.HashMap)4 ByteString (com.google.protobuf.ByteString)3 InvalidCiphertextException (org.whispersystems.signalservice.api.crypto.InvalidCiphertextException)3 RemoteAttestation (org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestation)3 UnauthenticatedResponseException (org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException)3 DiscoveryResponse (org.whispersystems.signalservice.internal.contacts.entities.DiscoveryResponse)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 DataInputStream (java.io.DataInputStream)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 UUID (java.util.UUID)2 ACI (org.whispersystems.signalservice.api.push.ACI)2 AESEncryptedResult (org.whispersystems.signalservice.internal.contacts.crypto.AESCipher.AESEncryptedResult)2 QueryEnvelope (org.whispersystems.signalservice.internal.contacts.entities.QueryEnvelope)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1