xref: /aosp_15_r20/external/tink/cc/hybrid/hybrid_public_key.h (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1*e7b1675dSTing-Kang Chang // Copyright 2023 Google LLC
2*e7b1675dSTing-Kang Chang //
3*e7b1675dSTing-Kang Chang // Licensed under the Apache License, Version 2.0 (the "License");
4*e7b1675dSTing-Kang Chang // you may not use this file except in compliance with the License.
5*e7b1675dSTing-Kang Chang // You may obtain a copy of the License at
6*e7b1675dSTing-Kang Chang //
7*e7b1675dSTing-Kang Chang //      http://www.apache.org/licenses/LICENSE-2.0
8*e7b1675dSTing-Kang Chang //
9*e7b1675dSTing-Kang Chang // Unless required by applicable law or agreed to in writing, software
10*e7b1675dSTing-Kang Chang // distributed under the License is distributed on an "AS IS" BASIS,
11*e7b1675dSTing-Kang Chang // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*e7b1675dSTing-Kang Chang // See the License for the specific language governing permissions and
13*e7b1675dSTing-Kang Chang // limitations under the License.
14*e7b1675dSTing-Kang Chang //
15*e7b1675dSTing-Kang Chang ////////////////////////////////////////////////////////////////////////////////
16*e7b1675dSTing-Kang Chang 
17*e7b1675dSTing-Kang Chang #ifndef TINK_HYBRID_HYBRID_PUBLIC_KEY_H_
18*e7b1675dSTing-Kang Chang #define TINK_HYBRID_HYBRID_PUBLIC_KEY_H_
19*e7b1675dSTing-Kang Chang 
20*e7b1675dSTing-Kang Chang #include "absl/strings/string_view.h"
21*e7b1675dSTing-Kang Chang #include "tink/hybrid/hybrid_parameters.h"
22*e7b1675dSTing-Kang Chang #include "tink/key.h"
23*e7b1675dSTing-Kang Chang 
24*e7b1675dSTing-Kang Chang namespace crypto {
25*e7b1675dSTing-Kang Chang namespace tink {
26*e7b1675dSTing-Kang Chang 
27*e7b1675dSTing-Kang Chang // Represents the encryption function for a hybrid encryption primitive.
28*e7b1675dSTing-Kang Chang class HybridPublicKey : public Key {
29*e7b1675dSTing-Kang Chang  public:
30*e7b1675dSTing-Kang Chang   // Returns the bytes prefixed to every ciphertext generated by this key.
31*e7b1675dSTing-Kang Chang   //
32*e7b1675dSTing-Kang Chang   // In order to make key rotation more efficient, Tink allows every hybrid
33*e7b1675dSTing-Kang Chang   // public key to have an associated ciphertext output prefix. When decrypting
34*e7b1675dSTing-Kang Chang   // a ciphertext, only keys with a matching prefix have to be tried.
35*e7b1675dSTing-Kang Chang   //
36*e7b1675dSTing-Kang Chang   // See https://developers.google.com/tink/wire-format#tink_output_prefix for
37*e7b1675dSTing-Kang Chang   // more background information on Tink output prefixes.
38*e7b1675dSTing-Kang Chang   virtual absl::string_view GetOutputPrefix() const = 0;
39*e7b1675dSTing-Kang Chang 
40*e7b1675dSTing-Kang Chang   const HybridParameters& GetParameters() const override = 0;
41*e7b1675dSTing-Kang Chang 
42*e7b1675dSTing-Kang Chang   bool operator==(const Key& other) const override = 0;
43*e7b1675dSTing-Kang Chang };
44*e7b1675dSTing-Kang Chang 
45*e7b1675dSTing-Kang Chang }  // namespace tink
46*e7b1675dSTing-Kang Chang }  // namespace crypto
47*e7b1675dSTing-Kang Chang 
48*e7b1675dSTing-Kang Chang #endif  // TINK_HYBRID_HYBRID_PUBLIC_KEY_H_
49