Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
30745146
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
大约 1 年 前同步成功
通知
9
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
30745146
编写于
9月 14, 2016
作者:
R
Richard Levitte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rather than one variable for each passwd type, use one enum variable
Reviewed-by:
N
Rich Salz
<
rsalz@openssl.org
>
上级
49681ae1
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
49 addition
and
38 deletion
+49
-38
apps/passwd.c
apps/passwd.c
+49
-38
未找到文件。
apps/passwd.c
浏览文件 @
30745146
...
...
@@ -47,10 +47,18 @@ static unsigned const char cov_2char[64] = {
0x73
,
0x74
,
0x75
,
0x76
,
0x77
,
0x78
,
0x79
,
0x7A
};
typedef
enum
{
passwd_unset
=
0
,
passwd_crypt
,
passwd_md5
,
passwd_apr1
,
passwd_sha256
,
passwd_sha512
}
passwd_modes
;
static
int
do_passwd
(
int
passed_salt
,
char
**
salt_p
,
char
**
salt_malloc_p
,
char
*
passwd
,
BIO
*
out
,
int
quiet
,
int
table
,
int
reverse
,
size_t
pw_maxlen
,
int
usecrypt
,
int
use1
,
int
useapr1
,
int
use5
,
int
use6
);
int
reverse
,
size_t
pw_maxlen
,
passwd_modes
mode
);
typedef
enum
OPTION_choice
{
OPT_ERR
=
-
1
,
OPT_EOF
=
0
,
OPT_HELP
,
...
...
@@ -94,8 +102,11 @@ int passwd_main(int argc, char **argv)
int
in_noverify
=
0
;
#endif
int
passed_salt
=
0
,
quiet
=
0
,
table
=
0
,
reverse
=
0
;
int
ret
=
1
,
usecrypt
=
0
,
use1
=
0
,
useapr1
=
0
,
use5
=
0
,
use6
=
0
;
size_t
passwd_malloc_size
=
0
,
pw_maxlen
=
256
;
int
ret
=
1
;
passwd_modes
mode
=
passwd_unset
;
size_t
passwd_malloc_size
=
0
;
size_t
pw_maxlen
=
256
;
/* arbitrary limit, should be enough for most
* passwords */
prog
=
opt_init
(
argc
,
argv
,
passwd_options
);
while
((
o
=
opt_next
())
!=
OPT_EOF
)
{
...
...
@@ -129,20 +140,30 @@ int passwd_main(int argc, char **argv)
case
OPT_REVERSE
:
reverse
=
1
;
break
;
case
OPT_1
:
if
(
mode
!=
passwd_unset
)
goto
opthelp
;
mode
=
passwd_md5
;
break
;
case
OPT_5
:
use5
=
1
;
if
(
mode
!=
passwd_unset
)
goto
opthelp
;
mode
=
passwd_sha256
;
break
;
case
OPT_6
:
use6
=
1
;
break
;
case
OPT_1
:
use1
=
1
;
if
(
mode
!=
passwd_unset
)
goto
opthelp
;
mode
=
passwd_sha512
;
break
;
case
OPT_APR1
:
useapr1
=
1
;
if
(
mode
!=
passwd_unset
)
goto
opthelp
;
mode
=
passwd_apr1
;
break
;
case
OPT_CRYPT
:
usecrypt
=
1
;
if
(
mode
!=
passwd_unset
)
goto
opthelp
;
mode
=
passwd_crypt
;
break
;
case
OPT_SALT
:
passed_salt
=
1
;
...
...
@@ -166,25 +187,21 @@ int passwd_main(int argc, char **argv)
passwds
=
argv
;
}
if
(
!
usecrypt
&&
!
use5
&&
!
use6
&&
!
use1
&&
!
useapr1
)
{
if
(
mode
==
passwd_unset
)
{
/* use default */
usecrypt
=
1
;
}
if
(
usecrypt
+
use5
+
use6
+
use1
+
useapr1
>
1
)
{
/* conflict */
goto
opthelp
;
mode
=
passwd_crypt
;
}
# ifdef OPENSSL_NO_DES
if
(
use
crypt
)
if
(
mode
==
passwd_
crypt
)
goto
opthelp
;
# endif
# ifdef NO_MD5CRYPT_1
if
(
use1
||
use
apr1
)
if
(
mode
==
passwd_md5
||
mode
==
passwd_
apr1
)
goto
opthelp
;
# endif
# ifdef NO_SHACRYPT
if
(
use5
||
use6
)
if
(
mode
==
passwd_sha256
||
mode
==
passwd_sha512
)
goto
opthelp
;
# endif
...
...
@@ -203,11 +220,8 @@ int passwd_main(int argc, char **argv)
goto
end
;
}
if
(
use
crypt
)
if
(
mode
==
passwd_
crypt
)
pw_maxlen
=
8
;
else
if
(
use1
||
useapr1
)
pw_maxlen
=
256
;
/* arbitrary limit, should be enough for most
* passwords */
if
(
passwds
==
NULL
)
{
/* no passwords on the command line */
...
...
@@ -246,8 +260,7 @@ int passwd_main(int argc, char **argv)
do
{
/* loop over list of passwords */
passwd
=
*
passwds
++
;
if
(
!
do_passwd
(
passed_salt
,
&
salt
,
&
salt_malloc
,
passwd
,
bio_out
,
quiet
,
table
,
reverse
,
pw_maxlen
,
usecrypt
,
use1
,
useapr1
,
use5
,
use6
))
quiet
,
table
,
reverse
,
pw_maxlen
,
mode
))
goto
end
;
}
while
(
*
passwds
!=
NULL
);
...
...
@@ -273,8 +286,7 @@ int passwd_main(int argc, char **argv)
if
(
!
do_passwd
(
passed_salt
,
&
salt
,
&
salt_malloc
,
passwd
,
bio_out
,
quiet
,
table
,
reverse
,
pw_maxlen
,
usecrypt
,
use1
,
useapr1
,
use5
,
use6
))
table
,
reverse
,
pw_maxlen
,
mode
))
goto
end
;
}
done
=
(
r
<=
0
);
...
...
@@ -703,8 +715,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt)
static
int
do_passwd
(
int
passed_salt
,
char
**
salt_p
,
char
**
salt_malloc_p
,
char
*
passwd
,
BIO
*
out
,
int
quiet
,
int
table
,
int
reverse
,
size_t
pw_maxlen
,
int
usecrypt
,
int
use1
,
int
useapr1
,
int
use5
,
int
use6
)
int
reverse
,
size_t
pw_maxlen
,
passwd_modes
mode
)
{
char
*
hash
=
NULL
;
...
...
@@ -714,7 +725,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
/* first make sure we have a salt */
if
(
!
passed_salt
)
{
# ifndef OPENSSL_NO_DES
if
(
use
crypt
)
{
if
(
mode
==
passwd_
crypt
)
{
if
(
*
salt_malloc_p
==
NULL
)
{
*
salt_p
=
*
salt_malloc_p
=
app_malloc
(
3
,
"salt buffer"
);
}
...
...
@@ -731,7 +742,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
# endif
/* !OPENSSL_NO_DES */
# ifndef NO_MD5CRYPT_1
if
(
use1
||
use
apr1
)
{
if
(
mode
==
passwd_md5
||
mode
==
passwd_
apr1
)
{
int
i
;
if
(
*
salt_malloc_p
==
NULL
)
{
...
...
@@ -747,7 +758,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
# endif
/* !NO_MD5CRYPT_1 */
# ifndef NO_SHACRYPT
if
(
use5
||
use6
)
{
if
(
mode
==
passwd_sha256
||
mode
==
passwd_sha512
)
{
int
i
;
if
(
*
salt_malloc_p
==
NULL
)
{
...
...
@@ -780,16 +791,16 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
/* now compute password hash */
# ifndef OPENSSL_NO_DES
if
(
use
crypt
)
if
(
mode
==
passwd_
crypt
)
hash
=
DES_crypt
(
passwd
,
*
salt_p
);
# endif
# ifndef NO_MD5CRYPT_1
if
(
use1
||
use
apr1
)
hash
=
md5crypt
(
passwd
,
(
use1
?
"1"
:
"apr1"
),
*
salt_p
);
if
(
mode
==
passwd_md5
||
mode
==
passwd_
apr1
)
hash
=
md5crypt
(
passwd
,
(
mode
==
passwd_md5
?
"1"
:
"apr1"
),
*
salt_p
);
# endif
# ifndef NO_SHACRYPT
if
(
use5
||
use6
)
hash
=
shacrypt
(
passwd
,
(
use5
?
"5"
:
"6"
),
*
salt_p
);
if
(
mode
==
passwd_sha256
||
mode
==
passwd_sha512
)
hash
=
shacrypt
(
passwd
,
(
mode
==
passwd_sha256
?
"5"
:
"6"
),
*
salt_p
);
# endif
assert
(
hash
!=
NULL
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录