Search in sources :

Example 1 with RemoteAttestationKeys

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

the class RemoteAttestationUtil method validateAndBuildRemoteAttestation.

private static RemoteAttestation validateAndBuildRemoteAttestation(RemoteAttestationResponse response, List<String> cookies, KeyStore iasKeyStore, ECKeyPair keyPair, String mrenclave) throws Quote.InvalidQuoteFormatException, InvalidCiphertextException, UnauthenticatedQuoteException, SignatureException, InvalidKeyException {
    RemoteAttestationKeys keys = new RemoteAttestationKeys(keyPair, response.getServerEphemeralPublic(), response.getServerStaticPublic());
    Quote quote = new Quote(response.getQuote());
    byte[] requestId = RemoteAttestationCipher.getRequestId(keys, response);
    RemoteAttestationCipher.verifyServerQuote(quote, response.getServerStaticPublic(), mrenclave);
    RemoteAttestationCipher.verifyIasSignature(iasKeyStore, response.getCertificates(), response.getSignatureBody(), response.getSignature(), quote);
    return new RemoteAttestation(requestId, keys, cookies);
}
Also used : Quote(org.whispersystems.signalservice.internal.contacts.crypto.Quote) RemoteAttestation(org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestation) RemoteAttestationKeys(org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestationKeys)

Example 2 with RemoteAttestationKeys

use of org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestationKeys in project libsignal-service-java by signalapp.

the class SignalServiceAccountManager method getRegisteredUsers.

public List<String> getRegisteredUsers(KeyStore iasKeyStore, Set<String> e164numbers, String mrenclave) throws IOException, Quote.InvalidQuoteFormatException, UnauthenticatedQuoteException, SignatureException, UnauthenticatedResponseException {
    try {
        String authorization = this.pushServiceSocket.getContactDiscoveryAuthorization();
        Curve25519 curve = Curve25519.getInstance(Curve25519.BEST);
        Curve25519KeyPair keyPair = curve.generateKeyPair();
        ContactDiscoveryCipher cipher = new ContactDiscoveryCipher();
        RemoteAttestationRequest attestationRequest = new RemoteAttestationRequest(keyPair.getPublicKey());
        Pair<RemoteAttestationResponse, List<String>> attestationResponse = this.pushServiceSocket.getContactDiscoveryRemoteAttestation(authorization, attestationRequest, mrenclave);
        RemoteAttestationKeys keys = new RemoteAttestationKeys(keyPair, attestationResponse.first().getServerEphemeralPublic(), attestationResponse.first().getServerStaticPublic());
        Quote quote = new Quote(attestationResponse.first().getQuote());
        byte[] requestId = cipher.getRequestId(keys, attestationResponse.first());
        cipher.verifyServerQuote(quote, attestationResponse.first().getServerStaticPublic(), mrenclave);
        cipher.verifyIasSignature(iasKeyStore, attestationResponse.first().getCertificates(), attestationResponse.first().getSignatureBody(), attestationResponse.first().getSignature(), quote);
        RemoteAttestation remoteAttestation = new RemoteAttestation(requestId, keys);
        List<String> addressBook = new LinkedList<>();
        for (String e164number : e164numbers) {
            addressBook.add(e164number.substring(1));
        }
        DiscoveryRequest request = cipher.createDiscoveryRequest(addressBook, remoteAttestation);
        DiscoveryResponse response = this.pushServiceSocket.getContactDiscoveryRegisteredUsers(authorization, request, attestationResponse.second(), mrenclave);
        byte[] data = cipher.getDiscoveryResponseData(response, remoteAttestation);
        Iterator<String> addressBookIterator = addressBook.iterator();
        List<String> results = new LinkedList<>();
        for (byte aData : data) {
            String candidate = addressBookIterator.next();
            if (aData != 0)
                results.add('+' + candidate);
        }
        return results;
    } catch (InvalidCiphertextException e) {
        throw new UnauthenticatedResponseException(e);
    }
}
Also used : ContactDiscoveryCipher(org.whispersystems.signalservice.internal.contacts.crypto.ContactDiscoveryCipher) DiscoveryResponse(org.whispersystems.signalservice.internal.contacts.entities.DiscoveryResponse) InvalidCiphertextException(org.whispersystems.signalservice.api.crypto.InvalidCiphertextException) RemoteAttestationResponse(org.whispersystems.signalservice.internal.contacts.entities.RemoteAttestationResponse) RemoteAttestationKeys(org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestationKeys) ByteString(com.google.protobuf.ByteString) LinkedList(java.util.LinkedList) Quote(org.whispersystems.signalservice.internal.contacts.crypto.Quote) RemoteAttestation(org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestation) RemoteAttestationRequest(org.whispersystems.signalservice.internal.contacts.entities.RemoteAttestationRequest) UnauthenticatedResponseException(org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException) Curve25519KeyPair(org.whispersystems.curve25519.Curve25519KeyPair) List(java.util.List) LinkedList(java.util.LinkedList) DiscoveryRequest(org.whispersystems.signalservice.internal.contacts.entities.DiscoveryRequest) Curve25519(org.whispersystems.curve25519.Curve25519)

Example 3 with RemoteAttestationKeys

use of org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestationKeys in project Signal-Android by signalapp.

the class RemoteAttestationUtil method validateAndBuildRemoteAttestation.

private static RemoteAttestation validateAndBuildRemoteAttestation(RemoteAttestationResponse response, List<String> cookies, KeyStore iasKeyStore, ECKeyPair keyPair, String mrenclave) throws Quote.InvalidQuoteFormatException, InvalidCiphertextException, UnauthenticatedQuoteException, SignatureException, InvalidKeyException {
    RemoteAttestationKeys keys = new RemoteAttestationKeys(keyPair, response.getServerEphemeralPublic(), response.getServerStaticPublic());
    Quote quote = new Quote(response.getQuote());
    byte[] requestId = RemoteAttestationCipher.getRequestId(keys, response);
    RemoteAttestationCipher.verifyServerQuote(quote, response.getServerStaticPublic(), mrenclave);
    RemoteAttestationCipher.verifyIasSignature(iasKeyStore, response.getCertificates(), response.getSignatureBody(), response.getSignature(), quote);
    return new RemoteAttestation(requestId, keys, cookies);
}
Also used : Quote(org.whispersystems.signalservice.internal.contacts.crypto.Quote) RemoteAttestation(org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestation) RemoteAttestationKeys(org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestationKeys)

Aggregations

Quote (org.whispersystems.signalservice.internal.contacts.crypto.Quote)3 RemoteAttestation (org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestation)3 RemoteAttestationKeys (org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestationKeys)3 ByteString (com.google.protobuf.ByteString)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Curve25519 (org.whispersystems.curve25519.Curve25519)1 Curve25519KeyPair (org.whispersystems.curve25519.Curve25519KeyPair)1 InvalidCiphertextException (org.whispersystems.signalservice.api.crypto.InvalidCiphertextException)1 ContactDiscoveryCipher (org.whispersystems.signalservice.internal.contacts.crypto.ContactDiscoveryCipher)1 UnauthenticatedResponseException (org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException)1 DiscoveryRequest (org.whispersystems.signalservice.internal.contacts.entities.DiscoveryRequest)1 DiscoveryResponse (org.whispersystems.signalservice.internal.contacts.entities.DiscoveryResponse)1 RemoteAttestationRequest (org.whispersystems.signalservice.internal.contacts.entities.RemoteAttestationRequest)1 RemoteAttestationResponse (org.whispersystems.signalservice.internal.contacts.entities.RemoteAttestationResponse)1