Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
e9be051f
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
接近 2 年 前同步成功
通知
12
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看板
提交
e9be051f
编写于
11月 24, 2010
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use generalise mac API for SSL key generation
上级
46fc96d4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
36 deletion
+36
-36
ssl/dtls1.h
ssl/dtls1.h
+2
-8
ssl/t1_enc.c
ssl/t1_enc.c
+34
-28
未找到文件。
ssl/dtls1.h
浏览文件 @
e9be051f
...
@@ -57,14 +57,8 @@
...
@@ -57,14 +57,8 @@
*
*
*/
*/
#ifndef HEADER_DTLS1_H
#ifndef HEADER_DTLS1_H
#define HEADER_DTLS1_H
#define HEADER_DTLS1_H
/* Unless _XOPEN_SOURCE_EXTENDED is defined, struct timeval will not be
properly defined with DEC C, at least on VMS */
#if defined(__DECC) || defined(__DECCXX)
#define _XOPEN_SOURCE_EXTENDED
#endif
#include <openssl/buffer.h>
#include <openssl/buffer.h>
#include <openssl/pqueue.h>
#include <openssl/pqueue.h>
...
...
ssl/t1_enc.c
浏览文件 @
e9be051f
...
@@ -159,68 +159,73 @@ static int tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
...
@@ -159,68 +159,73 @@ static int tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
unsigned
char
*
out
,
int
olen
)
unsigned
char
*
out
,
int
olen
)
{
{
int
chunk
;
int
chunk
;
unsigned
in
t
j
;
size_
t
j
;
HMAC_CTX
ctx
;
EVP_MD_CTX
ctx
,
ctx_tmp
;
HMAC_CTX
ctx_tmp
;
EVP_PKEY
*
mac_key
;
unsigned
char
A1
[
EVP_MAX_MD_SIZE
];
unsigned
char
A1
[
EVP_MAX_MD_SIZE
];
unsigned
in
t
A1_len
;
size_
t
A1_len
;
int
ret
=
0
;
int
ret
=
0
;
chunk
=
EVP_MD_size
(
md
);
chunk
=
EVP_MD_size
(
md
);
OPENSSL_assert
(
chunk
>=
0
);
OPENSSL_assert
(
chunk
>=
0
);
HMAC_CTX_init
(
&
ctx
);
EVP_MD_CTX_init
(
&
ctx
);
HMAC_CTX_init
(
&
ctx_tmp
);
EVP_MD_CTX_init
(
&
ctx_tmp
);
if
(
!
HMAC_Init_ex
(
&
ctx
,
sec
,
sec_len
,
md
,
NULL
))
mac_key
=
EVP_PKEY_new_mac_key
(
EVP_PKEY_HMAC
,
NULL
,
sec
,
sec_len
);
if
(
!
mac_key
)
goto
err
;
if
(
!
EVP_DigestSignInit
(
&
ctx
,
NULL
,
md
,
NULL
,
mac_key
))
goto
err
;
goto
err
;
if
(
!
HMAC_Init_ex
(
&
ctx_tmp
,
sec
,
sec_len
,
md
,
NULL
))
if
(
!
EVP_DigestSignInit
(
&
ctx_tmp
,
NULL
,
md
,
NULL
,
mac_key
))
goto
err
;
goto
err
;
if
(
seed1
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed1
,
seed1_len
))
if
(
seed1
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed1
,
seed1_len
))
goto
err
;
goto
err
;
if
(
seed2
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed2
,
seed2_len
))
if
(
seed2
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed2
,
seed2_len
))
goto
err
;
goto
err
;
if
(
seed3
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed3
,
seed3_len
))
if
(
seed3
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed3
,
seed3_len
))
goto
err
;
goto
err
;
if
(
seed4
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed4
,
seed4_len
))
if
(
seed4
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed4
,
seed4_len
))
goto
err
;
goto
err
;
if
(
seed5
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed5
,
seed5_len
))
if
(
seed5
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed5
,
seed5_len
))
goto
err
;
goto
err
;
if
(
!
HMAC_
Final
(
&
ctx
,
A1
,
&
A1_len
))
if
(
!
EVP_DigestSign
Final
(
&
ctx
,
A1
,
&
A1_len
))
goto
err
;
goto
err
;
for
(;;)
for
(;;)
{
{
if
(
!
HMAC_Init_ex
(
&
ctx
,
NULL
,
0
,
NULL
,
NULL
))
/* re-init */
/* Reinit mac contexts */
if
(
!
EVP_DigestSignInit
(
&
ctx
,
NULL
,
md
,
NULL
,
mac_key
))
goto
err
;
goto
err
;
if
(
!
HMAC_Init_ex
(
&
ctx_tmp
,
NULL
,
0
,
NULL
,
NULL
))
/* re-init */
if
(
!
EVP_DigestSignInit
(
&
ctx_tmp
,
NULL
,
md
,
NULL
,
mac_key
))
goto
err
;
goto
err
;
if
(
!
HMAC_
Update
(
&
ctx
,
A1
,
A1_len
))
if
(
!
EVP_DigestSign
Update
(
&
ctx
,
A1
,
A1_len
))
goto
err
;
goto
err
;
if
(
!
HMAC_
Update
(
&
ctx_tmp
,
A1
,
A1_len
))
if
(
!
EVP_DigestSign
Update
(
&
ctx_tmp
,
A1
,
A1_len
))
goto
err
;
goto
err
;
if
(
seed1
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed1
,
seed1_len
))
if
(
seed1
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed1
,
seed1_len
))
goto
err
;
goto
err
;
if
(
seed2
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed2
,
seed2_len
))
if
(
seed2
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed2
,
seed2_len
))
goto
err
;
goto
err
;
if
(
seed3
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed3
,
seed3_len
))
if
(
seed3
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed3
,
seed3_len
))
goto
err
;
goto
err
;
if
(
seed4
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed4
,
seed4_len
))
if
(
seed4
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed4
,
seed4_len
))
goto
err
;
goto
err
;
if
(
seed5
!=
NULL
&&
!
HMAC_
Update
(
&
ctx
,
seed5
,
seed5_len
))
if
(
seed5
&&
!
EVP_DigestSign
Update
(
&
ctx
,
seed5
,
seed5_len
))
goto
err
;
goto
err
;
if
(
olen
>
chunk
)
if
(
olen
>
chunk
)
{
{
if
(
!
HMAC_
Final
(
&
ctx
,
out
,
&
j
))
if
(
!
EVP_DigestSign
Final
(
&
ctx
,
out
,
&
j
))
goto
err
;
goto
err
;
out
+=
j
;
out
+=
j
;
olen
-=
j
;
olen
-=
j
;
if
(
!
HMAC_Final
(
&
ctx_tmp
,
A1
,
&
A1_len
))
/* calc the next A1 value */
/* calc the next A1 value */
if
(
!
EVP_DigestSignFinal
(
&
ctx_tmp
,
A1
,
&
A1_len
))
goto
err
;
goto
err
;
}
}
else
/* last one */
else
/* last one */
{
{
if
(
!
HMAC_
Final
(
&
ctx
,
A1
,
&
A1_len
))
if
(
!
EVP_DigestSign
Final
(
&
ctx
,
A1
,
&
A1_len
))
goto
err
;
goto
err
;
memcpy
(
out
,
A1
,
olen
);
memcpy
(
out
,
A1
,
olen
);
break
;
break
;
...
@@ -228,8 +233,9 @@ static int tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
...
@@ -228,8 +233,9 @@ static int tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
}
}
ret
=
1
;
ret
=
1
;
err:
err:
HMAC_CTX_cleanup
(
&
ctx
);
EVP_PKEY_free
(
mac_key
);
HMAC_CTX_cleanup
(
&
ctx_tmp
);
EVP_MD_CTX_cleanup
(
&
ctx
);
EVP_MD_CTX_cleanup
(
&
ctx_tmp
);
OPENSSL_cleanse
(
A1
,
sizeof
(
A1
));
OPENSSL_cleanse
(
A1
,
sizeof
(
A1
));
return
ret
;
return
ret
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录