Asylo
sgx_age_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_AGE_REMOTE_ASSERTION_VERIFIER_H_
20 #define ASYLO_IDENTITY_ATTESTATION_SGX_SGX_AGE_REMOTE_ASSERTION_VERIFIER_H_
21 
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 #include "asylo/crypto/certificate.pb.h"
27 #include "asylo/crypto/certificate_interface.h"
28 #include "asylo/crypto/certificate_util.h"
29 #include "asylo/identity/attestation/enclave_assertion_verifier.h"
30 #include "asylo/identity/identity.pb.h"
31 #include "asylo/identity/identity_acl.pb.h"
32 #include "asylo/util/mutex_guarded.h"
33 #include "asylo/util/status.h"
34 #include "asylo/util/statusor.h"
35 
36 namespace asylo {
37 
38 /// An implemention of the EnclaveAssertionVerifier interface for SGX remote
39 /// assertions generated by the Assertion Generator Enclave.
40 ///
41 /// An SgxAgeRemoteAssertionVerifier is capable of verifying assertions of SGX
42 /// code identity that originate from an Assertion Generator Enclave that has a
43 /// compatible set of root certificates.
44 class SgxAgeRemoteAssertionVerifier final : public EnclaveAssertionVerifier {
45  public:
46  /// Constructs an uninitialized SgxAgeRemoteAssertionVerifier.
47  ///
48  /// The verifier must be initialized via a call to Initialize().
50 
51  ///////////////////////////////////////////
52  // From AssertionAuthority interface. //
53  ///////////////////////////////////////////
54 
55  Status Initialize(const std::string &config) override;
56 
57  bool IsInitialized() const override;
58 
59  EnclaveIdentityType IdentityType() const override;
60 
61  std::string AuthorityType() const override;
62 
63  ///////////////////////////////////////////
64  // From AssertionVerifier interface. //
65  ///////////////////////////////////////////
66 
68 
69  StatusOr<bool> CanVerify(const AssertionOffer &offer) const override;
70 
72  EnclaveIdentity *peer_identity) const override;
73 
74  private:
75  // Struct that holds class members to be guarded by the initialization mutex.
76  struct Members {
77  // The Intel root cert.
78  std::unique_ptr<CertificateInterface> intel_root_certificate;
79 
80  // Required root certificates outside of the Intel root cert.
81  CertificateInterfaceVector additional_root_certificates;
82 
83  // A predicate for accepted AGE identities.
84  IdentityAclPredicate age_identity_expectation;
85 
86  // The assertion request that is sent to peers.
87  AssertionRequest assertion_request;
88 
89  // Indicates whether this generator has been initialized.
90  bool initialized;
91 
92  Members() : initialized(false) {}
93  };
94 
95  MutexGuarded<Members> members_;
96 };
97 
98 } // namespace asylo
99 
100 #endif // ASYLO_IDENTITY_ATTESTATION_SGX_SGX_AGE_REMOTE_ASSERTION_VERIFIER_H_
EnclaveIdentityType IdentityType() const override
Gets the enclave identity type handled by this assertion authority.
std::string AuthorityType() const override
Gets the type of this assertion authority.
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...
bool IsInitialized() const override
Indicates whether this assertion authority has been initialized successfully via a call to Initialize...
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]
SgxAgeRemoteAssertionVerifier()=default
Constructs an uninitialized SgxAgeRemoteAssertionVerifier.
Status CreateAssertionRequest(AssertionRequest *request) const override
Creates an assertion request compatible with this verifier&#39;s identity type and authority type and pla...
Status Initialize(const std::string &config) override
Initializes this assertion authority using the provided config.
StatusOr< bool > CanVerify(const AssertionOffer &offer) const override
Indicates whether the assertion offered in offer can be verified by this verifier.