xref: /aosp_15_r20/external/tink/cc/daead/deterministic_aead_key_templates.h (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1 // Copyright 2018 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_DAEAD_DETERMINISTIC_AEAD_KEY_TEMPLATES_H_
18 #define TINK_DAEAD_DETERMINISTIC_AEAD_KEY_TEMPLATES_H_
19 
20 #include "proto/tink.pb.h"
21 
22 namespace crypto {
23 namespace tink {
24 
25 ///////////////////////////////////////////////////////////////////////////////
26 // Pre-generated KeyTemplate for DeterministicAead key types.  One can use
27 // these templates to generate new KeysetHandle object with fresh keys.
28 // To generate a new keyset that contains a single AesGcmKey, one can do:
29 //
30 //   auto status = DeterministicAeadConfig::Register();
31 //   if (!status.ok()) { /* fail with error */ }
32 //   auto handle_result =
33 //       KeysetHandle::GenerateNew(DeterministicAeadKeyTemplates::Aes256Siv());
34 //   if (!handle_result.ok()) { /* fail with error */ }
35 //   auto keyset_handle = std::move(handle_result.value());
36 class DeterministicAeadKeyTemplates {
37  public:
38   // Returns a KeyTemplate that generates new instances of AesSivKey
39   // with the following parameters:
40   //   - key size: 64 bytes
41   //   - OutputPrefixType: TINK
42   static const google::crypto::tink::KeyTemplate& Aes256Siv();
43 };
44 
45 }  // namespace tink
46 }  // namespace crypto
47 
48 #endif  // TINK_DAEAD_DETERMINISTIC_AEAD_KEY_TEMPLATES_H_
49