From cb03823c67c1d92cc2827e1ba7bebadb42e38407 Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Mon, 5 Feb 2024 11:02:04 +0200 Subject: [PATCH] Remove unused code. (#4689) This PR removes some unused code, specifically: * A patch file that should have been removed in #4553. * The `EncryptionKeyValidation` class that is unused since #1197. * Setting CMake policies to NEW that are already set by `cmake_minimum_required(VERSION 3.21)` --- TYPE: NO_HISTORY (cherry picked from commit 49e87524c5090f8a06f8f9a4fd14bb24ed807408) --- cmake/common.cmake | 10 -- .../fix-awsmigrationhub-build.patch | 10 -- tiledb/CMakeLists.txt | 8 -- tiledb/sm/crypto/encryption_key_validation.cc | 128 ------------------ tiledb/sm/crypto/encryption_key_validation.h | 92 ------------- 5 files changed, 248 deletions(-) delete mode 100644 ports/aws-sdk-cpp/fix-awsmigrationhub-build.patch delete mode 100644 tiledb/sm/crypto/encryption_key_validation.cc delete mode 100644 tiledb/sm/crypto/encryption_key_validation.h diff --git a/cmake/common.cmake b/cmake/common.cmake index f388e0f60014..0630e8ac02c6 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -91,13 +91,3 @@ endif() include_directories(${CMAKE_SOURCE_DIR}) cmake_path(SET TILEDB_SOURCE_ROOT NORMALIZE ${CMAKE_SOURCE_DIR}) cmake_path(APPEND TILEDB_SOURCE_ROOT "external/include" OUTPUT_VARIABLE TILEDB_EXTERNAL_INCLUDE) - -# -# Policies -# -if (POLICY CMP0076) - # CMP0076 NEW instructs `target_sources` to convert relative paths to absolute ones. - # At present this is only used for unit-test executables, not for the main - # library at the top level. - cmake_policy(SET CMP0076 NEW) -endif() \ No newline at end of file diff --git a/ports/aws-sdk-cpp/fix-awsmigrationhub-build.patch b/ports/aws-sdk-cpp/fix-awsmigrationhub-build.patch deleted file mode 100644 index c2d98030136e..000000000000 --- a/ports/aws-sdk-cpp/fix-awsmigrationhub-build.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff --git a/generated/src/aws-cpp-sdk-AWSMigrationHub/CMakeLists.txt b/generated/src/aws-cpp-sdk-AWSMigrationHub/CMakeLists.txt -index a8a888d..574b985 100644 ---- a/generated/src/aws-cpp-sdk-AWSMigrationHub/CMakeLists.txt -+++ b/generated/src/aws-cpp-sdk-AWSMigrationHub/CMakeLists.txt -@@ -1,4 +1,4 @@ --add_project(aws-cpp-sdk-AWSMigrationHub "C++ SDK for the AWS AWSMigrationHub service" aws-cpp-sdk-core) -+add_project(aws-cpp-sdk-awsmigrationhub "C++ SDK for the AWS AWSMigrationHub service" aws-cpp-sdk-core) - - file(GLOB AWS_AWSMIGRATIONHUB_HEADERS - "include/aws/AWSMigrationHub/*.h" diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt index a10c5350b4ae..acaea72cf973 100644 --- a/tiledb/CMakeLists.txt +++ b/tiledb/CMakeLists.txt @@ -26,13 +26,6 @@ # THE SOFTWARE. # -############################################################ -# CMake policies -############################################################ - -# C++ library, allow the VISIBLITY_PRESET for each c++ target to work -cmake_policy(SET CMP0063 NEW) - ############################################################ # Find packages needed for object libraries ############################################################ @@ -184,7 +177,6 @@ set(TILEDB_CORE_SOURCES ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/consolidator/group_meta_consolidator.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/crypto/crypto.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/crypto/encryption_key.cc - ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/crypto/encryption_key_validation.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/crypto/crypto_openssl.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/crypto/crypto_win32.cc ${TILEDB_CORE_INCLUDE_DIR}/tiledb/sm/curl/curl_init.cc diff --git a/tiledb/sm/crypto/encryption_key_validation.cc b/tiledb/sm/crypto/encryption_key_validation.cc deleted file mode 100644 index 4980ce32029d..000000000000 --- a/tiledb/sm/crypto/encryption_key_validation.cc +++ /dev/null @@ -1,128 +0,0 @@ -/** - * @file encryption_key_validation.h - * - * @section LICENSE - * - * The MIT License - * - * @copyright Copyright (c) 2018-2021 TileDB, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @section DESCRIPTION - * - * This file defines a class for encryption key validation. - */ - -#include "tiledb/sm/crypto/encryption_key_validation.h" -#include "tiledb/common/logger.h" -#include "tiledb/sm/crypto/crypto.h" -#include "tiledb/sm/crypto/encryption_key.h" -#include "tiledb/sm/enums/encryption_type.h" - -using namespace tiledb::common; - -namespace tiledb { -namespace sm { - -const std::string EncryptionKeyValidation::ENCRYPTION_KEY_CHECK_DATA = - "TILEDB_ENCRYPTION_KEY_CHECK_DATA"; - -Status EncryptionKeyValidation::check_encryption_key( - const EncryptionKey& encryption_key) { - // First time: encrypt the check data. - if (encryption_key_check_data_.size() == 0) - RETURN_NOT_OK(init_encryption_key_check_data(encryption_key)); - - // Decrypt the data and check that it is the same. - Buffer output; - ConstBuffer input( - encryption_key_check_data_.data(), encryption_key_check_data_.size()); - switch (encryption_key.encryption_type()) { - case EncryptionType::NO_ENCRYPTION: - RETURN_NOT_OK(output.write(&input, input.size())); - break; - case EncryptionType::AES_256_GCM: { - ConstBuffer iv( - encryption_key_check_data_iv_.data(), - encryption_key_check_data_iv_.size()); - ConstBuffer tag( - encryption_key_check_data_tag_.data(), - encryption_key_check_data_tag_.size()); - ConstBuffer key = encryption_key.key(); - RETURN_NOT_OK( - Crypto::decrypt_aes256gcm(&key, &iv, &tag, &input, &output)); - break; - } - default: - return LOG_STATUS(Status_EncryptionError( - "Invalid encryption key; invalid encryption type.")); - } - - if (output.size() != ENCRYPTION_KEY_CHECK_DATA.size()) - return LOG_STATUS(Status_EncryptionError("Invalid encryption key.")); - for (uint64_t i = 0; i < output.size(); i++) { - if (output.value(i * sizeof(char)) != ENCRYPTION_KEY_CHECK_DATA[i]) - return LOG_STATUS(Status_EncryptionError("Invalid encryption key.")); - } - - return Status::Ok(); -} - -Status EncryptionKeyValidation::init_encryption_key_check_data( - const EncryptionKey& encryption_key) { - encryption_key_check_data_.clear(); - encryption_key_check_data_tag_.clear(); - encryption_key_check_data_iv_.clear(); - - ConstBuffer input( - ENCRYPTION_KEY_CHECK_DATA.data(), ENCRYPTION_KEY_CHECK_DATA.size()); - - switch (encryption_key.encryption_type()) { - case EncryptionType::NO_ENCRYPTION: - RETURN_NOT_OK(encryption_key_check_data_.write(&input, input.size())); - break; - case EncryptionType::AES_256_GCM: { - RETURN_NOT_OK( - encryption_key_check_data_iv_.realloc(Crypto::AES256GCM_IV_BYTES)); - RETURN_NOT_OK( - encryption_key_check_data_tag_.realloc(Crypto::AES256GCM_TAG_BYTES)); - ConstBuffer key = encryption_key.key(); - PreallocatedBuffer iv( - encryption_key_check_data_iv_.data(), - encryption_key_check_data_iv_.alloced_size()); - PreallocatedBuffer tag( - encryption_key_check_data_tag_.data(), - encryption_key_check_data_tag_.alloced_size()); - RETURN_NOT_OK(Crypto::encrypt_aes256gcm( - &key, nullptr, &input, &encryption_key_check_data_, &iv, &tag)); - encryption_key_check_data_iv_.advance_size(Crypto::AES256GCM_IV_BYTES); - encryption_key_check_data_tag_.advance_size(Crypto::AES256GCM_TAG_BYTES); - break; - } - default: - return LOG_STATUS(Status_EncryptionError( - "Invalid encryption key; invalid encryption type.")); - } - - return Status::Ok(); -} - -} // namespace sm -} // namespace tiledb diff --git a/tiledb/sm/crypto/encryption_key_validation.h b/tiledb/sm/crypto/encryption_key_validation.h deleted file mode 100644 index 60410fabcbb7..000000000000 --- a/tiledb/sm/crypto/encryption_key_validation.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file encryption_key_validation.h - * - * @section LICENSE - * - * The MIT License - * - * @copyright Copyright (c) 2018-2021 TileDB, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @section DESCRIPTION - * - * This file declares a class for encryption key validation. - */ - -#ifndef TILEDB_ENCRYPTION_KEY_VALIDATION_H -#define TILEDB_ENCRYPTION_KEY_VALIDATION_H - -#include "tiledb/common/status.h" -#include "tiledb/sm/buffer/buffer.h" - -using namespace tiledb::common; - -namespace tiledb { -namespace sm { - -class EncryptionKey; - -/** - * Class which securely validates that a given encryption key is the same as a - * previously given encryption key, without storing the key itself. - */ -class EncryptionKeyValidation { - public: - /** - * Checks an encryption key. - * - * On the first invocation, the given key is used to encrypt a buffer of known - * data. On subsequent invocations, the given key is used to decrypt the - * internal encrypted buffer, which is checked for correctness against the - * known data. - * - * An error is returned if the key is invalid. - * - * @param encryption_key The encryption key to check. - * @return Status - */ - Status check_encryption_key(const EncryptionKey& encryption_key); - - private: - /** Constant string value used to check encryption keys. */ - static const std::string ENCRYPTION_KEY_CHECK_DATA; - - /** Buffer holding the encrypted bytes for the check data. */ - Buffer encryption_key_check_data_; - - /** Buffer holding the IV bytes for the check data. */ - Buffer encryption_key_check_data_iv_; - - /** Buffer holding the tag bytes for the check data. */ - Buffer encryption_key_check_data_tag_; - - /** - * Encrypt a known value with the given key and store the encrypted data. - * - * @param encryption_key The encryption key to use. - * @return Status - */ - Status init_encryption_key_check_data(const EncryptionKey& encryption_key); -}; - -} // namespace sm -} // namespace tiledb - -#endif // TILEDB_ENCRYPTION_KEY_VALIDATION_H