From 29843e61228247cf777bb9b67879b2797d2bcefd Mon Sep 17 00:00:00 2001 From: yangqingyou Date: Tue, 26 May 2020 10:09:35 +0000 Subject: [PATCH] add cmake option flag DWITH_CRYPTO, test=develop --- CMakeLists.txt | 1 + cmake/third_party.cmake | 7 +++++-- paddle/fluid/framework/io/CMakeLists.txt | 4 +++- paddle/fluid/framework/io/crypto/CMakeLists.txt | 6 +++--- paddle/fluid/framework/io/crypto/aes_cipher.cc | 3 +++ paddle/fluid/framework/io/crypto/aes_cipher.h | 15 +++++++++++---- .../fluid/framework/io/crypto/aes_cipher_test.cc | 1 + 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dd586b5fc..127df949dd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,7 @@ option(WITH_DGC "Use DGC(Deep Gradient Compression) or not" ${WITH_DISTRIBUTE} option(SANITIZER_TYPE "Choose the type of sanitizer, options are: Address, Leak, Memory, Thread, Undefined" OFF) option(WITH_LITE "Compile Paddle Fluid with Lite Engine" OFF) option(WITH_NCCL "Compile PaddlePaddle with NCCL support" ON) +option(WITH_CRYPTO "Compile PaddlePaddle with paddle_crypto lib" ON) # PY_VERSION if(NOT PY_VERSION) diff --git a/cmake/third_party.cmake b/cmake/third_party.cmake index 55737265d0..8a4f54300e 100644 --- a/cmake/third_party.cmake +++ b/cmake/third_party.cmake @@ -205,10 +205,9 @@ include(external/threadpool)# download threadpool include(external/dlpack) # download dlpack include(external/xxhash) # download, build, install xxhash include(external/warpctc) # download, build, install warpctc -include(external/cryptopp) # download, build, install cryptopp list(APPEND third_party_deps extern_eigen3 extern_gflags extern_glog extern_boost extern_xxhash) -list(APPEND third_party_deps extern_zlib extern_dlpack extern_warpctc extern_threadpool extern_cryptopp) +list(APPEND third_party_deps extern_zlib extern_dlpack extern_warpctc extern_threadpool) # download file set(CUDAERROR_URL "http://paddlepaddledeps.bj.bcebos.com/cudaErrorMessage.tar.gz" CACHE STRING "" FORCE) @@ -306,4 +305,8 @@ if (WITH_LITE) include(external/lite) endif (WITH_LITE) +if (WITH_CRYPTO) + include(external/cryptopp) # download, build, install cryptopp +endif (WITH_CRYPTO) + add_custom_target(third_party ALL DEPENDS ${third_party_deps}) diff --git a/paddle/fluid/framework/io/CMakeLists.txt b/paddle/fluid/framework/io/CMakeLists.txt index 2c62489dad..30c66cee5b 100644 --- a/paddle/fluid/framework/io/CMakeLists.txt +++ b/paddle/fluid/framework/io/CMakeLists.txt @@ -2,4 +2,6 @@ cc_library(fs SRCS fs.cc DEPS string_helper glog boost) cc_library(shell SRCS shell.cc DEPS string_helper glog timer enforce) cc_test(test_fs SRCS test_fs.cc DEPS fs shell) -add_subdirectory(crypto) +if (WITH_CRYPTO) + add_subdirectory(crypto) +endif (WITH_CRYPTO) diff --git a/paddle/fluid/framework/io/crypto/CMakeLists.txt b/paddle/fluid/framework/io/crypto/CMakeLists.txt index ab4efe83aa..ae16353ec9 100644 --- a/paddle/fluid/framework/io/crypto/CMakeLists.txt +++ b/paddle/fluid/framework/io/crypto/CMakeLists.txt @@ -1,3 +1,3 @@ -cc_library(paddle_ciphers SRCS cipher_utils.cc cipher.cc aes_cipher.cc DEPS cryptopp enforce) -cc_test(aes_cipher_test SRCS aes_cipher_test.cc DEPS paddle_ciphers) -cc_test(cipher_utils_test SRCS cipher_utils_test.cc DEPS paddle_ciphers) +cc_library(paddle_crypto SRCS cipher_utils.cc cipher.cc aes_cipher.cc DEPS cryptopp enforce) +cc_test(aes_cipher_test SRCS aes_cipher_test.cc DEPS paddle_crypto) +cc_test(cipher_utils_test SRCS cipher_utils_test.cc DEPS paddle_crypto) diff --git a/paddle/fluid/framework/io/crypto/aes_cipher.cc b/paddle/fluid/framework/io/crypto/aes_cipher.cc index dce71692b6..c5b1f1d74a 100644 --- a/paddle/fluid/framework/io/crypto/aes_cipher.cc +++ b/paddle/fluid/framework/io/crypto/aes_cipher.cc @@ -29,8 +29,11 @@ #include #include +#include +#include #include #include +#include #include #include diff --git a/paddle/fluid/framework/io/crypto/aes_cipher.h b/paddle/fluid/framework/io/crypto/aes_cipher.h index 0c1f1fd243..840e778b09 100644 --- a/paddle/fluid/framework/io/crypto/aes_cipher.h +++ b/paddle/fluid/framework/io/crypto/aes_cipher.h @@ -27,14 +27,21 @@ #pragma once -#include -#include -#include - #include #include "paddle/fluid/framework/io/crypto/cipher.h" +namespace CryptoPP { + +class StreamTransformationFilter; +class SymmetricCipher; +class AuthenticatedSymmetricCipher; +class AuthenticatedDecryptionFilter; +class AuthenticatedEncryptionFilter; +template +class member_ptr; + +} // namespace CryptoPP namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/io/crypto/aes_cipher_test.cc b/paddle/fluid/framework/io/crypto/aes_cipher_test.cc index 0702e4ab78..3ba55f4f45 100644 --- a/paddle/fluid/framework/io/crypto/aes_cipher_test.cc +++ b/paddle/fluid/framework/io/crypto/aes_cipher_test.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include "paddle/fluid/framework/io/crypto/aes_cipher.h" +#include #include #include -- GitLab