1 // Copyright 2021 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 #include "tink/experimental/pqcrypto/kem/cecpq2_hybrid_config.h" 18 19 #include "absl/memory/memory.h" 20 #include "tink/aead/aead_config.h" 21 #include "tink/config/tink_fips.h" 22 #include "tink/experimental/pqcrypto/kem/cecpq2_aead_hkdf_private_key_manager.h" 23 #include "tink/experimental/pqcrypto/kem/cecpq2_aead_hkdf_public_key_manager.h" 24 #include "tink/hybrid/hybrid_decrypt_wrapper.h" 25 #include "tink/hybrid/hybrid_encrypt_wrapper.h" 26 #include "tink/registry.h" 27 #include "tink/util/status.h" 28 29 namespace crypto { 30 namespace tink { 31 Cecpq2HybridConfigRegister()32util::Status Cecpq2HybridConfigRegister() { 33 auto status = AeadConfig::Register(); 34 if (!status.ok()) return status; 35 36 // Register primitive wrappers 37 status = Registry::RegisterPrimitiveWrapper( 38 absl::make_unique<HybridEncryptWrapper>()); 39 if (!status.ok()) return status; 40 status = Registry::RegisterPrimitiveWrapper( 41 absl::make_unique<HybridDecryptWrapper>()); 42 if (!status.ok()) return status; 43 44 // Currently there are no CECPQ2 hybrid encryption key managers which only use 45 // FIPS-validated implementations, therefore none will be registered in 46 // FIPS only mode 47 if (IsFipsModeEnabled()) { 48 return util::OkStatus(); 49 } 50 51 // Register non-FIPS hybrid-hybrid key managers 52 status = Registry::RegisterAsymmetricKeyManagers( 53 absl::make_unique<Cecpq2AeadHkdfPrivateKeyManager>(), 54 absl::make_unique<Cecpq2AeadHkdfPublicKeyManager>(), true); 55 if (!status.ok()) return status; 56 57 return util::OkStatus(); 58 } 59 60 } // namespace tink 61 } // namespace crypto 62