Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
9338f290
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,发现更多精彩内容 >>
提交
9338f290
编写于
4月 14, 2011
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revise fips_test_suite to use table of IDs for human readable strings.
Modify HMAC selftest callbacks to notify each digest type used.
上级
8038511c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
60 deletion
+67
-60
fips/aes/fips_aes_selftest.c
fips/aes/fips_aes_selftest.c
+1
-1
fips/fips_test_suite.c
fips/fips_test_suite.c
+40
-45
fips/hmac/fips_hmac_selftest.c
fips/hmac/fips_hmac_selftest.c
+26
-14
未找到文件。
fips/aes/fips_aes_selftest.c
浏览文件 @
9338f290
...
...
@@ -134,7 +134,7 @@ int FIPS_selftest_aes_gcm(void)
memset
(
tag
,
0
,
sizeof
(
tag
));
if
(
!
fips_post_started
(
FIPS_TEST_GCM
,
0
,
0
))
return
1
;
if
(
!
fips_post_corrupt
(
FIPS_TEST_
HMAC
,
0
,
NULL
))
if
(
!
fips_post_corrupt
(
FIPS_TEST_
GCM
,
0
,
NULL
))
do_corrupt
=
1
;
if
(
!
FIPS_cipherinit
(
&
ctx
,
EVP_aes_256_gcm
(),
NULL
,
NULL
,
1
))
goto
err
;
...
...
fips/fips_test_suite.c
浏览文件 @
9338f290
...
...
@@ -665,42 +665,39 @@ static void test_msg(const char *msg, int result)
printf
(
"%s...%s
\n
"
,
msg
,
result
?
"successful"
:
Fail
(
"Failed!"
));
}
static
const
char
*
post_get_sig
(
int
id
)
{
switch
(
id
)
{
case
EVP_PKEY_RSA
:
return
" (RSA)"
;
case
EVP_PKEY_DSA
:
return
" (DSA)"
;
case
EVP_PKEY_EC
:
return
" (ECDSA)"
;
default:
return
" (UNKNOWN)"
;
/* Table of IDs for POST translating between NIDs and names */
}
}
static
const
char
*
post_get_cipher
(
int
id
)
typedef
struct
{
static
char
out
[
128
];
switch
(
id
)
int
id
;
const
char
*
name
;
}
POST_ID
;
POST_ID
id_list
[]
=
{
{
NID_sha1
,
"SHA1"
},
{
NID_sha224
,
"SHA224"
},
{
NID_sha256
,
"SHA256"
},
{
NID_sha384
,
"SHA384"
},
{
NID_sha512
,
"SHA512"
},
{
EVP_PKEY_RSA
,
"RSA"
},
{
EVP_PKEY_DSA
,
"DSA"
},
{
EVP_PKEY_EC
,
"ECDSA"
},
{
NID_aes_128_ecb
,
"AES-128-ECB"
},
{
NID_des_ede3_ecb
,
"DES-EDE3-ECB"
},
{
0
,
NULL
}
};
static
const
char
*
lookup_id
(
int
id
)
{
POST_ID
*
n
;
static
char
out
[
40
];
for
(
n
=
id_list
;
n
->
name
;
n
++
)
{
case
NID_aes_128_ecb
:
return
" (AES-128-ECB)"
;
case
NID_des_ede3_ecb
:
return
" (DES-EDE3-ECB)"
;
default:
sprintf
(
out
,
" (NID=%d)"
,
id
);
return
out
;
if
(
n
->
id
==
id
)
return
n
->
name
;
}
sprintf
(
out
,
"ID=%d
\n
"
,
id
);
return
out
;
}
static
int
fail_id
=
-
1
;
...
...
@@ -719,12 +716,11 @@ static int post_cb(int op, int id, int subid, void *ex)
case
FIPS_TEST_DIGEST
:
idstr
=
"Digest"
;
if
(
subid
==
NID_sha1
)
exstr
=
" (SHA1)"
;
exstr
=
lookup_id
(
subid
);
break
;
case
FIPS_TEST_CIPHER
:
exstr
=
post_get_cipher
(
subid
);
exstr
=
lookup_id
(
subid
);
idstr
=
"Cipher"
;
break
;
...
...
@@ -733,12 +729,13 @@ static int post_cb(int op, int id, int subid, void *ex)
{
EVP_PKEY
*
pkey
=
ex
;
keytype
=
pkey
->
type
;
exstr
=
post_get_sig
(
keytype
);
exstr
=
lookup_id
(
keytype
);
}
idstr
=
"Signature"
;
break
;
case
FIPS_TEST_HMAC
:
exstr
=
lookup_id
(
subid
);
idstr
=
"HMAC"
;
break
;
...
...
@@ -747,11 +744,11 @@ static int post_cb(int op, int id, int subid, void *ex)
break
;
case
FIPS_TEST_GCM
:
idstr
=
"
HMAC
"
;
idstr
=
"
GCM
"
;
break
;
case
FIPS_TEST_CCM
:
idstr
=
"
HMAC
"
;
idstr
=
"
CCM
"
;
break
;
case
FIPS_TEST_XTS
:
...
...
@@ -771,7 +768,7 @@ static int post_cb(int op, int id, int subid, void *ex)
{
EVP_PKEY
*
pkey
=
ex
;
keytype
=
pkey
->
type
;
exstr
=
post_get_sig
(
keytype
);
exstr
=
lookup_id
(
keytype
);
}
idstr
=
"Pairwise Consistency"
;
break
;
...
...
@@ -797,15 +794,15 @@ static int post_cb(int op, int id, int subid, void *ex)
break
;
case
FIPS_POST_STARTED
:
printf
(
"
\t\t
%s%s test started
\n
"
,
idstr
,
exstr
);
printf
(
"
\t\t
%s
%s test started
\n
"
,
idstr
,
exstr
);
break
;
case
FIPS_POST_SUCCESS
:
printf
(
"
\t\t
%s%s test OK
\n
"
,
idstr
,
exstr
);
printf
(
"
\t\t
%s
%s test OK
\n
"
,
idstr
,
exstr
);
break
;
case
FIPS_POST_FAIL
:
printf
(
"
\t\t
%s%s test FAILED!!
\n
"
,
idstr
,
exstr
);
printf
(
"
\t\t
%s
%s test FAILED!!
\n
"
,
idstr
,
exstr
);
break
;
case
FIPS_POST_CORRUPT
:
...
...
@@ -813,7 +810,7 @@ static int post_cb(int op, int id, int subid, void *ex)
&&
(
fail_key
==
-
1
||
fail_key
==
keytype
)
&&
(
fail_sub
==
-
1
||
fail_sub
==
subid
))
{
printf
(
"
\t\t
%s%s test failure induced
\n
"
,
idstr
,
exstr
);
printf
(
"
\t\t
%s
%s test failure induced
\n
"
,
idstr
,
exstr
);
return
0
;
}
break
;
...
...
@@ -822,8 +819,6 @@ static int post_cb(int op, int id, int subid, void *ex)
return
1
;
}
int
main
(
int
argc
,
char
**
argv
)
{
int
bad_rsa
=
0
,
bad_dsa
=
0
;
...
...
fips/hmac/fips_hmac_selftest.c
浏览文件 @
9338f290
/* ====================================================================
* Copyright (c) 20
05
The OpenSSL Project. All rights reserved.
* Copyright (c) 20
11
The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -119,46 +119,58 @@ int FIPS_selftest_hmac()
unsigned
char
out
[
EVP_MAX_MD_SIZE
];
const
EVP_MD
*
md
;
const
HMAC_KAT
*
t
;
int
rv
=
0
,
do_corrupt
=
0
;
int
rv
=
1
,
subid
;
HMAC_CTX
c
;
HMAC_CTX_init
(
&
c
);
if
(
!
fips_post_started
(
FIPS_TEST_HMAC
,
0
,
0
))
return
1
;
if
(
!
fips_post_corrupt
(
FIPS_TEST_HMAC
,
0
,
NULL
))
do_corrupt
=
1
;
for
(
n
=
0
,
t
=
vector
;
n
<
sizeof
(
vector
)
/
sizeof
(
vector
[
0
]);
n
++
,
t
++
)
{
md
=
(
*
t
->
alg
)();
subid
=
M_EVP_MD_type
(
md
);
if
(
!
fips_post_started
(
FIPS_TEST_HMAC
,
subid
,
0
))
continue
;
if
(
!
HMAC_Init_ex
(
&
c
,
t
->
key
,
strlen
(
t
->
key
),
md
,
NULL
))
{
rv
=
-
1
;
goto
err
;
}
if
(
!
HMAC_Update
(
&
c
,
(
const
unsigned
char
*
)
t
->
iv
,
strlen
(
t
->
iv
)))
{
rv
=
-
1
;
goto
err
;
if
(
do_corrupt
)
}
if
(
!
fips_post_corrupt
(
FIPS_TEST_HMAC
,
subid
,
NULL
))
{
if
(
!
HMAC_Update
(
&
c
,
(
const
unsigned
char
*
)
t
->
iv
,
1
))
{
rv
=
-
1
;
goto
err
;
}
}
if
(
!
HMAC_Final
(
&
c
,
out
,
&
outlen
))
{
rv
=
-
1
;
goto
err
;
}
if
(
memcmp
(
out
,
t
->
kaval
,
outlen
))
{
FIPSerr
(
FIPS_F_FIPS_SELFTEST_HMAC
,
FIPS_R_SELFTEST_FAILED
);
goto
err
;
fips_post_failed
(
FIPS_TEST_HMAC
,
subid
,
NULL
);
rv
=
0
;
}
if
(
!
fips_post_success
(
FIPS_TEST_HMAC
,
subid
,
NULL
))
goto
err
;
}
rv
=
1
;
err:
HMAC_CTX_cleanup
(
&
c
);
if
(
rv
==
0
)
if
(
rv
==
-
1
)
{
fips_post_failed
(
FIPS_TEST_HMAC
,
0
,
NULL
);
r
eturn
0
;
fips_post_failed
(
FIPS_TEST_HMAC
,
subid
,
NULL
);
r
v
=
0
;
}
return
fips_post_success
(
FIPS_TEST_HMAC
,
0
,
NULL
)
;
return
rv
;
}
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录