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_INTERNAL_LEGACY_PROTO_PARAMETERS_H_ 18 #define TINK_INTERNAL_LEGACY_PROTO_PARAMETERS_H_ 19 20 #include <utility> 21 22 #include "tink/internal/proto_parameters_serialization.h" 23 #include "tink/parameters.h" 24 #include "proto/tink.pb.h" 25 26 namespace crypto { 27 namespace tink { 28 namespace internal { 29 30 class LegacyProtoParameters : public Parameters { 31 public: 32 // Copyable and movable. 33 LegacyProtoParameters(const LegacyProtoParameters& other) = default; 34 LegacyProtoParameters& operator=(const LegacyProtoParameters& other) = 35 default; 36 LegacyProtoParameters(LegacyProtoParameters&& other) = default; 37 LegacyProtoParameters& operator=(LegacyProtoParameters&& other) = default; 38 LegacyProtoParameters(ProtoParametersSerialization serialization)39 explicit LegacyProtoParameters(ProtoParametersSerialization serialization) 40 : serialization_(std::move(serialization)) {} 41 HasIdRequirement()42 bool HasIdRequirement() const override { 43 return serialization_.GetKeyTemplate().output_prefix_type() != 44 google::crypto::tink::OutputPrefixType::RAW; 45 } 46 47 bool operator==(const Parameters& other) const override; 48 Serialization()49 const ProtoParametersSerialization& Serialization() const { 50 return serialization_; 51 } 52 53 private: 54 ProtoParametersSerialization serialization_; 55 }; 56 57 } // namespace internal 58 } // namespace tink 59 } // namespace crypto 60 61 #endif // TINK_INTERNAL_LEGACY_PROTO_PARAMETERS_H_ 62