Asylo
null_assertion_generator.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_GENERATOR_H_
20 #define ASYLO_IDENTITY_ATTESTATION_NULL_NULL_ASSERTION_GENERATOR_H_
21 
22 #include <string>
23 
24 #include "absl/synchronization/mutex.h"
25 #include "asylo/identity/attestation/enclave_assertion_generator.h"
26 
27 namespace asylo {
28 
29 /// An implementation of the EnclaveAssertionGenerator interface for null
30 /// assertions.
31 ///
32 /// NullAssertionGenerator generates assertions based on assertion requests from
33 /// a NullAssertionVerifier. The generated assertions have no cryptographic
34 /// bindings and are trivially verifiable by a NullAssertionVerifier.
35 class NullAssertionGenerator final : public EnclaveAssertionGenerator {
36  public:
37  /// Constructs an uninitialized NullAssertionGenerator.
38  ///
39  /// The generator can be initialized via a call to Initialize().
41 
42  ///////////////////////////////////////////
43  // From AssertionAuthority interface. //
44  ///////////////////////////////////////////
45 
46  Status Initialize(const std::string &config) override;
47 
48  bool IsInitialized() const override;
49 
50  EnclaveIdentityType IdentityType() const override;
51 
52  std::string AuthorityType() const override;
53 
54  ///////////////////////////////////////////
55  // From AssertionGenerator interface. //
56  ///////////////////////////////////////////
57 
59 
60  StatusOr<bool> CanGenerate(const AssertionRequest &request) const override;
61 
63  Assertion *assertion) const override;
64 
65  private:
66  // Returns true if the given |request| is a valid AssertionRequest for this
67  // generator.
68  bool IsValidAssertionRequest(const AssertionRequest &request) const;
69 
70  // Indicates whether this generator has been initialized.
71  bool initialized_ ABSL_GUARDED_BY(initialized_mu_);
72 
73  // A mutex that guards the initialized_ member.
74  mutable absl::Mutex initialized_mu_;
75 
76  // The type of this assertion authority.
77  static const char *const authority_type_;
78 
79  // The type of enclave identity handled by this generator.
80  static constexpr EnclaveIdentityType identity_type_ = NULL_IDENTITY;
81 };
82 
83 } // namespace asylo
84 
85 #endif // ASYLO_IDENTITY_ATTESTATION_NULL_NULL_ASSERTION_GENERATOR_H_
Status Initialize(const std::string &config) override
Initializes this assertion authority using the provided config.
EnclaveIdentityType IdentityType() const override
Gets the enclave identity type handled by this assertion authority.
bool IsInitialized() const override
Indicates whether this assertion authority has been initialized successfully via a call to Initialize...
StatusOr< bool > CanGenerate(const AssertionRequest &request) const override
Indicates whether the assertion requested in request can be generated by this generator.
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]
std::string AuthorityType() const override
Gets the type of this assertion authority.
NullAssertionGenerator()
Constructs an uninitialized NullAssertionGenerator.
Status CreateAssertionOffer(AssertionOffer *offer) const override
Creates an assertion offer compatible with this generator&#39;s identity type and authority type and plac...
Status Generate(const std::string &user_data, const AssertionRequest &request, Assertion *assertion) const override
Generates an assertion that satisfies the given request, if request is compatible with this generator...