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_SERIALIZATION_H_ 18 #define TINK_INTERNAL_SERIALIZATION_H_ 19 20 #include "absl/strings/string_view.h" 21 22 namespace crypto { 23 namespace tink { 24 25 // Represents either a serialized `Key` or a serialized `Parameters` object. 26 // 27 // Serialization objects are used within Tink to serialize keys, keysets, and 28 // parameters. For each serialization method (e.g., binary protobuf 29 // serialization), one subclass of this interface must be defined. 30 // 31 // This class should eventually be moved to the Tink Public API, but major 32 // changes still might be made until then (i.e., don't assume that this API 33 // is completely stable yet). 34 class Serialization { 35 public: 36 // Identifies which parsing method to use in the registry. 37 // 38 // When registering a parsing function in the registry, one argument will be 39 // this object identifier. When the registry is asked to parse a 40 // `Serialization`, the registry will then dispatch it to the corresponding 41 // method. 42 // 43 // The returned absl::string_view must remain valid for the lifetime of this 44 // `Serialization` object. 45 virtual absl::string_view ObjectIdentifier() const = 0; 46 47 virtual ~Serialization() = default; 48 }; 49 50 } // namespace tink 51 } // namespace crypto 52 53 #endif // TINK_INTERNAL_SERIALIZATION_H_ 54