Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
373b575f
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,发现更多精彩内容 >>
提交
373b575f
编写于
1月 16, 2000
作者:
U
Ulf Möller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New function RAND_pseudo_bytes() generated pseudorandom numbers that
are not guaranteed to be unpredictable.
上级
e1798f85
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
37 addition
and
9 deletion
+37
-9
CHANGES
CHANGES
+5
-4
apps/speed.c
apps/speed.c
+2
-2
crypto/pkcs7/pk7_mime.c
crypto/pkcs7/pk7_mime.c
+1
-1
crypto/rand/md_rand.c
crypto/rand/md_rand.c
+19
-0
crypto/rand/rand.h
crypto/rand/rand.h
+2
-0
crypto/rand/rand_lib.c
crypto/rand/rand_lib.c
+6
-0
crypto/rand/randtest.c
crypto/rand/randtest.c
+1
-1
e_os.h
e_os.h
+1
-1
未找到文件。
CHANGES
浏览文件 @
373b575f
...
...
@@ -7,11 +7,12 @@
*) Precautions against using the PRNG uninitialized: RAND_bytes() now
has a return value which indicates the quality of the random data
(1 = ok, 0 = not seeded). Also an error is recorded on the thread's
error queue.
error queue. New function RAND_pseudo_bytes() generates output that is
guaranteed to be unique but not unpredictable.
(TO DO: always check the result of RAND_bytes when it is used in the
library,
because leaving the error in the error queue but reporting
success in a function that uses RAND_bytes could confuse things
considerably.)
library,
or use RAND_pseudo_bytes instead, because leaving the
error in the error queue but reporting success in a function that
uses RAND_bytes could confuse things
considerably.)
[Ulf Möller]
*) Do more iterations of Rabin-Miller probable prime test (specifically,
...
...
apps/speed.c
浏览文件 @
373b575f
...
...
@@ -965,7 +965,7 @@ int MAIN(int argc, char **argv)
}
#endif
RAND_bytes
(
buf
,
36
);
RAND_
pseudo_
bytes
(
buf
,
36
);
#ifndef NO_RSA
for
(
j
=
0
;
j
<
RSA_NUM
;
j
++
)
{
...
...
@@ -1026,7 +1026,7 @@ int MAIN(int argc, char **argv)
}
#endif
RAND_bytes
(
buf
,
20
);
RAND_
pseudo_
bytes
(
buf
,
20
);
#ifndef NO_DSA
for
(
j
=
0
;
j
<
DSA_NUM
;
j
++
)
{
...
...
crypto/pkcs7/pk7_mime.c
浏览文件 @
373b575f
...
...
@@ -149,7 +149,7 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
if
((
flags
&
PKCS7_DETACHED
)
&&
data
)
{
/* We want multipart/signed */
/* Generate a random boundary */
RAND_bytes
((
unsigned
char
*
)
bound
,
32
);
RAND_
pseudo_
bytes
((
unsigned
char
*
)
bound
,
32
);
for
(
i
=
0
;
i
<
32
;
i
++
)
{
c
=
bound
[
i
]
&
0xf
;
if
(
c
<
10
)
c
+=
'0'
;
...
...
crypto/rand/md_rand.c
浏览文件 @
373b575f
...
...
@@ -146,12 +146,14 @@ static void ssleay_rand_cleanup(void);
static
void
ssleay_rand_seed
(
const
void
*
buf
,
int
num
);
static
void
ssleay_rand_add
(
const
void
*
buf
,
int
num
,
int
add_entropy
);
static
int
ssleay_rand_bytes
(
unsigned
char
*
buf
,
int
num
);
static
int
ssleay_rand_pseudo_bytes
(
unsigned
char
*
buf
,
int
num
);
RAND_METHOD
rand_ssleay_meth
=
{
ssleay_rand_seed
,
ssleay_rand_bytes
,
ssleay_rand_cleanup
,
ssleay_rand_add
,
ssleay_rand_pseudo_bytes
,
};
RAND_METHOD
*
RAND_SSLeay
(
void
)
...
...
@@ -449,6 +451,23 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
}
}
/* pseudo-random bytes that are guaranteed to be unique but not
unpredictable */
static
int
ssleay_rand_pseudo_bytes
(
unsigned
char
*
buf
,
int
num
)
{
int
ret
,
err
;
ret
=
RAND_bytes
(
buf
,
num
);
if
(
ret
==
0
)
{
err
=
ERR_peek_error
();
if
(
ERR_GET_LIB
(
err
)
==
ERR_LIB_RAND
&&
ERR_GET_REASON
(
err
)
==
RAND_R_PRNG_NOT_SEEDED
)
(
void
)
ERR_get_error
();
}
return
(
ret
);
}
#ifdef WINDOWS
#include <windows.h>
#include <openssl/rand.h>
...
...
crypto/rand/rand.h
浏览文件 @
373b575f
...
...
@@ -69,6 +69,7 @@ typedef struct rand_meth_st
int
(
*
bytes
)(
unsigned
char
*
buf
,
int
num
);
void
(
*
cleanup
)(
void
);
void
(
*
add
)(
const
void
*
buf
,
int
num
,
int
entropy
);
int
(
*
pseudorand
)(
unsigned
char
*
buf
,
int
num
);
}
RAND_METHOD
;
void
RAND_set_rand_method
(
RAND_METHOD
*
meth
);
...
...
@@ -76,6 +77,7 @@ RAND_METHOD *RAND_get_rand_method(void );
RAND_METHOD
*
RAND_SSLeay
(
void
);
void
RAND_cleanup
(
void
);
int
RAND_bytes
(
unsigned
char
*
buf
,
int
num
);
int
RAND_pseudo_bytes
(
unsigned
char
*
buf
,
int
num
);
void
RAND_seed
(
const
void
*
buf
,
int
num
);
void
RAND_add
(
const
void
*
buf
,
int
num
,
int
entropy
);
int
RAND_load_file
(
const
char
*
file
,
long
max_bytes
);
...
...
crypto/rand/rand_lib.c
浏览文件 @
373b575f
...
...
@@ -102,3 +102,9 @@ int RAND_bytes(unsigned char *buf, int num)
return
(
-
1
);
}
int
RAND_pseudo_bytes
(
unsigned
char
*
buf
,
int
num
)
{
if
(
rand_meth
!=
NULL
)
return
rand_meth
->
pseudorand
(
buf
,
num
);
return
(
-
1
);
}
crypto/rand/randtest.c
浏览文件 @
373b575f
...
...
@@ -73,7 +73,7 @@ int main()
/*double d; */
long
d
;
RAND_bytes
(
buf
,
2500
);
RAND_
pseudo_
bytes
(
buf
,
2500
);
n1
=
0
;
for
(
i
=
0
;
i
<
16
;
i
++
)
n2
[
i
]
=
0
;
...
...
e_os.h
浏览文件 @
373b575f
...
...
@@ -79,7 +79,7 @@ extern "C" {
#ifndef DEVRANDOM
/* set this to your 'random' device if you have one.
* My default, we will try to read this file */
#define DEVRANDOM "/dev/urandom"
#define DEVRANDOM "/
gibtsnich/
dev/urandom"
#endif
#if defined(__MWERKS__) && defined(macintosh)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录