Beispiel #1
0
        private static async Task <ResponsePair> MakeAttestationRequestAsync(PushServiceSocket socket,
                                                                             PushServiceSocket.ClientSet clientSet,
                                                                             string authorization,
                                                                             string enclaveName,
                                                                             Curve25519KeyPair keyPair)
        {
            RemoteAttestationRequest attestationRequest = new RemoteAttestationRequest(keyPair.getPublicKey());
            HttpResponseMessage      response           = await socket.MakeRequestAsync(clientSet, authorization, new List <string>(), $"/v1/attestation/{enclaveName}", "PUT", JsonUtil.ToJson(attestationRequest));

            HttpContent body = response.Content;

            if (body == null)
            {
                throw new MalformedResponseException("Empty response!");
            }

            return(new ResponsePair(await body.ReadAsStringAsync(), ParseCookies(response)));
        }
Beispiel #2
0
        public static async Task <Dictionary <string, RemoteAttestation> > GetAndVerifyMultiRemoteAttestation(PushServiceSocket socket,
                                                                                                              PushServiceSocket.ClientSet clientSet,
                                                                                                              string enclaveName,
                                                                                                              string mrenclave,
                                                                                                              string authorization)
        {
            Curve25519KeyPair keyPair = BuildKeyPair();
            ResponsePair      result  = await MakeAttestationRequestAsync(socket, clientSet, authorization, enclaveName, keyPair);

            MultiRemoteAttestationResponse         response     = JsonUtil.FromJson <MultiRemoteAttestationResponse>(result.body);
            Dictionary <string, RemoteAttestation> attestations = new Dictionary <string, RemoteAttestation>();

            if (response.Attestations !.Count == 0 || response.Attestations.Count > 3)
            {
                throw new MalformedResponseException($"Incorrect number of attestations: {response.Attestations.Count}");
            }

            foreach (var entry in response.Attestations)
            {
                attestations.Add(entry.Key,
                                 ValidateAndBuildRemoteAttestation(entry.Value, result.cookies, keyPair, mrenclave));
            }

            return(attestations);
        }
Beispiel #3
0
        public static async Task <RemoteAttestation> GetAndVerifyRemoteAttestationAsync(PushServiceSocket socket,
                                                                                        PushServiceSocket.ClientSet clientSet,
                                                                                        string enclaveName,
                                                                                        string mrenclave,
                                                                                        string authorization)
        {
            Curve25519KeyPair keyPair = BuildKeyPair();
            ResponsePair      result  = await MakeAttestationRequestAsync(socket, clientSet, authorization, enclaveName, keyPair);

            RemoteAttestationResponse response = JsonUtil.FromJson <RemoteAttestationResponse>(result.body);

            return(ValidateAndBuildRemoteAttestation(response, result.cookies, keyPair, mrenclave));
        }