Asylo
null_assertion_verifier.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 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_NULL_NULL_ASSERTION_VERIFIER_H_
20 #define ASYLO_IDENTITY_ATTESTATION_NULL_NULL_ASSERTION_VERIFIER_H_
21 
22 #include <string>
23 
24 #include "absl/synchronization/mutex.h"
25 #include "asylo/identity/attestation/enclave_assertion_verifier.h"
26 
27 namespace asylo {
28 
29 /// An implementation of the EnclaveAssertionVerifier interface for null
30 /// assertions.
31 ///
32 /// NullAssertionVerifier can verify assertions generated by a
33 /// NullAssertionGenerator, although there are no cryptographic checks involved
34 /// in verifying such an assertion.
35 ///
36 /// The identity extracted from a verified null assertion is the null-terminated
37 /// string "Null Identity".
38 class NullAssertionVerifier final : public EnclaveAssertionVerifier {
39  public:
40  /// Constructs an uninitialized NullAssertionVerifier.
41  ///
42  /// The verifier can be initialized via a call to Initialize().
44 
45  ///////////////////////////////////////////
46  // From AssertionAuthority interface. //
47  ///////////////////////////////////////////
48 
49  Status Initialize(const std::string &config) override;
50 
51  bool IsInitialized() const override;
52 
53  EnclaveIdentityType IdentityType() const override;
54 
55  std::string AuthorityType() const override;
56 
57  ///////////////////////////////////////////
58  // From AssertionVerifier interface. //
59  ///////////////////////////////////////////
60 
62 
63  StatusOr<bool> CanVerify(const AssertionOffer &offer) const override;
64 
66  EnclaveIdentity *peer_identity) const override;
67 
68  private:
69  // Indicates whether this verifier has been initialized.
70  bool initialized_ ABSL_GUARDED_BY(initialized_mu_);
71 
72  // A mutex that guards the initialized_ member.
73  mutable absl::Mutex initialized_mu_;
74 
75  // The type of this assertion authority.
76  static const char *const authority_type_;
77 
78  // The type of enclave identity handled by this verifier.
79  static constexpr EnclaveIdentityType identity_type_ = NULL_IDENTITY;
80 };
81 
82 } // namespace asylo
83 
84 #endif // ASYLO_IDENTITY_ATTESTATION_NULL_NULL_ASSERTION_VERIFIER_H_
bool IsInitialized() const override
Indicates whether this assertion authority has been initialized successfully via a call to Initialize...
NullAssertionVerifier()
Constructs an uninitialized NullAssertionVerifier.
EnclaveIdentityType IdentityType() const override
Gets the enclave identity type handled by this assertion authority.
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.
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...
Status Initialize(const std::string &config) override
Initializes this assertion authority using the provided config.
std::string AuthorityType() const override
Gets the type of this assertion authority.
Status CreateAssertionRequest(AssertionRequest *request) const override
Creates an assertion request compatible with this verifier&#39;s identity type and authority type and pla...