Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
39090878
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看板
提交
39090878
编写于
7月 31, 2013
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extend DH parameter generation support.
Add support for DH parameter generation using DSA methods including FIPS 186-3.
上级
d3cc91ee
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
121 addition
and
2 deletion
+121
-2
crypto/dh/dh.h
crypto/dh/dh.h
+10
-1
crypto/dh/dh_pmeth.c
crypto/dh/dh_pmeth.c
+111
-1
未找到文件。
crypto/dh/dh.h
浏览文件 @
39090878
...
...
@@ -243,6 +243,14 @@ DH *DH_get_2048_256(void);
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)
#define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)
#define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)
#define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)
...
...
@@ -258,7 +266,8 @@ DH *DH_get_2048_256(void);
#define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1)
#define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2)
#define EVP_PKEY_CTRL_DH_RFC5114 (EVP_PKEY_ALG_CTRL + 3)
#define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN (EVP_PKEY_ALG_CTRL + 4)
#define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE (EVP_PKEY_ALG_CTRL + 5)
/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
...
...
crypto/dh/dh_pmeth.c
浏览文件 @
39090878
...
...
@@ -62,6 +62,9 @@
#include <openssl/evp.h>
#include <openssl/dh.h>
#include <openssl/bn.h>
#ifndef OPENSSL_NO_DSA
#include <openssl/dsa.h>
#endif
#include "evp_locl.h"
/* DH pkey context structure */
...
...
@@ -72,6 +75,8 @@ typedef struct
int
prime_len
;
int
generator
;
int
use_dsa
;
int
subprime_len
;
const
EVP_MD
*
md
;
int
rfc5114_param
;
/* Keygen callback info */
int
gentmp
[
2
];
...
...
@@ -85,8 +90,10 @@ static int pkey_dh_init(EVP_PKEY_CTX *ctx)
if
(
!
dctx
)
return
0
;
dctx
->
prime_len
=
1024
;
dctx
->
subprime_len
=
-
1
;
dctx
->
generator
=
2
;
dctx
->
use_dsa
=
0
;
dctx
->
md
=
NULL
;
dctx
->
rfc5114_param
=
0
;
ctx
->
data
=
dctx
;
...
...
@@ -104,8 +111,10 @@ static int pkey_dh_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
sctx
=
src
->
data
;
dctx
=
dst
->
data
;
dctx
->
prime_len
=
sctx
->
prime_len
;
dctx
->
subprime_len
=
sctx
->
subprime_len
;
dctx
->
generator
=
sctx
->
generator
;
dctx
->
use_dsa
=
sctx
->
use_dsa
;
dctx
->
md
=
sctx
->
md
;
dctx
->
rfc5114_param
=
sctx
->
rfc5114_param
;
return
1
;
}
...
...
@@ -128,10 +137,29 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
dctx
->
prime_len
=
p1
;
return
1
;
case
EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN
:
if
(
dctx
->
use_dsa
==
0
)
return
-
2
;
dctx
->
subprime_len
=
p1
;
return
1
;
case
EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR
:
if
(
dctx
->
use_dsa
)
return
-
2
;
dctx
->
generator
=
p1
;
return
1
;
case
EVP_PKEY_CTRL_DH_PARAMGEN_TYPE
:
#ifdef OPENSSL_NO_DSA
if
(
p1
!=
0
)
return
-
2
;
#else
if
(
p1
<
0
||
p1
>
2
)
return
-
2
;
#endif
dctx
->
use_dsa
=
p1
;
return
1
;
case
EVP_PKEY_CTRL_DH_RFC5114
:
if
(
p1
<
1
||
p1
>
3
)
return
-
2
;
...
...
@@ -148,7 +176,7 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
}
}
static
int
pkey_dh_ctrl_str
(
EVP_PKEY_CTX
*
ctx
,
const
char
*
type
,
const
char
*
value
)
{
...
...
@@ -174,9 +202,75 @@ static int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx,
len
=
atoi
(
value
);
return
EVP_PKEY_CTX_set_dh_paramgen_generator
(
ctx
,
len
);
}
if
(
!
strcmp
(
type
,
"dh_paramgen_subprime_len"
))
{
int
len
;
len
=
atoi
(
value
);
return
EVP_PKEY_CTX_set_dh_paramgen_subprime_len
(
ctx
,
len
);
}
if
(
!
strcmp
(
type
,
"dh_paramgen_type"
))
{
int
typ
;
typ
=
atoi
(
value
);
return
EVP_PKEY_CTX_set_dh_paramgen_type
(
ctx
,
typ
);
}
return
-
2
;
}
#ifndef OPENSSL_NO_DSA
extern
int
dsa_builtin_paramgen
(
DSA
*
ret
,
size_t
bits
,
size_t
qbits
,
const
EVP_MD
*
evpmd
,
const
unsigned
char
*
seed_in
,
size_t
seed_len
,
unsigned
char
*
seed_out
,
int
*
counter_ret
,
unsigned
long
*
h_ret
,
BN_GENCB
*
cb
);
extern
int
dsa_builtin_paramgen2
(
DSA
*
ret
,
size_t
L
,
size_t
N
,
const
EVP_MD
*
evpmd
,
const
unsigned
char
*
seed_in
,
size_t
seed_len
,
int
idx
,
unsigned
char
*
seed_out
,
int
*
counter_ret
,
unsigned
long
*
h_ret
,
BN_GENCB
*
cb
);
static
DSA
*
dsa_dh_generate
(
DH_PKEY_CTX
*
dctx
,
BN_GENCB
*
pcb
)
{
DSA
*
ret
;
int
rv
=
0
;
int
prime_len
=
dctx
->
prime_len
;
int
subprime_len
=
dctx
->
subprime_len
;
const
EVP_MD
*
md
=
dctx
->
md
;
if
(
dctx
->
use_dsa
>
2
)
return
NULL
;
ret
=
DSA_new
();
if
(
!
ret
)
return
NULL
;
if
(
subprime_len
==
-
1
)
{
if
(
prime_len
>=
2048
)
subprime_len
=
256
;
else
subprime_len
=
160
;
}
if
(
md
==
NULL
)
{
if
(
prime_len
>=
2048
)
md
=
EVP_sha256
();
else
md
=
EVP_sha1
();
}
if
(
dctx
->
use_dsa
==
1
)
rv
=
dsa_builtin_paramgen
(
ret
,
prime_len
,
subprime_len
,
md
,
NULL
,
0
,
NULL
,
NULL
,
NULL
,
pcb
);
else
if
(
dctx
->
use_dsa
==
2
)
rv
=
dsa_builtin_paramgen2
(
ret
,
prime_len
,
subprime_len
,
md
,
NULL
,
0
,
-
1
,
NULL
,
NULL
,
NULL
,
pcb
);
if
(
rv
<=
0
)
{
DSA_free
(
ret
);
return
NULL
;
}
return
ret
;
}
#endif
static
int
pkey_dh_paramgen
(
EVP_PKEY_CTX
*
ctx
,
EVP_PKEY
*
pkey
)
{
DH
*
dh
=
NULL
;
...
...
@@ -213,11 +307,27 @@ static int pkey_dh_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
}
else
pcb
=
NULL
;
#ifndef OPENSSL_NO_DSA
if
(
dctx
->
use_dsa
)
{
DSA
*
dsa_dh
;
dsa_dh
=
dsa_dh_generate
(
dctx
,
pcb
);
if
(
!
dsa_dh
)
return
0
;
dh
=
DSA_dup_DH
(
dsa_dh
);
DSA_free
(
dsa_dh
);
if
(
!
dh
)
return
0
;
EVP_PKEY_assign
(
pkey
,
EVP_PKEY_DHX
,
dh
);
return
1
;
}
#endif
dh
=
DH_new
();
if
(
!
dh
)
return
0
;
ret
=
DH_generate_parameters_ex
(
dh
,
dctx
->
prime_len
,
dctx
->
generator
,
pcb
);
if
(
ret
)
EVP_PKEY_assign_DH
(
pkey
,
dh
);
else
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录