1 // Copyright 2018 Google Inc. 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_DAEAD_DETERMINISTIC_AEAD_FACTORY_H_ 18 #define TINK_DAEAD_DETERMINISTIC_AEAD_FACTORY_H_ 19 20 #include <memory> 21 22 #include "absl/base/macros.h" 23 #include "tink/deterministic_aead.h" 24 #include "tink/key_manager.h" 25 #include "tink/keyset_handle.h" 26 #include "tink/util/statusor.h" 27 28 namespace crypto { 29 namespace tink { 30 31 /////////////////////////////////////////////////////////////////////////////// 32 // This class is deprecated. Call 33 // keyset_handle->GetPrimitive<DeterministicAead>() instead. 34 // 35 // Note that in order to for this change to be safe, the 36 // DeterministicAeadWrapper has to be registered in your binary before this 37 // call. This happens automatically if you call one of 38 // * DeterministicAeadConfig::Register() 39 // * TinkConfig::Register() 40 class ABSL_DEPRECATED( 41 "Call getPrimitive<DeterministicAeadFactory>() on the keyset_handle after " 42 "registering the DeterministicAeadWrapper instead.") 43 DeterministicAeadFactory { 44 public: 45 // Returns an DeterministicAead-primitive that uses key material from 46 // the keyset specified via 'keyset_handle'. 47 static crypto::tink::util::StatusOr<std::unique_ptr<DeterministicAead>> 48 GetPrimitive(const KeysetHandle& keyset_handle); 49 50 // Returns an DeterministicAead-primitive that uses key material from 51 // the keyset specified via 'keyset_handle' and is instantiated by the given 52 // 'custom_key_manager' (instead of the key manager from the Registry). 53 static crypto::tink::util::StatusOr<std::unique_ptr<DeterministicAead>> 54 GetPrimitive(const KeysetHandle& keyset_handle, 55 const KeyManager<DeterministicAead>* custom_key_manager); 56 57 private: DeterministicAeadFactory()58 DeterministicAeadFactory() {} 59 }; 60 61 } // namespace tink 62 } // namespace crypto 63 64 #endif // TINK_DAEAD_DETERMINISTIC_AEAD_FACTORY_H_ 65