Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
8f576627
O
openssl
项目概览
btwise
/
openssl
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8f576627
编写于
6月 02, 2018
作者:
K
Kurt Roeckx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for KERN_ARND to get random bytes on NetBSD
Reviewed-by:
N
Andy Polyakov
<
appro@openssl.org
>
GH: #6405
上级
6da34cfb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
7 deletion
+18
-7
crypto/rand/rand_unix.c
crypto/rand/rand_unix.c
+18
-7
未找到文件。
crypto/rand/rand_unix.c
浏览文件 @
8f576627
...
...
@@ -23,7 +23,7 @@
# include <sys/sysctl.h>
# include <sys/param.h>
#endif
#if defined(__OpenBSD__)
#if defined(__OpenBSD__)
|| defined(__NetBSD__)
# include <sys/param.h>
#endif
#ifdef OPENSSL_SYS_UNIX
...
...
@@ -189,7 +189,7 @@ size_t rand_pool_acquire_entropy(RAND_POOL *pool)
# error "librandom not (yet) supported"
# endif
# if
defined(__FreeBSD__
) && defined(KERN_ARND)
# if
(defined(__FreeBSD__) || defined(__NetBSD__)
) && defined(KERN_ARND)
/*
* sysctl_random(): Use sysctl() to read a random number from the kernel
* Returns the size on success, 0 on failure.
...
...
@@ -201,14 +201,25 @@ static size_t sysctl_random(char *buf, size_t buflen)
size_t
len
;
/*
* O
ld implementations returned longs, newer versions support variable
*
sizes up to 256 byte. The code below would not work properly when
*
the sysctl returns long and we want to request something not a multiple
* of longs, which should never be the case.
* O
n FreeBSD old implementations returned longs, newer versions support
*
variable sizes up to 256 byte. The code below would not work properly
*
when the sysctl returns long and we want to request something not a
*
multiple
of longs, which should never be the case.
*/
if
(
!
ossl_assert
(
buflen
%
sizeof
(
long
)
==
0
))
return
0
;
/*
* On NetBSD before 4.0 KERN_ARND was an alias for KERN_URND, and only
* filled in an int, leaving the rest uninitialized. Since NetBSD 4.0
* it returns a variable number of bytes with the current version supporting
* up to 256 bytes.
* Just return an error on older NetBSD versions.
*/
#if defined(__NetBSD__) && __NetBSD_Version__ < 400000000
return
0
;
#endif
mib
[
0
]
=
CTL_KERN
;
mib
[
1
]
=
KERN_ARND
;
...
...
@@ -239,7 +250,7 @@ int syscall_random(void *buf, size_t buflen)
return
(
int
)
syscall
(
SYS_getrandom
,
buf
,
buflen
,
0
);
# endif
# if
defined(__FreeBSD__
) && defined(KERN_ARND)
# if
(defined(__FreeBSD__) || defined(__NetBSD__)
) && defined(KERN_ARND)
return
(
int
)
sysctl_random
(
buf
,
buflen
);
# endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录