Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
b5dd1787
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
9 个月 前同步成功
通知
8
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,体验更适合开发者的 AI 搜索 >>
提交
b5dd1787
编写于
4月 18, 2011
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix EVP CCM decrypt. Add decrypt support to algorithm test program.
上级
98279c16
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
16 deletion
+65
-16
CHANGES
CHANGES
+4
-3
crypto/evp/e_aes.c
crypto/evp/e_aes.c
+2
-2
fips/aes/fips_gcmtest.c
fips/aes/fips_gcmtest.c
+59
-11
未找到文件。
CHANGES
浏览文件 @
b5dd1787
...
...
@@ -4,9 +4,10 @@
Changes between 1.0.1 and 1.1.0 [xx XXX xxxx]
*) Initial untested CCM support via EVP. Interface is very similar to GCM
case except we must supply all data in one chunk (i.e. no update, final)
and the message length must be supplied if AAD is used.
*) CCM support via EVP. Interface is very similar to GCM case except we
must supply all data in one chunk (i.e. no update, final) and the
message length must be supplied if AAD is used. Add algorithm test
support.
[Steve Henson]
*) Initial version of POST overhaul. Add POST callback to allow the status
...
...
crypto/evp/e_aes.c
浏览文件 @
b5dd1787
...
...
@@ -625,7 +625,7 @@ static int aes_ccm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
case
EVP_CTRL_CCM_GET_TAG
:
if
(
!
c
->
encrypt
||
!
cctx
->
tag_set
)
return
0
;
if
(
CRYPTO_ccm128_tag
(
&
cctx
->
ccm
,
ptr
,
(
size_t
)
arg
))
if
(
!
CRYPTO_ccm128_tag
(
&
cctx
->
ccm
,
ptr
,
(
size_t
)
arg
))
return
0
;
cctx
->
tag_set
=
0
;
cctx
->
iv_set
=
0
;
...
...
@@ -707,7 +707,7 @@ static int aes_ccm(EVP_CIPHER_CTX *ctx, unsigned char *out,
if
(
!
CRYPTO_ccm128_decrypt
(
ccm
,
in
,
out
,
len
))
{
unsigned
char
tag
[
16
];
if
(
!
CRYPTO_ccm128_tag
(
ccm
,
tag
,
cctx
->
M
))
if
(
CRYPTO_ccm128_tag
(
ccm
,
tag
,
cctx
->
M
))
{
if
(
!
memcmp
(
tag
,
ctx
->
buf
,
cctx
->
M
))
rv
=
len
;
...
...
fips/aes/fips_gcmtest.c
浏览文件 @
b5dd1787
...
...
@@ -337,7 +337,7 @@ static void xtstest(FILE *in, FILE *out)
}
}
static
void
ccm
encryp
t
(
FILE
*
in
,
FILE
*
out
)
static
void
ccm
tes
t
(
FILE
*
in
,
FILE
*
out
)
{
char
buf
[
2048
];
char
lbuf
[
2048
];
...
...
@@ -347,26 +347,37 @@ static void ccmencrypt(FILE *in, FILE *out)
unsigned
char
*
Adata
=
NULL
,
*
Payload
=
NULL
;
unsigned
char
*
CT
=
NULL
;
int
Plen
=
-
1
,
Nlen
=
-
1
,
Tlen
=
-
1
,
Alen
=
-
1
;
int
decr
=
0
;
EVP_CIPHER_CTX
ctx
;
const
EVP_CIPHER
*
ccm
=
NULL
;
FIPS_cipher_ctx_init
(
&
ctx
);
while
(
fgets
(
buf
,
sizeof
buf
,
in
)
!=
NULL
)
{
char
*
p
;
fputs
(
buf
,
out
);
redo:
if
(
!
parse_line
(
&
keyword
,
&
value
,
lbuf
,
buf
))
continue
;
/* If surrounded by square brackets zap them */
if
(
keyword
[
0
]
==
'['
)
{
char
*
p
;
keyword
++
;
p
=
strchr
(
value
,
']'
);
if
(
p
)
*
p
=
0
;
}
/* See if we have a comma separated list of parameters
* if so copy rest of line back to buffer and redo later.
*/
p
=
strchr
(
value
,
','
);
if
(
p
)
{
*
p
=
0
;
strcpy
(
buf
,
p
+
1
);
decr
=
1
;
}
if
(
!
strcmp
(
keyword
,
"Plen"
))
Plen
=
atoi
(
value
);
else
if
(
!
strcmp
(
keyword
,
"Nlen"
))
...
...
@@ -375,7 +386,9 @@ static void ccmencrypt(FILE *in, FILE *out)
Tlen
=
atoi
(
value
);
else
if
(
!
strcmp
(
keyword
,
"Alen"
))
Alen
=
atoi
(
value
);
else
if
(
!
strcmp
(
keyword
,
"Key"
))
if
(
p
)
goto
redo
;
if
(
!
strcmp
(
keyword
,
"Key"
))
{
if
(
Key
)
OPENSSL_free
(
Key
);
...
...
@@ -403,7 +416,7 @@ static void ccmencrypt(FILE *in, FILE *out)
exit
(
1
);
}
}
else
if
(
!
strcmp
(
keyword
,
"Payload"
))
else
if
(
!
strcmp
(
keyword
,
"Payload"
)
&&
!
decr
)
{
Payload
=
hex2bin_m
(
value
,
&
l
);
if
(
Plen
&&
l
!=
Plen
)
...
...
@@ -421,6 +434,15 @@ static void ccmencrypt(FILE *in, FILE *out)
exit
(
1
);
}
}
else
if
(
!
strcmp
(
keyword
,
"CT"
)
&&
decr
)
{
CT
=
hex2bin_m
(
value
,
&
l
);
if
(
l
!=
(
Plen
+
Tlen
))
{
fprintf
(
stderr
,
"Inconsistent CT length
\n
"
);
exit
(
1
);
}
}
if
(
Payload
)
{
FIPS_cipherinit
(
&
ctx
,
ccm
,
NULL
,
NULL
,
1
);
...
...
@@ -438,7 +460,33 @@ static void ccmencrypt(FILE *in, FILE *out)
OPENSSL_free
(
CT
);
OPENSSL_free
(
Payload
);
CT
=
Payload
=
NULL
;
}
}
if
(
CT
)
{
int
rv
;
int
len
=
Plen
==
0
?
1
:
Plen
;
FIPS_cipherinit
(
&
ctx
,
ccm
,
NULL
,
NULL
,
0
);
FIPS_cipher_ctx_ctrl
(
&
ctx
,
EVP_CTRL_CCM_SET_IVLEN
,
Nlen
,
0
);
FIPS_cipher_ctx_ctrl
(
&
ctx
,
EVP_CTRL_CCM_SET_TAG
,
Tlen
,
CT
+
Plen
);
FIPS_cipherinit
(
&
ctx
,
NULL
,
Key
,
Nonce
,
0
);
FIPS_cipher
(
&
ctx
,
NULL
,
NULL
,
Plen
);
FIPS_cipher
(
&
ctx
,
NULL
,
Adata
,
Alen
);
Payload
=
OPENSSL_malloc
(
len
);
rv
=
FIPS_cipher
(
&
ctx
,
Payload
,
CT
,
Plen
);
if
(
rv
>=
0
)
{
if
(
rv
==
0
)
Payload
[
0
]
=
0
;
fputs
(
"Result = Pass
\n
"
,
out
);
OutputValue
(
"Payload"
,
Payload
,
len
,
out
,
0
);
}
else
fputs
(
"Result = Fail
\n
"
,
out
);
OPENSSL_free
(
CT
);
OPENSSL_free
(
Payload
);
CT
=
Payload
=
NULL
;
}
}
if
(
Key
)
OPENSSL_free
(
Key
);
...
...
@@ -450,7 +498,7 @@ static void ccmencrypt(FILE *in, FILE *out)
int
main
(
int
argc
,
char
**
argv
)
{
int
encrypt
;
int
xts
=
0
,
ccm
enc
=
0
;
int
xts
=
0
,
ccm
=
0
;
FILE
*
in
,
*
out
;
if
(
argc
==
4
)
{
...
...
@@ -484,8 +532,8 @@ int main(int argc,char **argv)
encrypt
=
2
;
else
if
(
!
strcmp
(
argv
[
1
],
"-decrypt"
))
encrypt
=
0
;
else
if
(
!
strcmp
(
argv
[
1
],
"-ccm
encrypt
"
))
ccm
enc
=
1
;
else
if
(
!
strcmp
(
argv
[
1
],
"-ccm"
))
ccm
=
1
;
else
if
(
!
strcmp
(
argv
[
1
],
"-xts"
))
xts
=
1
;
else
...
...
@@ -494,8 +542,8 @@ int main(int argc,char **argv)
exit
(
1
);
}
if
(
ccm
enc
)
ccm
encryp
t
(
in
,
out
);
if
(
ccm
)
ccm
tes
t
(
in
,
out
);
else
if
(
xts
)
xtstest
(
in
,
out
);
else
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录