Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
e45c6c4e
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,发现更多精彩内容 >>
提交
e45c6c4e
编写于
3月 07, 2011
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Uninstantiate and free functions for DRBG.
上级
ff4a19a4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
54 addition
and
11 deletion
+54
-11
fips/rand/fips_drbg_ctr.c
fips/rand/fips_drbg_ctr.c
+7
-0
fips/rand/fips_drbg_hash.c
fips/rand/fips_drbg_hash.c
+8
-0
fips/rand/fips_drbg_lib.c
fips/rand/fips_drbg_lib.c
+34
-11
fips/rand/fips_drbgvs.c
fips/rand/fips_drbgvs.c
+2
-0
fips/rand/fips_rand.h
fips/rand/fips_rand.h
+3
-0
未找到文件。
fips/rand/fips_drbg_ctr.c
浏览文件 @
e45c6c4e
...
...
@@ -350,6 +350,12 @@ static int drbg_ctr_generate(DRBG_CTX *dctx,
}
static
int
drbg_ctr_uninstantiate
(
DRBG_CTX
*
dctx
)
{
OPENSSL_cleanse
(
&
dctx
->
d
.
ctr
,
sizeof
(
DRBG_CTR_CTX
));
return
1
;
}
int
fips_drbg_ctr_init
(
DRBG_CTX
*
dctx
)
{
DRBG_CTR_CTX
*
cctx
=
&
dctx
->
d
.
ctr
;
...
...
@@ -377,6 +383,7 @@ int fips_drbg_ctr_init(DRBG_CTX *dctx)
dctx
->
instantiate
=
drbg_ctr_instantiate
;
dctx
->
reseed
=
drbg_ctr_reseed
;
dctx
->
generate
=
drbg_ctr_generate
;
dctx
->
uninstantiate
=
drbg_ctr_uninstantiate
;
cctx
->
keylen
=
keylen
;
...
...
fips/rand/fips_drbg_hash.c
浏览文件 @
e45c6c4e
...
...
@@ -306,6 +306,13 @@ static int drbg_hash_generate(DRBG_CTX *dctx,
return
1
;
}
static
int
drbg_hash_uninstantiate
(
DRBG_CTX
*
dctx
)
{
EVP_MD_CTX_cleanup
(
&
dctx
->
d
.
hash
.
mctx
);
OPENSSL_cleanse
(
&
dctx
->
d
.
hash
,
sizeof
(
DRBG_HASH_CTX
));
return
1
;
}
int
fips_drbg_hash_init
(
DRBG_CTX
*
dctx
)
{
const
EVP_MD
*
md
;
...
...
@@ -346,6 +353,7 @@ int fips_drbg_hash_init(DRBG_CTX *dctx)
dctx
->
instantiate
=
drbg_hash_instantiate
;
dctx
->
reseed
=
drbg_hash_reseed
;
dctx
->
generate
=
drbg_hash_generate
;
dctx
->
uninstantiate
=
drbg_hash_uninstantiate
;
dctx
->
d
.
hash
.
md
=
md
;
EVP_MD_CTX_init
(
&
hctx
->
mctx
);
...
...
fips/rand/fips_drbg_lib.c
浏览文件 @
e45c6c4e
...
...
@@ -62,30 +62,41 @@
/* Support framework for SP800-90 DRBGs */
DRBG_CTX
*
FIPS_drbg_new
(
int
type
,
unsigned
int
flags
)
static
int
fips_drbg_init
(
DRBG_CTX
*
dctx
,
int
type
,
unsigned
int
flags
)
{
int
rv
;
DRBG_CTX
*
dctx
;
dctx
=
OPENSSL_malloc
(
sizeof
(
DRBG_CTX
));
memset
(
dctx
,
0
,
sizeof
(
DRBG_CTX
));
dctx
->
status
=
DRBG_STATUS_UNINITIALISED
;
dctx
->
flags
=
flags
;
dctx
->
type
=
type
;
rv
=
fips_drbg_hash_init
(
dctx
);
if
(
rv
==
-
2
)
rv
=
fips_drbg_ctr_init
(
dctx
);
if
(
rv
<=
0
)
return
rv
;
}
DRBG_CTX
*
FIPS_drbg_new
(
int
type
,
unsigned
int
flags
)
{
DRBG_CTX
*
dctx
;
dctx
=
OPENSSL_malloc
(
sizeof
(
DRBG_CTX
));
if
(
!
dctx
)
return
NULL
;
if
(
fips_drbg_init
(
dctx
,
type
,
flags
)
<=
0
)
{
/* Fatal: cannot initialiase DRBG */
goto
err
;
OPENSSL_free
(
dctx
);
return
NULL
;
}
return
dctx
;
}
err:
if
(
dctx
)
OPENSSL_free
(
dctx
);
return
NULL
;
void
FIPS_drbg_free
(
DRBG_CTX
*
dctx
)
{
dctx
->
uninstantiate
(
dctx
);
OPENSSL_cleanse
(
dctx
,
sizeof
(
DRBG_CTX
));
OPENSSL_free
(
dctx
);
}
int
FIPS_drbg_instantiate
(
DRBG_CTX
*
dctx
,
...
...
@@ -224,6 +235,18 @@ int FIPS_drbg_generate(DRBG_CTX *dctx, unsigned char *out, size_t outlen,
return
1
;
}
int
FIPS_drbg_uninstantiate
(
DRBG_CTX
*
dctx
)
{
int
save_type
,
save_flags
,
rv
;
save_type
=
dctx
->
type
;
save_flags
=
dctx
->
flags
;
rv
=
dctx
->
uninstantiate
(
dctx
);
OPENSSL_cleanse
(
dctx
,
sizeof
(
DRBG_CTX
));
/* If method has problems uninstantiating, return error */
if
(
rv
<=
0
)
return
rv
;
return
fips_drbg_init
(
dctx
,
save_type
,
save_flags
);
}
int
FIPS_drbg_set_test_mode
(
DRBG_CTX
*
dctx
,
size_t
(
*
get_entropy
)(
DRBG_CTX
*
ctx
,
unsigned
char
*
out
,
...
...
fips/rand/fips_drbgvs.c
浏览文件 @
e45c6c4e
...
...
@@ -294,6 +294,8 @@ int main(int argc,char **argv)
if
(
gen
==
2
)
{
OutputValue
(
"ReturnedBits"
,
out
,
outlen
,
stdout
,
0
);
FIPS_drbg_free
(
dctx
);
dctx
=
NULL
;
gen
=
0
;
}
...
...
fips/rand/fips_rand.h
浏览文件 @
e45c6c4e
...
...
@@ -83,6 +83,9 @@ int FIPS_drbg_generate(DRBG_CTX *dctx, unsigned char *out, size_t outlen,
int
prediction_resistance
,
const
unsigned
char
*
adin
,
size_t
adinlen
);
int
FIPS_drbg_uninstantiate
(
DRBG_CTX
*
dctx
);
void
FIPS_drbg_free
(
DRBG_CTX
*
dctx
);
int
FIPS_drbg_set_test_mode
(
DRBG_CTX
*
dctx
,
size_t
(
*
get_entropy
)(
DRBG_CTX
*
ctx
,
unsigned
char
*
out
,
int
entropy
,
size_t
min_len
,
size_t
max_len
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录