Asylo
attributes_util.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_PLATFORM_SGX_ATTRIBUTES_UTIL_H_
20 #define ASYLO_IDENTITY_PLATFORM_SGX_ATTRIBUTES_UTIL_H_
21 
22 #include <vector>
23 
24 #include "absl/strings/string_view.h"
25 #include "asylo/identity/platform/sgx/architecture_bits.h"
26 #include "asylo/identity/platform/sgx/attributes.pb.h"
27 #include "asylo/util/status.h"
28 #include "asylo/util/statusor.h"
29 
30 /// @file attributes_util.h
31 /// @brief This library implements operations and utility functions on
32 /// Attributes messages.
33 
34 namespace asylo {
35 namespace sgx {
36 
37 /// Computes the bitwise AND of two Attributes protos.
39 
40 /// Checks two Attributes protos for equality.
41 bool operator==(const Attributes &lhs, const Attributes &rhs);
42 
43 /// Checks two Attributes protos for inequality.
44 bool operator!=(const Attributes &lhs, const Attributes &rhs);
45 
46 /// Sets the given `bit` of `attributes` to true, or returns a non-OK Status if
47 /// the `bit` was invalid.
49 
50 /// Sets the given `bit` of `attributes` to false, or returns a non-OK Status if
51 /// the `bit` was invalid.
53 
54 /// Returns whether the given `bit` of `attributes` is set, or a non-OK Status
55 /// if the `bit` was invalid.
57  const Attributes &attributes);
58 
59 /// Returns a printable list of the bits set in `attributes`.
61  const Attributes &attributes);
62 
63 } // namespace sgx
64 } // namespace asylo
65 
66 #endif // ASYLO_IDENTITY_PLATFORM_SGX_ATTRIBUTES_UTIL_H_
Attributes operator &(const Attributes &lhs, const Attributes &rhs)
Computes the bitwise AND of two Attributes protos.
bool operator==(const Miscselect &lhs, const Miscselect &rhs)
Checks two Miscselect protos for equality.
bool operator!=(const Miscselect &lhs, const Miscselect &rhs)
Checks two Miscselect protos for inequality.
Status SetAttributeBit(AttributeBit bit, Attributes *attributes)
Sets the given bit of attributes to true, or returns a non-OK Status if the bit was invalid...
Status ClearAttributeBit(AttributeBit bit, Attributes *attributes)
Sets the given bit of attributes to false, or returns a non-OK Status if the bit was invalid...
ABSL_CONST_INIT const char kStatusMoveAssignmentMsg[]
Definition: architecture_bits.h:26
StatusOr< bool > IsAttributeBitSet(AttributeBit bit, const Attributes &attributes)
Returns whether the given bit of attributes is set, or a non-OK Status if the bit was invalid...
std::vector< absl::string_view > GetPrintableAttributeList(const Attributes &attributes)
Returns a printable list of the bits set in attributes.