Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
2aaec9cc
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看板
提交
2aaec9cc
编写于
10月 29, 2003
作者:
G
Geoff Thorpe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update any code that was using deprecated functions so that everything builds
and links with OPENSSL_NO_DEPRECATED defined.
上级
9d473aa2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
88 addition
and
55 deletion
+88
-55
CHANGES
CHANGES
+3
-1
apps/dhparam.c
apps/dhparam.c
+14
-10
apps/gendh.c
apps/gendh.c
+10
-7
apps/genrsa.c
apps/genrsa.c
+10
-5
apps/req.c
apps/req.c
+13
-7
apps/s_server.c
apps/s_server.c
+6
-1
crypto/bn/bntest.c
crypto/bn/bntest.c
+11
-6
crypto/dh/dhtest.c
crypto/dh/dhtest.c
+10
-6
crypto/dsa/dsatest.c
crypto/dsa/dsatest.c
+11
-12
未找到文件。
CHANGES
浏览文件 @
2aaec9cc
...
@@ -5,7 +5,9 @@
...
@@ -5,7 +5,9 @@
Changes between 0.9.7c and 0.9.8 [xx XXX xxxx]
Changes between 0.9.7c and 0.9.8 [xx XXX xxxx]
*) Ensure that deprecated functions do not get compiled when
*) Ensure that deprecated functions do not get compiled when
OPENSSL_NO_DEPRECATED is defined.
OPENSSL_NO_DEPRECATED is defined. Some "openssl" subcommands and a few of
the self-tests were still using deprecated key-generation functions so
these have been updated also.
[Geoff Thorpe]
[Geoff Thorpe]
*) Reorganise PKCS#7 code to separate the digest location functionality
*) Reorganise PKCS#7 code to separate the digest location functionality
...
...
apps/dhparam.c
浏览文件 @
2aaec9cc
...
@@ -142,7 +142,7 @@
...
@@ -142,7 +142,7 @@
* -C
* -C
*/
*/
static
void
MS_CALLBACK
dh_cb
(
int
p
,
int
n
,
void
*
arg
);
static
int
MS_CALLBACK
dh_cb
(
int
p
,
int
n
,
BN_GENCB
*
cb
);
int
MAIN
(
int
,
char
**
);
int
MAIN
(
int
,
char
**
);
...
@@ -294,6 +294,8 @@ bad:
...
@@ -294,6 +294,8 @@ bad:
if
(
num
)
{
if
(
num
)
{
BN_GENCB
cb
;
BN_GENCB_set
(
&
cb
,
dh_cb
,
bio_err
);
if
(
!
app_RAND_load_file
(
NULL
,
bio_err
,
1
)
&&
inrand
==
NULL
)
if
(
!
app_RAND_load_file
(
NULL
,
bio_err
,
1
)
&&
inrand
==
NULL
)
{
{
BIO_printf
(
bio_err
,
"warning, not much extra random data, consider using the -rand option
\n
"
);
BIO_printf
(
bio_err
,
"warning, not much extra random data, consider using the -rand option
\n
"
);
...
@@ -305,12 +307,13 @@ bad:
...
@@ -305,12 +307,13 @@ bad:
#ifndef OPENSSL_NO_DSA
#ifndef OPENSSL_NO_DSA
if
(
dsaparam
)
if
(
dsaparam
)
{
{
DSA
*
dsa
;
DSA
*
dsa
=
DSA_new
()
;
BIO_printf
(
bio_err
,
"Generating DSA parameters, %d bit long prime
\n
"
,
num
);
BIO_printf
(
bio_err
,
"Generating DSA parameters, %d bit long prime
\n
"
,
num
);
dsa
=
DSA_generate_parameters
(
num
,
NULL
,
0
,
NULL
,
NULL
,
dh_cb
,
bio_err
);
if
(
!
dsa
||
!
DSA_generate_parameters_ex
(
dsa
,
num
,
if
(
dsa
==
NULL
)
NULL
,
0
,
NULL
,
NULL
,
&
cb
)
)
{
{
if
(
dsa
)
DSA_free
(
dsa
);
ERR_print_errors
(
bio_err
);
ERR_print_errors
(
bio_err
);
goto
end
;
goto
end
;
}
}
...
@@ -326,12 +329,12 @@ bad:
...
@@ -326,12 +329,12 @@ bad:
else
else
#endif
#endif
{
{
dh
=
DH_new
();
BIO_printf
(
bio_err
,
"Generating DH parameters, %d bit long safe prime, generator %d
\n
"
,
num
,
g
);
BIO_printf
(
bio_err
,
"Generating DH parameters, %d bit long safe prime, generator %d
\n
"
,
num
,
g
);
BIO_printf
(
bio_err
,
"This is going to take a long time
\n
"
);
BIO_printf
(
bio_err
,
"This is going to take a long time
\n
"
);
dh
=
DH_generate_parameters
(
num
,
g
,
dh_cb
,
bio_err
);
if
(
!
dh
||
!
DH_generate_parameters_ex
(
dh
,
num
,
g
,
&
cb
))
if
(
dh
==
NULL
)
{
{
if
(
dh
)
DH_free
(
dh
);
ERR_print_errors
(
bio_err
);
ERR_print_errors
(
bio_err
);
goto
end
;
goto
end
;
}
}
...
@@ -534,7 +537,7 @@ end:
...
@@ -534,7 +537,7 @@ end:
}
}
/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
static
void
MS_CALLBACK
dh_cb
(
int
p
,
int
n
,
void
*
arg
)
static
int
MS_CALLBACK
dh_cb
(
int
p
,
int
n
,
BN_GENCB
*
cb
)
{
{
char
c
=
'*'
;
char
c
=
'*'
;
...
@@ -542,11 +545,12 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
...
@@ -542,11 +545,12 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
3
)
c
=
'\n'
;
if
(
p
==
3
)
c
=
'\n'
;
BIO_write
(
(
BIO
*
)
arg
,
&
c
,
1
);
BIO_write
(
cb
->
arg
,
&
c
,
1
);
(
void
)
BIO_flush
(
(
BIO
*
)
arg
);
(
void
)
BIO_flush
(
cb
->
arg
);
#ifdef LINT
#ifdef LINT
p
=
n
;
p
=
n
;
#endif
#endif
return
1
;
}
}
#endif
#endif
apps/gendh.c
浏览文件 @
2aaec9cc
...
@@ -81,12 +81,13 @@
...
@@ -81,12 +81,13 @@
#undef PROG
#undef PROG
#define PROG gendh_main
#define PROG gendh_main
static
void
MS_CALLBACK
dh_cb
(
int
p
,
int
n
,
void
*
arg
);
static
int
MS_CALLBACK
dh_cb
(
int
p
,
int
n
,
BN_GENCB
*
cb
);
int
MAIN
(
int
,
char
**
);
int
MAIN
(
int
,
char
**
);
int
MAIN
(
int
argc
,
char
**
argv
)
int
MAIN
(
int
argc
,
char
**
argv
)
{
{
BN_GENCB
cb
;
#ifndef OPENSSL_NO_ENGINE
#ifndef OPENSSL_NO_ENGINE
ENGINE
*
e
=
NULL
;
ENGINE
*
e
=
NULL
;
#endif
#endif
...
@@ -102,6 +103,7 @@ int MAIN(int argc, char **argv)
...
@@ -102,6 +103,7 @@ int MAIN(int argc, char **argv)
apps_startup
();
apps_startup
();
BN_GENCB_set
(
&
cb
,
dh_cb
,
bio_err
);
if
(
bio_err
==
NULL
)
if
(
bio_err
==
NULL
)
if
((
bio_err
=
BIO_new
(
BIO_s_file
()))
!=
NULL
)
if
((
bio_err
=
BIO_new
(
BIO_s_file
()))
!=
NULL
)
BIO_set_fp
(
bio_err
,
stderr
,
BIO_NOCLOSE
|
BIO_FP_TEXT
);
BIO_set_fp
(
bio_err
,
stderr
,
BIO_NOCLOSE
|
BIO_FP_TEXT
);
...
@@ -199,10 +201,10 @@ bad:
...
@@ -199,10 +201,10 @@ bad:
BIO_printf
(
bio_err
,
"Generating DH parameters, %d bit long safe prime, generator %d
\n
"
,
num
,
g
);
BIO_printf
(
bio_err
,
"Generating DH parameters, %d bit long safe prime, generator %d
\n
"
,
num
,
g
);
BIO_printf
(
bio_err
,
"This is going to take a long time
\n
"
);
BIO_printf
(
bio_err
,
"This is going to take a long time
\n
"
);
dh
=
DH_generate_parameters
(
num
,
g
,
dh_cb
,
bio_err
);
if
(
dh
==
NULL
)
goto
end
;
if
(((
dh
=
DH_new
())
==
NULL
)
||
!
DH_generate_parameters_ex
(
dh
,
num
,
g
,
&
cb
))
goto
end
;
app_RAND_write_file
(
NULL
,
bio_err
);
app_RAND_write_file
(
NULL
,
bio_err
);
if
(
!
PEM_write_bio_DHparams
(
out
,
dh
))
if
(
!
PEM_write_bio_DHparams
(
out
,
dh
))
...
@@ -217,7 +219,7 @@ end:
...
@@ -217,7 +219,7 @@ end:
OPENSSL_EXIT
(
ret
);
OPENSSL_EXIT
(
ret
);
}
}
static
void
MS_CALLBACK
dh_cb
(
int
p
,
int
n
,
void
*
arg
)
static
int
MS_CALLBACK
dh_cb
(
int
p
,
int
n
,
BN_GENCB
*
cb
)
{
{
char
c
=
'*'
;
char
c
=
'*'
;
...
@@ -225,10 +227,11 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
...
@@ -225,10 +227,11 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
3
)
c
=
'\n'
;
if
(
p
==
3
)
c
=
'\n'
;
BIO_write
(
(
BIO
*
)
arg
,
&
c
,
1
);
BIO_write
(
cb
->
arg
,
&
c
,
1
);
(
void
)
BIO_flush
(
(
BIO
*
)
arg
);
(
void
)
BIO_flush
(
cb
->
arg
);
#ifdef LINT
#ifdef LINT
p
=
n
;
p
=
n
;
#endif
#endif
return
1
;
}
}
#endif
#endif
apps/genrsa.c
浏览文件 @
2aaec9cc
...
@@ -81,12 +81,13 @@
...
@@ -81,12 +81,13 @@
#undef PROG
#undef PROG
#define PROG genrsa_main
#define PROG genrsa_main
static
void
MS_CALLBACK
genrsa_cb
(
int
p
,
int
n
,
void
*
arg
);
static
int
MS_CALLBACK
genrsa_cb
(
int
p
,
int
n
,
BN_GENCB
*
cb
);
int
MAIN
(
int
,
char
**
);
int
MAIN
(
int
,
char
**
);
int
MAIN
(
int
argc
,
char
**
argv
)
int
MAIN
(
int
argc
,
char
**
argv
)
{
{
BN_GENCB
cb
;
#ifndef OPENSSL_NO_ENGINE
#ifndef OPENSSL_NO_ENGINE
ENGINE
*
e
=
NULL
;
ENGINE
*
e
=
NULL
;
#endif
#endif
...
@@ -105,6 +106,7 @@ int MAIN(int argc, char **argv)
...
@@ -105,6 +106,7 @@ int MAIN(int argc, char **argv)
BIO
*
out
=
NULL
;
BIO
*
out
=
NULL
;
apps_startup
();
apps_startup
();
BN_GENCB_set
(
&
cb
,
genrsa_cb
,
bio_err
);
if
(
bio_err
==
NULL
)
if
(
bio_err
==
NULL
)
if
((
bio_err
=
BIO_new
(
BIO_s_file
()))
!=
NULL
)
if
((
bio_err
=
BIO_new
(
BIO_s_file
()))
!=
NULL
)
...
@@ -239,7 +241,9 @@ bad:
...
@@ -239,7 +241,9 @@ bad:
BIO_printf
(
bio_err
,
"Generating RSA private key, %d bit long modulus
\n
"
,
BIO_printf
(
bio_err
,
"Generating RSA private key, %d bit long modulus
\n
"
,
num
);
num
);
rsa
=
RSA_generate_key
(
num
,
f4
,
genrsa_cb
,
bio_err
);
if
(((
rsa
=
RSA_new
())
==
NULL
)
||
!
RSA_generate_key_ex
(
rsa
,
num
,
f4
,
&
cb
))
goto
err
;
app_RAND_write_file
(
NULL
,
bio_err
);
app_RAND_write_file
(
NULL
,
bio_err
);
...
@@ -277,7 +281,7 @@ err:
...
@@ -277,7 +281,7 @@ err:
OPENSSL_EXIT
(
ret
);
OPENSSL_EXIT
(
ret
);
}
}
static
void
MS_CALLBACK
genrsa_cb
(
int
p
,
int
n
,
void
*
arg
)
static
int
MS_CALLBACK
genrsa_cb
(
int
p
,
int
n
,
BN_GENCB
*
cb
)
{
{
char
c
=
'*'
;
char
c
=
'*'
;
...
@@ -285,11 +289,12 @@ static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
...
@@ -285,11 +289,12 @@ static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
3
)
c
=
'\n'
;
if
(
p
==
3
)
c
=
'\n'
;
BIO_write
(
(
BIO
*
)
arg
,
&
c
,
1
);
BIO_write
(
cb
->
arg
,
&
c
,
1
);
(
void
)
BIO_flush
(
(
BIO
*
)
arg
);
(
void
)
BIO_flush
(
cb
->
arg
);
#ifdef LINT
#ifdef LINT
p
=
n
;
p
=
n
;
#endif
#endif
return
1
;
}
}
#else
/* !OPENSSL_NO_RSA */
#else
/* !OPENSSL_NO_RSA */
...
...
apps/req.c
浏览文件 @
2aaec9cc
...
@@ -135,7 +135,7 @@ static int add_attribute_object(X509_REQ *req, char *text,
...
@@ -135,7 +135,7 @@ static int add_attribute_object(X509_REQ *req, char *text,
static
int
add_DN_object
(
X509_NAME
*
n
,
char
*
text
,
char
*
def
,
char
*
value
,
static
int
add_DN_object
(
X509_NAME
*
n
,
char
*
text
,
char
*
def
,
char
*
value
,
int
nid
,
int
n_min
,
int
n_max
,
unsigned
long
chtype
,
int
mval
);
int
nid
,
int
n_min
,
int
n_max
,
unsigned
long
chtype
,
int
mval
);
#ifndef OPENSSL_NO_RSA
#ifndef OPENSSL_NO_RSA
static
void
MS_CALLBACK
req_cb
(
int
p
,
int
n
,
void
*
arg
);
static
int
MS_CALLBACK
req_cb
(
int
p
,
int
n
,
BN_GENCB
*
cb
);
#endif
#endif
static
int
req_check_len
(
int
len
,
int
n_min
,
int
n_max
);
static
int
req_check_len
(
int
len
,
int
n_min
,
int
n_max
);
static
int
check_end
(
char
*
str
,
char
*
end
);
static
int
check_end
(
char
*
str
,
char
*
end
);
...
@@ -712,6 +712,8 @@ bad:
...
@@ -712,6 +712,8 @@ bad:
if
(
newreq
&&
(
pkey
==
NULL
))
if
(
newreq
&&
(
pkey
==
NULL
))
{
{
BN_GENCB
cb
;
BN_GENCB_set
(
&
cb
,
req_cb
,
bio_err
);
char
*
randfile
=
NCONF_get_string
(
req_conf
,
SECTION
,
"RANDFILE"
);
char
*
randfile
=
NCONF_get_string
(
req_conf
,
SECTION
,
"RANDFILE"
);
if
(
randfile
==
NULL
)
if
(
randfile
==
NULL
)
ERR_clear_error
();
ERR_clear_error
();
...
@@ -740,10 +742,13 @@ bad:
...
@@ -740,10 +742,13 @@ bad:
#ifndef OPENSSL_NO_RSA
#ifndef OPENSSL_NO_RSA
if
(
pkey_type
==
TYPE_RSA
)
if
(
pkey_type
==
TYPE_RSA
)
{
{
if
(
!
EVP_PKEY_assign_RSA
(
pkey
,
RSA
*
rsa
=
RSA_new
();
RSA_generate_key
(
newkey
,
0x10001
,
if
(
!
rsa
||
!
RSA_generate_key_ex
(
rsa
,
newkey
,
0x10001
,
&
cb
)
||
req_cb
,
bio_err
)))
!
EVP_PKEY_assign_RSA
(
pkey
,
rsa
))
{
if
(
rsa
)
RSA_free
(
rsa
);
goto
end
;
goto
end
;
}
}
}
else
else
#endif
#endif
...
@@ -1610,7 +1615,7 @@ err:
...
@@ -1610,7 +1615,7 @@ err:
}
}
#ifndef OPENSSL_NO_RSA
#ifndef OPENSSL_NO_RSA
static
void
MS_CALLBACK
req_cb
(
int
p
,
int
n
,
void
*
arg
)
static
int
MS_CALLBACK
req_cb
(
int
p
,
int
n
,
BN_GENCB
*
cb
)
{
{
char
c
=
'*'
;
char
c
=
'*'
;
...
@@ -1618,11 +1623,12 @@ static void MS_CALLBACK req_cb(int p, int n, void *arg)
...
@@ -1618,11 +1623,12 @@ static void MS_CALLBACK req_cb(int p, int n, void *arg)
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
3
)
c
=
'\n'
;
if
(
p
==
3
)
c
=
'\n'
;
BIO_write
(
(
BIO
*
)
arg
,
&
c
,
1
);
BIO_write
(
cb
->
arg
,
&
c
,
1
);
(
void
)
BIO_flush
(
(
BIO
*
)
arg
);
(
void
)
BIO_flush
(
cb
->
arg
);
#ifdef LINT
#ifdef LINT
p
=
n
;
p
=
n
;
#endif
#endif
return
1
;
}
}
#endif
#endif
...
...
apps/s_server.c
浏览文件 @
2aaec9cc
...
@@ -1785,7 +1785,12 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
...
@@ -1785,7 +1785,12 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
BIO_printf
(
bio_err
,
"Generating temp (%d bit) RSA key..."
,
keylength
);
BIO_printf
(
bio_err
,
"Generating temp (%d bit) RSA key..."
,
keylength
);
(
void
)
BIO_flush
(
bio_err
);
(
void
)
BIO_flush
(
bio_err
);
}
}
rsa_tmp
=
RSA_generate_key
(
keylength
,
RSA_F4
,
NULL
,
NULL
);
if
(((
rsa_tmp
=
RSA_new
())
==
NULL
)
||
!
RSA_generate_key_ex
(
rsa_tmp
,
keylength
,
RSA_F4
,
NULL
))
{
if
(
rsa_tmp
)
RSA_free
(
rsa_tmp
);
rsa_tmp
=
NULL
;
}
if
(
!
s_quiet
)
if
(
!
s_quiet
)
{
{
BIO_printf
(
bio_err
,
"
\n
"
);
BIO_printf
(
bio_err
,
"
\n
"
);
...
...
crypto/bn/bntest.c
浏览文件 @
2aaec9cc
...
@@ -1502,7 +1502,7 @@ int test_gf2m_mod_solve_quad(BIO *bp,BN_CTX *ctx)
...
@@ -1502,7 +1502,7 @@ int test_gf2m_mod_solve_quad(BIO *bp,BN_CTX *ctx)
return
ret
;
return
ret
;
}
}
static
void
genprime_cb
(
int
p
,
int
n
,
void
*
arg
)
static
int
genprime_cb
(
int
p
,
int
n
,
BN_GENCB
*
arg
)
{
{
char
c
=
'*'
;
char
c
=
'*'
;
...
@@ -1512,12 +1512,12 @@ static void genprime_cb(int p, int n, void *arg)
...
@@ -1512,12 +1512,12 @@ static void genprime_cb(int p, int n, void *arg)
if
(
p
==
3
)
c
=
'\n'
;
if
(
p
==
3
)
c
=
'\n'
;
putc
(
c
,
stderr
);
putc
(
c
,
stderr
);
fflush
(
stderr
);
fflush
(
stderr
);
(
void
)
n
;
return
1
;
(
void
)
arg
;
}
}
int
test_kron
(
BIO
*
bp
,
BN_CTX
*
ctx
)
int
test_kron
(
BIO
*
bp
,
BN_CTX
*
ctx
)
{
{
BN_GENCB
cb
;
BIGNUM
*
a
,
*
b
,
*
r
,
*
t
;
BIGNUM
*
a
,
*
b
,
*
r
,
*
t
;
int
i
;
int
i
;
int
legendre
,
kronecker
;
int
legendre
,
kronecker
;
...
@@ -1528,6 +1528,8 @@ int test_kron(BIO *bp, BN_CTX *ctx)
...
@@ -1528,6 +1528,8 @@ int test_kron(BIO *bp, BN_CTX *ctx)
r
=
BN_new
();
r
=
BN_new
();
t
=
BN_new
();
t
=
BN_new
();
if
(
a
==
NULL
||
b
==
NULL
||
r
==
NULL
||
t
==
NULL
)
goto
err
;
if
(
a
==
NULL
||
b
==
NULL
||
r
==
NULL
||
t
==
NULL
)
goto
err
;
BN_GENCB_set
(
&
cb
,
genprime_cb
,
NULL
);
/* We test BN_kronecker(a, b, ctx) just for b odd (Jacobi symbol).
/* We test BN_kronecker(a, b, ctx) just for b odd (Jacobi symbol).
* In this case we know that if b is prime, then BN_kronecker(a, b, ctx)
* In this case we know that if b is prime, then BN_kronecker(a, b, ctx)
...
@@ -1538,7 +1540,7 @@ int test_kron(BIO *bp, BN_CTX *ctx)
...
@@ -1538,7 +1540,7 @@ int test_kron(BIO *bp, BN_CTX *ctx)
* don't want to test whether b is prime but whether BN_kronecker
* don't want to test whether b is prime but whether BN_kronecker
* works.) */
* works.) */
if
(
!
BN_generate_prime
(
b
,
512
,
0
,
NULL
,
NULL
,
genprime_cb
,
NULL
))
goto
err
;
if
(
!
BN_generate_prime
_ex
(
b
,
512
,
0
,
NULL
,
NULL
,
&
cb
))
goto
err
;
b
->
neg
=
rand_neg
();
b
->
neg
=
rand_neg
();
putc
(
'\n'
,
stderr
);
putc
(
'\n'
,
stderr
);
...
@@ -1606,6 +1608,7 @@ int test_kron(BIO *bp, BN_CTX *ctx)
...
@@ -1606,6 +1608,7 @@ int test_kron(BIO *bp, BN_CTX *ctx)
int
test_sqrt
(
BIO
*
bp
,
BN_CTX
*
ctx
)
int
test_sqrt
(
BIO
*
bp
,
BN_CTX
*
ctx
)
{
{
BN_GENCB
cb
;
BIGNUM
*
a
,
*
p
,
*
r
;
BIGNUM
*
a
,
*
p
,
*
r
;
int
i
,
j
;
int
i
,
j
;
int
ret
=
0
;
int
ret
=
0
;
...
@@ -1614,7 +1617,9 @@ int test_sqrt(BIO *bp, BN_CTX *ctx)
...
@@ -1614,7 +1617,9 @@ int test_sqrt(BIO *bp, BN_CTX *ctx)
p
=
BN_new
();
p
=
BN_new
();
r
=
BN_new
();
r
=
BN_new
();
if
(
a
==
NULL
||
p
==
NULL
||
r
==
NULL
)
goto
err
;
if
(
a
==
NULL
||
p
==
NULL
||
r
==
NULL
)
goto
err
;
BN_GENCB_set
(
&
cb
,
genprime_cb
,
NULL
);
for
(
i
=
0
;
i
<
16
;
i
++
)
for
(
i
=
0
;
i
<
16
;
i
++
)
{
{
if
(
i
<
8
)
if
(
i
<
8
)
...
@@ -1628,7 +1633,7 @@ int test_sqrt(BIO *bp, BN_CTX *ctx)
...
@@ -1628,7 +1633,7 @@ int test_sqrt(BIO *bp, BN_CTX *ctx)
if
(
!
BN_set_word
(
a
,
32
))
goto
err
;
if
(
!
BN_set_word
(
a
,
32
))
goto
err
;
if
(
!
BN_set_word
(
r
,
2
*
i
+
1
))
goto
err
;
if
(
!
BN_set_word
(
r
,
2
*
i
+
1
))
goto
err
;
if
(
!
BN_generate_prime
(
p
,
256
,
0
,
a
,
r
,
genprime_cb
,
NULL
))
goto
err
;
if
(
!
BN_generate_prime
_ex
(
p
,
256
,
0
,
a
,
r
,
&
cb
))
goto
err
;
putc
(
'\n'
,
stderr
);
putc
(
'\n'
,
stderr
);
}
}
p
->
neg
=
rand_neg
();
p
->
neg
=
rand_neg
();
...
...
crypto/dh/dhtest.c
浏览文件 @
2aaec9cc
...
@@ -89,12 +89,13 @@ int main(int argc, char *argv[])
...
@@ -89,12 +89,13 @@ int main(int argc, char *argv[])
#define MS_CALLBACK
#define MS_CALLBACK
#endif
#endif
static
void
MS_CALLBACK
cb
(
int
p
,
int
n
,
void
*
arg
);
static
int
MS_CALLBACK
cb
(
int
p
,
int
n
,
BN_GENCB
*
arg
);
static
const
char
rnd_seed
[]
=
"string to make the random number generator think it has entropy"
;
static
const
char
rnd_seed
[]
=
"string to make the random number generator think it has entropy"
;
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
BN_GENCB
_cb
;
DH
*
a
;
DH
*
a
;
DH
*
b
=
NULL
;
DH
*
b
=
NULL
;
char
buf
[
12
];
char
buf
[
12
];
...
@@ -116,8 +117,10 @@ int main(int argc, char *argv[])
...
@@ -116,8 +117,10 @@ int main(int argc, char *argv[])
if
(
out
==
NULL
)
EXIT
(
1
);
if
(
out
==
NULL
)
EXIT
(
1
);
BIO_set_fp
(
out
,
stdout
,
BIO_NOCLOSE
);
BIO_set_fp
(
out
,
stdout
,
BIO_NOCLOSE
);
a
=
DH_generate_parameters
(
64
,
DH_GENERATOR_5
,
cb
,
out
);
BN_GENCB_set
(
&
_cb
,
&
cb
,
out
);
if
(
a
==
NULL
)
goto
err
;
if
(((
a
=
DH_new
())
==
NULL
)
||
!
DH_generate_parameters_ex
(
a
,
64
,
DH_GENERATOR_5
,
&
_cb
))
goto
err
;
if
(
!
DH_check
(
a
,
&
i
))
goto
err
;
if
(
!
DH_check
(
a
,
&
i
))
goto
err
;
if
(
i
&
DH_CHECK_P_NOT_PRIME
)
if
(
i
&
DH_CHECK_P_NOT_PRIME
)
...
@@ -201,7 +204,7 @@ err:
...
@@ -201,7 +204,7 @@ err:
return
(
ret
);
return
(
ret
);
}
}
static
void
MS_CALLBACK
cb
(
int
p
,
int
n
,
void
*
arg
)
static
int
MS_CALLBACK
cb
(
int
p
,
int
n
,
BN_GENCB
*
arg
)
{
{
char
c
=
'*'
;
char
c
=
'*'
;
...
@@ -209,10 +212,11 @@ static void MS_CALLBACK cb(int p, int n, void *arg)
...
@@ -209,10 +212,11 @@ static void MS_CALLBACK cb(int p, int n, void *arg)
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
2
)
c
=
'*'
;
if
(
p
==
3
)
c
=
'\n'
;
if
(
p
==
3
)
c
=
'\n'
;
BIO_write
(
(
BIO
*
)
arg
,
&
c
,
1
);
BIO_write
(
arg
->
arg
,
&
c
,
1
);
(
void
)
BIO_flush
(
(
BIO
*
)
arg
);
(
void
)
BIO_flush
(
arg
->
arg
);
#ifdef LINT
#ifdef LINT
p
=
n
;
p
=
n
;
#endif
#endif
return
1
;
}
}
#endif
#endif
crypto/dsa/dsatest.c
浏览文件 @
2aaec9cc
...
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
...
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
#define MS_CALLBACK
#define MS_CALLBACK
#endif
#endif
static
void
MS_CALLBACK
dsa_cb
(
int
p
,
int
n
,
void
*
arg
);
static
int
MS_CALLBACK
dsa_cb
(
int
p
,
int
n
,
BN_GENCB
*
arg
);
/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to
/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to
* FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */
* FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */
...
@@ -135,6 +135,7 @@ static BIO *bio_err=NULL;
...
@@ -135,6 +135,7 @@ static BIO *bio_err=NULL;
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
BN_GENCB
cb
;
DSA
*
dsa
=
NULL
;
DSA
*
dsa
=
NULL
;
int
counter
,
ret
=
0
,
i
,
j
;
int
counter
,
ret
=
0
,
i
,
j
;
unsigned
char
buf
[
256
];
unsigned
char
buf
[
256
];
...
@@ -154,7 +155,10 @@ int main(int argc, char **argv)
...
@@ -154,7 +155,10 @@ int main(int argc, char **argv)
BIO_printf
(
bio_err
,
"test generation of DSA parameters
\n
"
);
BIO_printf
(
bio_err
,
"test generation of DSA parameters
\n
"
);
dsa
=
DSA_generate_parameters
(
512
,
seed
,
20
,
&
counter
,
&
h
,
dsa_cb
,
bio_err
);
BN_GENCB_set
(
&
cb
,
dsa_cb
,
bio_err
);
if
(((
dsa
=
DSA_new
())
==
NULL
)
||
!
DSA_generate_parameters_ex
(
dsa
,
512
,
seed
,
20
,
&
counter
,
&
h
,
&
cb
))
goto
end
;
BIO_printf
(
bio_err
,
"seed
\n
"
);
BIO_printf
(
bio_err
,
"seed
\n
"
);
for
(
i
=
0
;
i
<
20
;
i
+=
4
)
for
(
i
=
0
;
i
<
20
;
i
+=
4
)
...
@@ -221,13 +225,7 @@ end:
...
@@ -221,13 +225,7 @@ end:
return
(
0
);
return
(
0
);
}
}
static
int
cb_exit
(
int
ec
)
static
int
MS_CALLBACK
dsa_cb
(
int
p
,
int
n
,
BN_GENCB
*
arg
)
{
EXIT
(
ec
);
return
(
0
);
/* To keep some compilers quiet */
}
static
void
MS_CALLBACK
dsa_cb
(
int
p
,
int
n
,
void
*
arg
)
{
{
char
c
=
'*'
;
char
c
=
'*'
;
static
int
ok
=
0
,
num
=
0
;
static
int
ok
=
0
,
num
=
0
;
...
@@ -236,13 +234,14 @@ static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
...
@@ -236,13 +234,14 @@ static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
1
)
c
=
'+'
;
if
(
p
==
2
)
{
c
=
'*'
;
ok
++
;
}
if
(
p
==
2
)
{
c
=
'*'
;
ok
++
;
}
if
(
p
==
3
)
c
=
'\n'
;
if
(
p
==
3
)
c
=
'\n'
;
BIO_write
(
arg
,
&
c
,
1
);
BIO_write
(
arg
->
arg
,
&
c
,
1
);
(
void
)
BIO_flush
(
arg
);
(
void
)
BIO_flush
(
arg
->
arg
);
if
(
!
ok
&&
(
p
==
0
)
&&
(
num
>
1
))
if
(
!
ok
&&
(
p
==
0
)
&&
(
num
>
1
))
{
{
BIO_printf
((
BIO
*
)
arg
,
"error in dsatest
\n
"
);
BIO_printf
((
BIO
*
)
arg
,
"error in dsatest
\n
"
);
cb_exit
(
1
)
;
return
0
;
}
}
return
1
;
}
}
#endif
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录