Search in sources :

Example 1 with AESEncryptedResult

use of org.whispersystems.signalservice.internal.contacts.crypto.AESCipher.AESEncryptedResult in project Signal-Android by WhisperSystems.

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)

Example 2 with AESEncryptedResult

use of org.whispersystems.signalservice.internal.contacts.crypto.AESCipher.AESEncryptedResult 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

HashMap (java.util.HashMap)2 Map (java.util.Map)2 AESEncryptedResult (org.whispersystems.signalservice.internal.contacts.crypto.AESCipher.AESEncryptedResult)2 DiscoveryRequest (org.whispersystems.signalservice.internal.contacts.entities.DiscoveryRequest)2 QueryEnvelope (org.whispersystems.signalservice.internal.contacts.entities.QueryEnvelope)2