xref: /aosp_15_r20/external/tink/cc/key_access.h (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1 // Copyright 2021 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 ////////////////////////////////////////////////////////////////////////////////
16 
17 #ifndef TINK_KEY_ACCESS_H_
18 #define TINK_KEY_ACCESS_H_
19 
20 namespace crypto {
21 namespace tink {
22 
23 class KeyAccess {
24  public:
PublicAccess()25   static KeyAccess PublicAccess() {
26     KeyAccess token(false);
27     return token;
28   }
29 
CanAccessSecret()30   bool CanAccessSecret() { return can_access_secret_; }
31 
32   // KeyAccess objects are copiable and movable.
33   KeyAccess(const KeyAccess&) = default;
34   KeyAccess& operator=(const KeyAccess&) = default;
35   KeyAccess(KeyAccess&& other) = default;
36   KeyAccess& operator=(KeyAccess&& other) = default;
37 
38  private:
39   KeyAccess() = delete;
KeyAccess(bool can_access_secret)40   explicit KeyAccess(bool can_access_secret)
41       : can_access_secret_(can_access_secret) {}
42   friend class SecretKeyAccess;
43   bool can_access_secret_;
44 };
45 
46 }  // namespace tink
47 }  // namespace crypto
48 
49 #endif  // TINK_KEY_ACCESS_H_
50