1 // Copyright 2019 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 #include "tink/prf/prf_config.h" 17 18 #include "tink/config/tink_fips.h" 19 #include "tink/prf/aes_cmac_prf_key_manager.h" 20 #include "tink/prf/hkdf_prf_key_manager.h" 21 #include "tink/prf/hmac_prf_key_manager.h" 22 #include "tink/prf/prf_set_wrapper.h" 23 #include "tink/registry.h" 24 #include "tink/util/status.h" 25 26 namespace crypto { 27 namespace tink { 28 Register()29crypto::tink::util::Status PrfConfig::Register() { 30 // Register primitive wrapper. 31 auto status = 32 Registry::RegisterPrimitiveWrapper(absl::make_unique<PrfSetWrapper>()); 33 if (!status.ok()) return status; 34 35 status = Registry::RegisterKeyTypeManager( 36 absl::make_unique<HmacPrfKeyManager>(), true); 37 if (!status.ok()) return status; 38 39 // When using FIPS only mode do not register other key managers. 40 if (IsFipsModeEnabled()) return util::OkStatus(); 41 42 status = Registry::RegisterKeyTypeManager( 43 absl::make_unique<HkdfPrfKeyManager>(), true); 44 if (!status.ok()) return status; 45 46 status = Registry::RegisterKeyTypeManager( 47 absl::make_unique<AesCmacPrfKeyManager>(), true); 48 if (!status.ok()) { 49 return status; 50 } 51 return util::OkStatus(); 52 } 53 54 } // namespace tink 55 } // namespace crypto 56