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