Search in sources :

Example 6 with RemoteAttestation

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

Example 7 with RemoteAttestation

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

the class RemoteAttestationUtil method getAndVerifyMultiRemoteAttestation.

public static Map<String, RemoteAttestation> getAndVerifyMultiRemoteAttestation(PushServiceSocket socket, PushServiceSocket.ClientSet clientSet, KeyStore iasKeyStore, String enclaveName, String mrenclave, String authorization) throws IOException, Quote.InvalidQuoteFormatException, InvalidCiphertextException, UnauthenticatedQuoteException, SignatureException, InvalidKeyException {
    ECKeyPair keyPair = buildKeyPair();
    ResponsePair result = makeAttestationRequest(socket, clientSet, authorization, enclaveName, keyPair);
    MultiRemoteAttestationResponse response = JsonUtil.fromJson(result.body, MultiRemoteAttestationResponse.class);
    Map<String, RemoteAttestation> attestations = new HashMap<>();
    if (response.getAttestations().isEmpty() || response.getAttestations().size() > 3) {
        throw new MalformedResponseException("Incorrect number of attestations: " + response.getAttestations().size());
    }
    for (Map.Entry<String, RemoteAttestationResponse> entry : response.getAttestations().entrySet()) {
        attestations.put(entry.getKey(), validateAndBuildRemoteAttestation(entry.getValue(), result.cookies, iasKeyStore, keyPair, mrenclave));
    }
    return attestations;
}
Also used : RemoteAttestation(org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestation) HashMap(java.util.HashMap) MultiRemoteAttestationResponse(org.whispersystems.signalservice.internal.contacts.entities.MultiRemoteAttestationResponse) RemoteAttestationResponse(org.whispersystems.signalservice.internal.contacts.entities.RemoteAttestationResponse) ECKeyPair(org.whispersystems.libsignal.ecc.ECKeyPair) MalformedResponseException(org.whispersystems.signalservice.api.push.exceptions.MalformedResponseException) MultiRemoteAttestationResponse(org.whispersystems.signalservice.internal.contacts.entities.MultiRemoteAttestationResponse) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

RemoteAttestation (org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestation)7 HashMap (java.util.HashMap)4 ByteString (com.google.protobuf.ByteString)3 InvalidCiphertextException (org.whispersystems.signalservice.api.crypto.InvalidCiphertextException)3 Quote (org.whispersystems.signalservice.internal.contacts.crypto.Quote)3 RemoteAttestationKeys (org.whispersystems.signalservice.internal.contacts.crypto.RemoteAttestationKeys)3 UnauthenticatedResponseException (org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException)3 DiscoveryRequest (org.whispersystems.signalservice.internal.contacts.entities.DiscoveryRequest)3 DiscoveryResponse (org.whispersystems.signalservice.internal.contacts.entities.DiscoveryResponse)3 RemoteAttestationResponse (org.whispersystems.signalservice.internal.contacts.entities.RemoteAttestationResponse)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 ECKeyPair (org.whispersystems.libsignal.ecc.ECKeyPair)2 ACI (org.whispersystems.signalservice.api.push.ACI)2 MalformedResponseException (org.whispersystems.signalservice.api.push.exceptions.MalformedResponseException)2 MultiRemoteAttestationResponse (org.whispersystems.signalservice.internal.contacts.entities.MultiRemoteAttestationResponse)2 LinkedList (java.util.LinkedList)1