Asylo
sgx_intel_ecdsa_qe_remote_assertion_verifier.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2020 Asylo authors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef ASYLO_IDENTITY_ATTESTATION_SGX_SGX_INTEL_ECDSA_QE_REMOTE_ASSERTION_VERIFIER_H_
20 #define ASYLO_IDENTITY_ATTESTATION_SGX_SGX_INTEL_ECDSA_QE_REMOTE_ASSERTION_VERIFIER_H_
21 
22 #include <memory>
23 #include <string>
24 #include <string_view>
25 #include <utility>
26 #include <vector>
27 
28 #include "asylo/crypto/certificate_interface.h"
29 #include "asylo/identity/additional_authenticated_data_generator.h"
30 #include "asylo/identity/attestation/enclave_assertion_verifier.h"
31 #include "asylo/identity/attestation/sgx/sgx_intel_ecdsa_qe_remote_assertion_authority_config.pb.h"
32 #include "asylo/identity/enclave_assertion_authority.h"
33 #include "asylo/identity/identity.pb.h"
34 #include "asylo/identity/identity_acl.pb.h"
35 #include "asylo/identity/platform/sgx/internal/code_identity_constants.h"
36 #include "asylo/identity/platform/sgx/sgx_identity.pb.h"
37 #include "asylo/platform/common/static_map.h"
38 #include "asylo/util/mutex_guarded.h"
39 #include "asylo/util/status.h"
40 #include "asylo/util/statusor.h"
41 
42 namespace asylo {
43 
44 /// Implementation of `EnclaveAssertionVerifier` that verifiers assertions
45 /// generated by the Intel ECDSA quoting enclave. These assertions attest,
46 /// to a remote party, properties about both an enclave's code as well as
47 /// the Intel platform properties.
49  public:
50  /// Constructs a new `SgxIntelEcdsaQeAssertionVerifier` that generates
51  /// assertions suitable for use with EKEP.
53 
54  /// Constructs a new `SgxIntelEcdsaQeAssertionVerifier` that uses
55  /// `aad_generator` to generate the expected additional authenticated data to
56  /// be matched with quotes.
58  std::unique_ptr<AdditionalAuthenticatedDataGenerator> aad_generator);
59 
60  Status Initialize(const std::string &serialized_config) override;
61 
62  bool IsInitialized() const override;
63 
64  EnclaveIdentityType IdentityType() const override;
65 
66  std::string AuthorityType() const override;
67 
69 
70  StatusOr<bool> CanVerify(const AssertionOffer &offer) const override;
71 
73  EnclaveIdentity *peer_identity) const override;
74 
75  private:
76  // Type that holds members for mutex-synchronized access.
77  struct Members {
78  explicit Members(
79  std::unique_ptr<AdditionalAuthenticatedDataGenerator> generator)
80  : aad_generator(std::move(generator)) {}
81 
82  bool is_initialized = false;
83  std::vector<std::unique_ptr<CertificateInterface>> root_certificates;
84  std::unique_ptr<AdditionalAuthenticatedDataGenerator> aad_generator;
85  IdentityAclPredicate qe_identity_expectation;
86  };
87 
88  Status CheckInitialization(absl::string_view caller) const;
89 
90  MutexGuarded<Members> members_;
91 };
92 
93 } // namespace asylo
94 
95 #endif // ASYLO_IDENTITY_ATTESTATION_SGX_SGX_INTEL_ECDSA_QE_REMOTE_ASSERTION_VERIFIER_H_
bool IsInitialized() const override
Indicates whether this assertion authority has been initialized successfully via a call to Initialize...
SgxIntelEcdsaQeRemoteAssertionVerifier()
Constructs a new SgxIntelEcdsaQeAssertionVerifier that generates assertions suitable for use with EKE...
Status Initialize(const std::string &serialized_config) override
Initializes this assertion authority using the provided config.
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]
StatusOr< bool > CanVerify(const AssertionOffer &offer) const override
Indicates whether the assertion offered in offer can be verified by this verifier.
EnclaveIdentityType IdentityType() const override
Gets the enclave identity type handled by this assertion authority.
Implementation of EnclaveAssertionVerifier that verifiers assertions generated by the Intel ECDSA quo...
Definition: sgx_intel_ecdsa_qe_remote_assertion_verifier.h:48
Status CreateAssertionRequest(AssertionRequest *request) const override
Creates an assertion request compatible with this verifier&#39;s identity type and authority type and pla...
SgxIntelEcdsaQeRemoteAssertionVerifier(std::unique_ptr< AdditionalAuthenticatedDataGenerator > aad_generator)
Constructs a new SgxIntelEcdsaQeAssertionVerifier that uses aad_generator to generate the expected ad...
Status Verify(const std::string &user_data, const Assertion &assertion, EnclaveIdentity *peer_identity) const override
Verifies an assertion that is compatible with this verifier&#39;s identity type and authority type...
std::string AuthorityType() const override
Gets the type of this assertion authority.