xref: /aosp_15_r20/external/tink/cc/experimental/pqcrypto/kem/cecpq2_aead_hkdf_dem_helper.h (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1 // Copyright 2021 Google LLC
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_EXPERIMENTAL_PQCRYPTO_KEM_CECPQ2_AEAD_HKDF_DEM_HELPER_H_
18 #define TINK_EXPERIMENTAL_PQCRYPTO_KEM_CECPQ2_AEAD_HKDF_DEM_HELPER_H_
19 
20 #include <memory>
21 
22 #include "tink/aead.h"
23 #include "tink/daead/subtle/aead_or_daead.h"
24 #include "tink/util/protobuf_helper.h"
25 #include "tink/util/secret_data.h"
26 #include "tink/util/statusor.h"
27 #include "proto/tink.pb.h"
28 
29 namespace crypto {
30 namespace tink {
31 
32 // A helper for DEM (data encapsulation mechanism) of CECPQ2-AEAD-HKDF.
33 class Cecpq2AeadHkdfDemHelper {
34  public:
35   // Constructs a new helper for the specified DEM key template.
36   static crypto::tink::util::StatusOr<
37       std::unique_ptr<const Cecpq2AeadHkdfDemHelper>>
38   New(const google::crypto::tink::KeyTemplate& dem_key_template);
39 
40   virtual ~Cecpq2AeadHkdfDemHelper() = default;
41 
42   // Creates and returns a new AeadOrDaead object that uses
43   // a 32-bytes or greater high-entropy seed to generate a key.
44   virtual crypto::tink::util::StatusOr<
45       std::unique_ptr<crypto::tink::subtle::AeadOrDaead>>
46   GetAeadOrDaead(const util::SecretData& seed) const = 0;
47 
48   // Return the key material size.
49   virtual crypto::tink::util::StatusOr<uint32_t> GetKeyMaterialSize() const = 0;
50 };
51 
52 }  // namespace tink
53 }  // namespace crypto
54 
55 #endif  // TINK_EXPERIMENTAL_PQCRYPTO_KEM_CECPQ2_AEAD_HKDF_DEM_HELPER_H_
56