xref: /aosp_15_r20/external/tink/cc/parameters.h (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1 // Copyright 2022 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_PARAMETERS_H_
18 #define TINK_PARAMETERS_H_
19 
20 namespace crypto {
21 namespace tink {
22 
23 // Represents a cryptographic function without the actual key material.
24 //
25 // In Tink, a `Key` represents a set of cryptographic functions. A `Parameters`
26 // object contains all the information about the function that is not randomly
27 // chosen with each instance.
28 class Parameters {
29  public:
30   // Returns true if a key created with these parameters has to have a
31   // particular id when it is in a keyset.  Otherwise, returns false.
32   //
33   // In Tink, certain keys change their behavior depending on the key id (e.g.,
34   // an `Aead` object may add a prefix containing the big endian encoding of the
35   // key id to the ciphertext). In this case, such a key should require a unique
36   // id in `Key::GetIdRequirement()` and return true.
37   virtual bool HasIdRequirement() const = 0;
38 
39   // Returns true if all `Parameters` fields have identical values.  Otherwise,
40   // returns false.
41   virtual bool operator==(const Parameters& other) const = 0;
42   bool operator!=(const Parameters& other) const { return !(*this == other); }
43 
44   virtual ~Parameters() = default;
45 };
46 
47 }  // namespace tink
48 }  // namespace crypto
49 
50 #endif  // TINK_PARAMETERS_H_
51