Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
cb1b3aa1
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,发现更多精彩内容 >>
提交
cb1b3aa1
编写于
4月 19, 2011
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add AES CCM selftest.
上级
8c709683
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
109 addition
and
0 deletion
+109
-0
crypto/fips_err.h
crypto/fips_err.h
+1
-0
fips/aes/fips_aes_selftest.c
fips/aes/fips_aes_selftest.c
+102
-0
fips/fips.h
fips/fips.h
+2
-0
fips/fips_post.c
fips/fips_post.c
+2
-0
fips/fips_test_suite.c
fips/fips_test_suite.c
+2
-0
未找到文件。
crypto/fips_err.h
浏览文件 @
cb1b3aa1
...
...
@@ -99,6 +99,7 @@ static ERR_STRING_DATA FIPS_str_functs[]=
{
ERR_FUNC
(
FIPS_F_FIPS_RAND_SET_METHOD
),
"FIPS_rand_set_method"
},
{
ERR_FUNC
(
FIPS_F_FIPS_RAND_STATUS
),
"FIPS_rand_status"
},
{
ERR_FUNC
(
FIPS_F_FIPS_SELFTEST_AES
),
"FIPS_selftest_aes"
},
{
ERR_FUNC
(
FIPS_F_FIPS_SELFTEST_AES_CCM
),
"FIPS_selftest_aes_ccm"
},
{
ERR_FUNC
(
FIPS_F_FIPS_SELFTEST_AES_GCM
),
"FIPS_selftest_aes_gcm"
},
{
ERR_FUNC
(
FIPS_F_FIPS_SELFTEST_AES_XTS
),
"FIPS_selftest_aes_xts"
},
{
ERR_FUNC
(
FIPS_F_FIPS_SELFTEST_CMAC
),
"FIPS_selftest_cmac"
},
...
...
fips/aes/fips_aes_selftest.c
浏览文件 @
cb1b3aa1
...
...
@@ -97,6 +97,108 @@ int FIPS_selftest_aes()
return
ret
;
}
/* AES-CCM test data from NIST public test vectors */
static
const
unsigned
char
ccm_key
[]
=
{
0xce
,
0xb0
,
0x09
,
0xae
,
0xa4
,
0x45
,
0x44
,
0x51
,
0xfe
,
0xad
,
0xf0
,
0xe6
,
0xb3
,
0x6f
,
0x45
,
0x55
,
0x5d
,
0xd0
,
0x47
,
0x23
,
0xba
,
0xa4
,
0x48
,
0xe8
};
static
const
unsigned
char
ccm_nonce
[]
=
{
0x76
,
0x40
,
0x43
,
0xc4
,
0x94
,
0x60
,
0xb7
};
static
const
unsigned
char
ccm_adata
[]
=
{
0x6e
,
0x80
,
0xdd
,
0x7f
,
0x1b
,
0xad
,
0xf3
,
0xa1
,
0xc9
,
0xab
,
0x25
,
0xc7
,
0x5f
,
0x10
,
0xbd
,
0xe7
,
0x8c
,
0x23
,
0xfa
,
0x0e
,
0xb8
,
0xf9
,
0xaa
,
0xa5
,
0x3a
,
0xde
,
0xfb
,
0xf4
,
0xcb
,
0xf7
,
0x8f
,
0xe4
};
static
const
unsigned
char
ccm_pt
[]
=
{
0xc8
,
0xd2
,
0x75
,
0xf9
,
0x19
,
0xe1
,
0x7d
,
0x7f
,
0xe6
,
0x9c
,
0x2a
,
0x1f
,
0x58
,
0x93
,
0x9d
,
0xfe
,
0x4d
,
0x40
,
0x37
,
0x91
,
0xb5
,
0xdf
,
0x13
,
0x10
};
static
const
unsigned
char
ccm_ct
[]
=
{
0x8a
,
0x0f
,
0x3d
,
0x82
,
0x29
,
0xe4
,
0x8e
,
0x74
,
0x87
,
0xfd
,
0x95
,
0xa2
,
0x8a
,
0xd3
,
0x92
,
0xc8
,
0x0b
,
0x36
,
0x81
,
0xd4
,
0xfb
,
0xc7
,
0xbb
,
0xfd
};
static
const
unsigned
char
ccm_tag
[]
=
{
0x2d
,
0xd6
,
0xef
,
0x1c
,
0x45
,
0xd4
,
0xcc
,
0xb7
,
0x23
,
0xdc
,
0x07
,
0x44
,
0x14
,
0xdb
,
0x50
,
0x6d
};
int
FIPS_selftest_aes_ccm
(
void
)
{
int
ret
=
0
,
do_corrupt
=
0
;
unsigned
char
out
[
128
],
tag
[
16
];
EVP_CIPHER_CTX
ctx
;
FIPS_cipher_ctx_init
(
&
ctx
);
memset
(
out
,
0
,
sizeof
(
out
));
if
(
!
fips_post_started
(
FIPS_TEST_CCM
,
0
,
0
))
return
1
;
if
(
!
fips_post_corrupt
(
FIPS_TEST_CCM
,
0
,
NULL
))
do_corrupt
=
1
;
if
(
!
FIPS_cipherinit
(
&
ctx
,
EVP_aes_192_ccm
(),
NULL
,
NULL
,
1
))
goto
err
;
if
(
!
FIPS_cipher_ctx_ctrl
(
&
ctx
,
EVP_CTRL_CCM_SET_IVLEN
,
sizeof
(
ccm_nonce
),
NULL
))
goto
err
;
if
(
!
FIPS_cipher_ctx_ctrl
(
&
ctx
,
EVP_CTRL_CCM_SET_TAG
,
sizeof
(
ccm_tag
),
NULL
))
goto
err
;
if
(
!
FIPS_cipherinit
(
&
ctx
,
NULL
,
ccm_key
,
ccm_nonce
,
1
))
goto
err
;
if
(
FIPS_cipher
(
&
ctx
,
NULL
,
NULL
,
sizeof
(
ccm_pt
))
!=
sizeof
(
ccm_pt
))
goto
err
;
if
(
FIPS_cipher
(
&
ctx
,
NULL
,
ccm_adata
,
sizeof
(
ccm_adata
))
<
0
)
goto
err
;
if
(
FIPS_cipher
(
&
ctx
,
out
,
ccm_pt
,
sizeof
(
ccm_pt
))
!=
sizeof
(
ccm_ct
))
goto
err
;
if
(
!
FIPS_cipher_ctx_ctrl
(
&
ctx
,
EVP_CTRL_CCM_GET_TAG
,
16
,
tag
))
goto
err
;
if
(
memcmp
(
tag
,
ccm_tag
,
sizeof
(
ccm_tag
))
||
memcmp
(
out
,
ccm_ct
,
sizeof
(
ccm_ct
)))
goto
err
;
memset
(
out
,
0
,
sizeof
(
out
));
/* Modify expected tag value */
if
(
do_corrupt
)
tag
[
0
]
++
;
if
(
!
FIPS_cipherinit
(
&
ctx
,
EVP_aes_192_ccm
(),
NULL
,
NULL
,
0
))
goto
err
;
if
(
!
FIPS_cipher_ctx_ctrl
(
&
ctx
,
EVP_CTRL_CCM_SET_IVLEN
,
sizeof
(
ccm_nonce
),
NULL
))
goto
err
;
if
(
!
FIPS_cipher_ctx_ctrl
(
&
ctx
,
EVP_CTRL_CCM_SET_TAG
,
16
,
tag
))
goto
err
;
if
(
!
FIPS_cipherinit
(
&
ctx
,
NULL
,
ccm_key
,
ccm_nonce
,
0
))
goto
err
;
if
(
FIPS_cipher
(
&
ctx
,
NULL
,
NULL
,
sizeof
(
ccm_ct
))
!=
sizeof
(
ccm_ct
))
goto
err
;
if
(
FIPS_cipher
(
&
ctx
,
NULL
,
ccm_adata
,
sizeof
(
ccm_adata
))
<
0
)
goto
err
;
if
(
FIPS_cipher
(
&
ctx
,
out
,
ccm_ct
,
sizeof
(
ccm_ct
))
!=
sizeof
(
ccm_pt
))
goto
err
;
if
(
memcmp
(
out
,
ccm_pt
,
sizeof
(
ccm_pt
)))
goto
err
;
ret
=
1
;
err:
FIPS_cipher_ctx_cleanup
(
&
ctx
);
if
(
ret
==
0
)
{
fips_post_failed
(
FIPS_TEST_CCM
,
0
,
NULL
);
FIPSerr
(
FIPS_F_FIPS_SELFTEST_AES_CCM
,
FIPS_R_SELFTEST_FAILED
);
return
0
;
}
else
return
fips_post_success
(
FIPS_TEST_CCM
,
0
,
NULL
);
}
/* AES-GCM test data from NIST public test vectors */
static
const
unsigned
char
gcm_key
[]
=
{
...
...
fips/fips.h
浏览文件 @
cb1b3aa1
...
...
@@ -73,6 +73,7 @@ int FIPS_selftest(void);
int
FIPS_selftest_failed
(
void
);
void
FIPS_selftest_check
(
void
);
int
FIPS_selftest_sha1
(
void
);
int
FIPS_selftest_aes_ccm
(
void
);
int
FIPS_selftest_aes_gcm
(
void
);
int
FIPS_selftest_aes_xts
(
void
);
int
FIPS_selftest_aes
(
void
);
...
...
@@ -260,6 +261,7 @@ void ERR_load_FIPS_strings(void);
#define FIPS_F_FIPS_RAND_SET_METHOD 126
#define FIPS_F_FIPS_RAND_STATUS 127
#define FIPS_F_FIPS_SELFTEST_AES 128
#define FIPS_F_FIPS_SELFTEST_AES_CCM 145
#define FIPS_F_FIPS_SELFTEST_AES_GCM 129
#define FIPS_F_FIPS_SELFTEST_AES_XTS 144
#define FIPS_F_FIPS_SELFTEST_CMAC 130
...
...
fips/fips_post.c
浏览文件 @
cb1b3aa1
...
...
@@ -172,6 +172,8 @@ int FIPS_selftest(void)
rv
=
0
;
if
(
!
FIPS_selftest_aes
())
rv
=
0
;
if
(
!
FIPS_selftest_aes_ccm
())
rv
=
0
;
if
(
!
FIPS_selftest_aes_gcm
())
rv
=
0
;
if
(
!
FIPS_selftest_aes_xts
())
...
...
fips/fips_test_suite.c
浏览文件 @
cb1b3aa1
...
...
@@ -850,6 +850,8 @@ int main(int argc,char **argv)
}
else
if
(
!
strcmp
(
argv
[
1
],
"aes"
))
{
fail_id
=
FIPS_TEST_CIPHER
;
fail_sub
=
NID_aes_128_ecb
;
}
else
if
(
!
strcmp
(
argv
[
1
],
"aes-ccm"
))
{
fail_id
=
FIPS_TEST_CCM
;
}
else
if
(
!
strcmp
(
argv
[
1
],
"aes-gcm"
))
{
fail_id
=
FIPS_TEST_GCM
;
}
else
if
(
!
strcmp
(
argv
[
1
],
"aes-xts"
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录