Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
27a3d9f9
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
10
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
27a3d9f9
编写于
6月 27, 2006
作者:
R
Richard Levitte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use poll() when possible to gather Unix randomness entropy
上级
48fc582f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
7 deletion
+57
-7
CHANGES
CHANGES
+5
-0
crypto/rand/rand_unix.c
crypto/rand/rand_unix.c
+52
-7
未找到文件。
CHANGES
浏览文件 @
27a3d9f9
...
@@ -1289,6 +1289,11 @@
...
@@ -1289,6 +1289,11 @@
Changes between 0.9.7j and 0.9.7k [xx XXX xxxx]
Changes between 0.9.7j and 0.9.7k [xx XXX xxxx]
*) Change the Unix randomness entropy gathering to use poll() when
possible instead of select(), since the latter has some
undesirable limitations.
[Darryl Miles via Richard Levitte]
*) Disable rogue ciphersuites:
*) Disable rogue ciphersuites:
- SSLv2 0x08 0x00 0x80 ("RC4-64-MD5")
- SSLv2 0x08 0x00 0x80 ("RC4-64-MD5")
...
...
crypto/rand/rand_unix.c
浏览文件 @
27a3d9f9
...
@@ -126,6 +126,54 @@
...
@@ -126,6 +126,54 @@
#include <unistd.h>
#include <unistd.h>
#include <time.h>
#include <time.h>
#if defined(OPENSSL_SYS_LINUX)
/* lets use poll() */
# include <sys/poll.h>
# define IOWAIT_VARS struct pollfd pset; struct timeval t
# define IOWAIT_INIT(f, t) do { \
pset.fd = (f); \
pset.events = POLLIN; \
pset.revents = 0; \
(t)->tv_sec = 0; \
(t)->tv_usec = 10*1000; \
/* Spend 10ms on each file. */
\
} while(0)
# define IOWAIT_FUNC(f, t) poll(&pset, 1, ((t)->tv_sec * 1000) + ((t)->tv_usec / 1000))
# define IOWAIT_CHECK(f) ((pset.revents & POLLIN) != 0)
#else
/* lets use select() */
/* For each platform we could do with making a guess at
* how many FDs we support. With glibc/Linux its possible
* to use FD_SETSIZE directly, but this may not be very
* portable. Another options was to use _POSIX_OPEN_MAX
* but that value is a tad dull on modern hardware. So
* I ended up trying sizeof(fd_set)*8 which should be
* closer to the real value.
* If this causes a problem on your platform because we
* can not guess correctly then set it to zero.
*/
# if defined(FD_SETSIZE)
# define IOWAIT_FD_SETSIZE (FD_SETSIZE)
# else
/* fallback method */
# define IOWAIT_FD_SETSIZE (sizeof(fd_set) * 8)
# endif
# define IOWAIT_VARS fd_set fset; struct timeval t
# define IOWAIT_INIT(f, t) do { \
FD_ZERO(&fset); \
if(IOWAIT_FD_SETSIZE > 0 \
&& (f) >= IOWAIT_FD_SETSIZE) \
{ break; } \
FD_SET((f), &fset); \
(t)->tv_sec = 0; \
(t)->tv_usec = 10*1000; \
/* Spend 10ms on each file. */
\
} while(0)
# define IOWAIT_FUNC(f, t) select((f)+1,&fset,NULL,NULL,(t))
# define IOWAIT_CHECK(f) FD_ISSET((f), &fset)
#endif
#ifdef __OpenBSD__
#ifdef __OpenBSD__
int
RAND_poll
(
void
)
int
RAND_poll
(
void
)
{
{
...
@@ -185,11 +233,9 @@ int RAND_poll(void)
...
@@ -185,11 +233,9 @@ int RAND_poll(void)
#endif
#endif
))
>=
0
)
))
>=
0
)
{
{
struct
timeval
t
=
{
0
,
10
*
1000
};
/* Spend 10ms on
each file. */
int
r
;
int
r
;
unsigned
int
j
;
unsigned
int
j
;
fd_set
fset
;
IOWAIT_VARS
;
struct
stat
*
st
=&
randomstats
[
i
];
struct
stat
*
st
=&
randomstats
[
i
];
/* Avoid using same input... Used to be O_NOFOLLOW
/* Avoid using same input... Used to be O_NOFOLLOW
...
@@ -215,13 +261,12 @@ int RAND_poll(void)
...
@@ -215,13 +261,12 @@ int RAND_poll(void)
else
if
(
r
==
0
)
else
if
(
r
==
0
)
snooze
(
t
.
tv_usec
);
snooze
(
t
.
tv_usec
);
#else
#else
FD_ZERO
(
&
fset
);
IOWAIT_INIT
(
fd
,
&
t
);
FD_SET
(
fd
,
&
fset
);
r
=
-
1
;
r
=
-
1
;
if
(
select
(
fd
+
1
,
&
fset
,
NULL
,
NULL
,
&
t
)
<
0
)
if
(
IOWAIT_FUNC
(
fd
,
&
t
)
<
0
)
t
.
tv_usec
=
0
;
t
.
tv_usec
=
0
;
else
if
(
FD_ISSET
(
fd
,
&
fset
))
else
if
(
IOWAIT_CHECK
(
fd
))
{
{
r
=
read
(
fd
,(
unsigned
char
*
)
tmpbuf
+
n
,
r
=
read
(
fd
,(
unsigned
char
*
)
tmpbuf
+
n
,
ENTROPY_NEEDED
-
n
);
ENTROPY_NEEDED
-
n
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录