Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
d827c5ed
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看板
提交
d827c5ed
编写于
12月 06, 2014
作者:
M
Matt Caswell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tests for OCB mode
Reviewed-by:
N
Tim Hudson
<
tjh@openssl.org
>
上级
e6b336ef
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
11 deletion
+45
-11
crypto/evp/evp_test.c
crypto/evp/evp_test.c
+24
-11
crypto/evp/evptests.txt
crypto/evp/evptests.txt
+21
-0
未找到文件。
crypto/evp/evp_test.c
浏览文件 @
d827c5ed
...
...
@@ -178,7 +178,7 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
EVP_CIPHER_CTX_set_flags
(
ctx
,
EVP_CIPHER_CTX_FLAG_WRAP_ALLOW
);
if
(
encdec
!=
0
)
{
if
(
mode
==
EVP_CIPH_GCM_MODE
)
if
(
(
mode
==
EVP_CIPH_GCM_MODE
)
||
(
mode
==
EVP_CIPH_OCB_MODE
)
)
{
if
(
!
EVP_EncryptInit_ex
(
ctx
,
c
,
NULL
,
NULL
,
NULL
))
{
...
...
@@ -186,12 +186,19 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
ERR_print_errors_fp
(
stderr
);
test1_exit
(
10
);
}
if
(
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_
GCM_
SET_IVLEN
,
in
,
NULL
))
if
(
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_SET_IVLEN
,
in
,
NULL
))
{
fprintf
(
stderr
,
"IV length set failed
\n
"
);
ERR_print_errors_fp
(
stderr
);
test1_exit
(
11
);
}
if
((
mode
==
EVP_CIPH_OCB_MODE
)
&&
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_OCB_SET_TAGLEN
,
tn
,
NULL
))
{
fprintf
(
stderr
,
"Tag length set failed
\n
"
);
ERR_print_errors_fp
(
stderr
);
test1_exit
(
15
);
}
if
(
!
EVP_EncryptInit_ex
(
ctx
,
NULL
,
NULL
,
key
,
iv
))
{
fprintf
(
stderr
,
"Key/IV set failed
\n
"
);
...
...
@@ -290,13 +297,12 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
hexdump
(
stderr
,
"Expected"
,
ciphertext
,
cn
);
test1_exit
(
9
);
}
if
(
mode
==
EVP_CIPH_GCM_MODE
||
mode
==
EVP_CIPH_CCM_MODE
)
if
((
mode
==
EVP_CIPH_GCM_MODE
)
||
(
mode
==
EVP_CIPH_OCB_MODE
)
||
(
mode
==
EVP_CIPH_CCM_MODE
))
{
unsigned
char
rtag
[
16
];
/* Note: EVP_CTRL_CCM_GET_TAG has same value as
* EVP_CTRL_GCM_GET_TAG
*/
if
(
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_GCM_GET_TAG
,
tn
,
rtag
))
if
(
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_GET_TAG
,
tn
,
rtag
))
{
fprintf
(
stderr
,
"Get tag failed
\n
"
);
ERR_print_errors_fp
(
stderr
);
...
...
@@ -314,27 +320,34 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn,
if
(
encdec
<=
0
)
{
if
(
mode
==
EVP_CIPH_GCM_MODE
)
if
(
(
mode
==
EVP_CIPH_GCM_MODE
)
||
(
mode
==
EVP_CIPH_OCB_MODE
)
)
{
if
(
!
EVP_DecryptInit_ex
(
ctx
,
c
,
NULL
,
NULL
,
NULL
))
{
fprintf
(
stderr
,
"
En
cryptInit failed
\n
"
);
fprintf
(
stderr
,
"
De
cryptInit failed
\n
"
);
ERR_print_errors_fp
(
stderr
);
test1_exit
(
10
);
}
if
(
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_
GCM_
SET_IVLEN
,
in
,
NULL
))
if
(
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_SET_IVLEN
,
in
,
NULL
))
{
fprintf
(
stderr
,
"IV length set failed
\n
"
);
ERR_print_errors_fp
(
stderr
);
test1_exit
(
11
);
}
if
((
mode
==
EVP_CIPH_OCB_MODE
)
&&
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_OCB_SET_TAGLEN
,
tn
,
NULL
))
{
fprintf
(
stderr
,
"Tag length set failed
\n
"
);
ERR_print_errors_fp
(
stderr
);
test1_exit
(
15
);
}
if
(
!
EVP_DecryptInit_ex
(
ctx
,
NULL
,
NULL
,
key
,
iv
))
{
fprintf
(
stderr
,
"Key/IV set failed
\n
"
);
ERR_print_errors_fp
(
stderr
);
test1_exit
(
12
);
}
if
(
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_
GCM_
SET_TAG
,
tn
,
(
void
*
)
tag
))
if
(
!
EVP_CIPHER_CTX_ctrl
(
ctx
,
EVP_CTRL_SET_TAG
,
tn
,
(
void
*
)
tag
))
{
fprintf
(
stderr
,
"Set tag failed
\n
"
);
ERR_print_errors_fp
(
stderr
);
...
...
crypto/evp/evptests.txt
浏览文件 @
d827c5ed
...
...
@@ -372,6 +372,27 @@ aes-128-gcm:00000000000000000000000000000000:ffffffff000000000000000000000000000
# 80 bytes plaintext, submitted by Intel
aes-128-gcm:843ffcf5d2b72694d19ed01d01249412:dbcca32ebf9b804617c3aa9e:000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f:6268c6fa2a80b2d137467f092f657ac04d89be2beaa623d61b5a868c8f03ff95d3dcee23ad2f1ab3a6c80eaf4b140eb05de3457f0fbc111a6b43d0763aa422a3013cf1dc37fe417d1fbfc449b75d4cc5:00000000000000000000000000000000101112131415161718191a1b1c1d1e1f:3b629ccfbc1119b7319e1dce2cd6fd6d
#AES OCB Test vectors
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B::::197B9C3C441D3C83EAFB2BEF633B9182
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:0001020304050607:92B657130A74B85A:0001020304050607:16DC76A46D47E1EAD537209E8A96D14E
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:::0001020304050607:98B91552C8C009185044E30A6EB2FE21
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:0001020304050607:92B657130A74B85A::971EFFCAE19AD4716F88E87B871FBEED
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:000102030405060708090A0B0C0D0E0F:BEA5E8798DBE7110031C144DA0B26122:000102030405060708090A0B0C0D0E0F:776C9924D6723A1FC4524532AC3E5BEB
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:::000102030405060708090A0B0C0D0E0F:7DDB8E6CEA6814866212509619B19CC6
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:000102030405060708090A0B0C0D0E0F:BEA5E8798DBE7110031C144DA0B26122::13CC8B747807121A4CBB3E4BD6B456AF
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:000102030405060708090A0B0C0D0E0F1011121314151617:BEA5E8798DBE7110031C144DA0B26122FCFCEE7A2A8D4D48:000102030405060708090A0B0C0D0E0F1011121314151617:5FA94FC3F38820F1DC3F3D1FD4E55E1C
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:::000102030405060708090A0B0C0D0E0F1011121314151617:282026DA3068BC9FA118681D559F10F6
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:000102030405060708090A0B0C0D0E0F1011121314151617:BEA5E8798DBE7110031C144DA0B26122FCFCEE7A2A8D4D48::6EF2F52587FDA0ED97DC7EEDE241DF68
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:BEA5E8798DBE7110031C144DA0B26122CEAAB9B05DF771A657149D53773463CB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:B2A040DD3BD5164372D76D7BB6824240
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:::000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:E1E072633BADE51A60E85951D9C42A1B
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F:BEA5E8798DBE7110031C144DA0B26122CEAAB9B05DF771A657149D53773463CB::4A3BAE824465CFDAF8C41FC50C7DF9D9
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627:BEA5E8798DBE7110031C144DA0B26122CEAAB9B05DF771A657149D53773463CB68C65778B058A635:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627:659C623211DEEA0DE30D2C381879F4C8
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:::000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627:7AEB7A69A1687DD082CA27B0D9A37096
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627:BEA5E8798DBE7110031C144DA0B26122CEAAB9B05DF771A657149D53773463CB68C65778B058A635::060C8467F4ABAB5E8B3C2067A2E115DC
#AES OCB Non standard test vectors - generated from reference implementation
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627:09a4fd29de949d9a9aa9924248422097ad4883b4713e6c214ff6567ada08a96766fc4e2ee3e3a5a1:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627:1b6c44f34e3abb3cbf8976e7
aes-128-ocb:000102030405060708090A0B0C0D0E0F:000102030405060708090A0B0C0D0E:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627:5e2fa7367ffbdb3938845cfd415fcc71ec79634eb31451609d27505f5e2978f43c44213d8fa441ee:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627:1ad62009901f40cba7cd7156f94a7324
# AES XTS test vectors from IEEE Std 1619-2007
aes-128-xts:0000000000000000000000000000000000000000000000000000000000000000:00000000000000000000000000000000:0000000000000000000000000000000000000000000000000000000000000000:917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e
aes-128-xts:1111111111111111111111111111111122222222222222222222222222222222:33333333330000000000000000000000:4444444444444444444444444444444444444444444444444444444444444444:c454185e6a16936e39334038acef838bfb186fff7480adc4289382ecd6d394f0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录