Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
62b4ff7d
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
62b4ff7d
编写于
6月 01, 2020
作者:
Y
Yanghello
提交者:
GitHub
6月 01, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Aes_cipher_test and cipher_utils_test failed fixed (#24816)
上级
b490e41c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
9 addition
and
11 deletion
+9
-11
CMakeLists.txt
CMakeLists.txt
+1
-1
cmake/external/cryptopp.cmake
cmake/external/cryptopp.cmake
+2
-1
paddle/fluid/framework/io/crypto/aes_cipher.cc
paddle/fluid/framework/io/crypto/aes_cipher.cc
+5
-8
paddle/fluid/framework/io/crypto/cipher_utils.cc
paddle/fluid/framework/io/crypto/cipher_utils.cc
+1
-1
未找到文件。
CMakeLists.txt
浏览文件 @
62b4ff7d
...
...
@@ -88,7 +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 crypto support"
O
FF
)
option
(
WITH_CRYPTO
"Compile PaddlePaddle with crypto support"
O
N
)
# PY_VERSION
if
(
NOT PY_VERSION
)
...
...
cmake/external/cryptopp.cmake
浏览文件 @
62b4ff7d
...
...
@@ -68,7 +68,8 @@ ExternalProject_Add(
SOURCE_DIR
${
CRYPTOPP_SOURCE_DIR
}
PATCH_COMMAND
COMMAND
${
CMAKE_COMMAND
}
-E remove_directory
"<SOURCE_DIR>/cmake/"
COMMAND git clone -b
${
CRYPTOPP_TAG
}
https://github.com/noloader/cryptopp-cmake
"<SOURCE_DIR>/cmake"
COMMAND git clone https://github.com/noloader/cryptopp-cmake
"<SOURCE_DIR>/cmake"
COMMAND cd
"<SOURCE_DIR>/cmake"
&& git checkout tags/
${
CRYPTOPP_TAG
}
-b
${
CRYPTOPP_TAG
}
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
"<SOURCE_DIR>/cmake/"
"<SOURCE_DIR>/"
INSTALL_DIR
${
CRYPTOPP_INSTALL_DIR
}
CMAKE_ARGS
${
CRYPTOPP_CMAKE_ARGS
}
...
...
paddle/fluid/framework/io/crypto/aes_cipher.cc
浏览文件 @
62b4ff7d
...
...
@@ -60,7 +60,6 @@ std::string AESCipher::EncryptInternal(const std::string& plaintext,
CryptoPP
::
member_ptr
<
CryptoPP
::
SymmetricCipher
>
m_cipher
;
CryptoPP
::
member_ptr
<
CryptoPP
::
StreamTransformationFilter
>
m_filter
;
bool
need_iv
=
false
;
std
::
string
iv
=
""
;
const
unsigned
char
*
key_char
=
reinterpret_cast
<
const
unsigned
char
*>
(
&
(
key
.
at
(
0
)));
BuildCipher
(
true
,
&
need_iv
,
&
m_cipher
,
&
m_filter
);
...
...
@@ -77,7 +76,7 @@ std::string AESCipher::EncryptInternal(const std::string& plaintext,
m_filter
->
Attach
(
new
CryptoPP
::
StringSink
(
ciphertext
));
CryptoPP
::
StringSource
(
plaintext
,
true
,
new
CryptoPP
::
Redirector
(
*
m_filter
));
if
(
need_iv
)
{
ciphertext
=
iv_
.
append
(
ciphertext
)
;
return
iv_
+
ciphertext
;
}
return
ciphertext
;
...
...
@@ -88,7 +87,6 @@ std::string AESCipher::DecryptInternal(const std::string& ciphertext,
CryptoPP
::
member_ptr
<
CryptoPP
::
SymmetricCipher
>
m_cipher
;
CryptoPP
::
member_ptr
<
CryptoPP
::
StreamTransformationFilter
>
m_filter
;
bool
need_iv
=
false
;
std
::
string
iv
=
""
;
const
unsigned
char
*
key_char
=
reinterpret_cast
<
const
unsigned
char
*>
(
&
(
key
.
at
(
0
)));
BuildCipher
(
false
,
&
need_iv
,
&
m_cipher
,
&
m_filter
);
...
...
@@ -115,7 +113,6 @@ std::string AESCipher::AuthenticatedEncryptInternal(
CryptoPP
::
member_ptr
<
CryptoPP
::
AuthenticatedSymmetricCipher
>
m_cipher
;
CryptoPP
::
member_ptr
<
CryptoPP
::
AuthenticatedEncryptionFilter
>
m_filter
;
bool
need_iv
=
false
;
std
::
string
iv
=
""
;
const
unsigned
char
*
key_char
=
reinterpret_cast
<
const
unsigned
char
*>
(
&
(
key
.
at
(
0
)));
BuildAuthEncCipher
(
&
need_iv
,
&
m_cipher
,
&
m_filter
);
...
...
@@ -143,7 +140,6 @@ std::string AESCipher::AuthenticatedDecryptInternal(
CryptoPP
::
member_ptr
<
CryptoPP
::
AuthenticatedSymmetricCipher
>
m_cipher
;
CryptoPP
::
member_ptr
<
CryptoPP
::
AuthenticatedDecryptionFilter
>
m_filter
;
bool
need_iv
=
false
;
std
::
string
iv
=
""
;
const
unsigned
char
*
key_char
=
reinterpret_cast
<
const
unsigned
char
*>
(
&
(
key
.
at
(
0
)));
BuildAuthDecCipher
(
&
need_iv
,
&
m_cipher
,
&
m_filter
);
...
...
@@ -266,14 +262,15 @@ std::string AESCipher::Decrypt(const std::string& ciphertext,
void
AESCipher
::
EncryptToFile
(
const
std
::
string
&
plaintext
,
const
std
::
string
&
key
,
const
std
::
string
&
filename
)
{
std
::
ofstream
fout
(
filename
);
fout
<<
this
->
Encrypt
(
plaintext
,
key
);
std
::
ofstream
fout
(
filename
,
std
::
ios
::
binary
);
std
::
string
ciphertext
=
this
->
Encrypt
(
plaintext
,
key
);
fout
.
write
(
ciphertext
.
data
(),
ciphertext
.
size
());
fout
.
close
();
}
std
::
string
AESCipher
::
DecryptFromFile
(
const
std
::
string
&
key
,
const
std
::
string
&
filename
)
{
std
::
ifstream
fin
(
filename
);
std
::
ifstream
fin
(
filename
,
std
::
ios
::
binary
);
std
::
string
ciphertext
{
std
::
istreambuf_iterator
<
char
>
(
fin
),
std
::
istreambuf_iterator
<
char
>
()};
fin
.
close
();
...
...
paddle/fluid/framework/io/crypto/cipher_utils.cc
浏览文件 @
62b4ff7d
...
...
@@ -43,7 +43,7 @@ std::string CipherUtils::GenKeyToFile(int length, const std::string& filename) {
// CryptoPP::byte key[length];
prng
.
GenerateBlock
(
reinterpret_cast
<
unsigned
char
*>
(
&
(
rng
.
at
(
0
))),
rng
.
size
());
std
::
ofstream
fout
(
filename
);
std
::
ofstream
fout
(
filename
,
std
::
ios
::
binary
);
PADDLE_ENFORCE_EQ
(
fout
.
is_open
(),
true
,
paddle
::
platform
::
errors
::
Unavailable
(
"Failed to open file : %s, "
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录