Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
50ec3951
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看板
提交
50ec3951
编写于
6月 20, 2005
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle wrap-arounds and revive missing assignment.
上级
11cd2397
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
56 addition
and
30 deletion
+56
-30
ssl/d1_pkt.c
ssl/d1_pkt.c
+56
-30
未找到文件。
ssl/d1_pkt.c
浏览文件 @
50ec3951
...
...
@@ -121,27 +121,53 @@
#include <openssl/buffer.h>
#include <openssl/pqueue.h>
/* mod
256
saturating subtract of two 64-bit values in big-endian order */
/* mod
128
saturating subtract of two 64-bit values in big-endian order */
static
int
satsub64be
(
const
unsigned
char
*
v1
,
const
unsigned
char
*
v2
)
{
int
i
;
unsigned
char
c1
,
c2
;
for
(
i
=
0
;
i
<
8
;
i
++
,
v1
++
,
v2
++
)
{
c1
=*
v1
;
c2
=*
v2
;
if
(
c1
!=
c2
)
break
;
{
int
ret
,
sat
,
brw
,
i
;
if
(
sizeof
(
long
)
==
8
)
do
{
const
union
{
long
one
;
char
little
;
}
is_endian
=
{
1
};
long
l
;
if
(
is_endian
.
little
)
break
;
/* not reached on little-endians */
/* following test is redundant, because input is
* always aligned, but I take no chances... */
if
(((
size_t
)
v1
|
(
size_t
)
v2
)
&
0x7
)
break
;
l
=
*
((
long
*
)
v1
);
l
=-
*
((
long
*
)
v2
);
if
(
l
>
128
)
return
128
;
else
if
(
l
<-
128
)
return
-
128
;
else
return
(
int
)
l
;
}
while
(
0
);
ret
=
(
int
)
v1
[
7
]
-
(
int
)
v2
[
7
];
sat
=
0
;
brw
=
ret
>>
8
;
/* brw is either 0 or -1 */
if
(
ret
&
0x80
)
{
for
(
i
=
6
;
i
>=
0
;
i
--
)
{
brw
+=
(
int
)
v1
[
i
]
-
(
int
)
v2
[
i
];
sat
|=
~
brw
;
brw
>>=
8
;
}
if
(
i
==
8
)
return
0
;
else
if
(
i
==
7
)
return
(
int
)
c1
-
(
int
)
c2
;
else
if
(
c1
>
c2
)
return
256
;
else
return
-
256
;
}
else
{
for
(
i
=
6
;
i
>=
0
;
i
--
)
{
brw
+=
(
int
)
v1
[
i
]
-
(
int
)
v2
[
i
];
sat
|=
brw
;
brw
>>=
8
;
}
}
brw
<<=
8
;
/* brw is either 0 or -256 */
if
(
sat
&
0xff
)
return
brw
|
0x80
;
else
return
brw
+
(
ret
&
0xFF
);
}
static
int
have_handshake_fragment
(
SSL
*
s
,
int
type
,
unsigned
char
*
buf
,
int
len
,
int
peek
);
static
int
dtls1_record_replay_check
(
SSL
*
s
,
DTLS1_BITMAP
*
bitmap
,
unsigned
char
*
seq_num
);
static
int
dtls1_record_replay_check
(
SSL
*
s
,
DTLS1_BITMAP
*
bitmap
);
static
void
dtls1_record_bitmap_update
(
SSL
*
s
,
DTLS1_BITMAP
*
bitmap
);
static
DTLS1_BITMAP
*
dtls1_get_bitmap
(
SSL
*
s
,
SSL3_RECORD
*
rr
,
unsigned
int
*
is_next_epoch
);
...
...
@@ -334,17 +360,17 @@ dtls1_get_buffered_record(SSL *s)
static
int
dtls1_process_record
(
SSL
*
s
)
{
int
i
,
al
;
int
i
,
al
;
int
clear
=
0
;
int
enc_err
;
int
enc_err
;
SSL_SESSION
*
sess
;
SSL3_RECORD
*
rr
;
SSL3_RECORD
*
rr
;
unsigned
int
mac_size
;
unsigned
char
md
[
EVP_MAX_MD_SIZE
];
rr
=
&
(
s
->
s3
->
rrec
);
sess
=
s
->
session
;
sess
=
s
->
session
;
/* At this point, s->packet_length == SSL3_RT_HEADER_LNGTH + rr->length,
* and we have that many bytes in s->packet
...
...
@@ -390,10 +416,10 @@ printf("\n");
#endif
/* r->length is now the compressed data plus mac */
if
(
(
sess
==
NULL
)
||
if
(
(
sess
==
NULL
)
||
(
s
->
enc_read_ctx
==
NULL
)
||
(
s
->
read_hash
==
NULL
))
clear
=
1
;
clear
=
1
;
if
(
!
clear
)
{
...
...
@@ -463,8 +489,8 @@ if ( (sess == NULL) ||
/* we have pulled in a full packet so zero things */
s
->
packet_length
=
0
;
dtls1_record_bitmap_update
(
s
,
&
(
s
->
d1
->
bitmap
));
/* Mark receipt of record. */
return
(
1
);
dtls1_record_bitmap_update
(
s
,
&
(
s
->
d1
->
bitmap
));
/* Mark receipt of record. */
return
(
1
);
decryption_failed_or_bad_record_mac:
/* Separate 'decryption_failed' alert was introduced with TLS 1.0,
...
...
@@ -601,13 +627,13 @@ again:
/* match epochs. NULL means the packet is dropped on the floor */
bitmap
=
dtls1_get_bitmap
(
s
,
rr
,
&
is_next_epoch
);
if
(
bitmap
==
NULL
)
{
s
->
packet_length
=
0
;
/* dump this record */
goto
again
;
/* get another record */
{
s
->
packet_length
=
0
;
/* dump this record */
goto
again
;
/* get another record */
}
/* check whether this is a repeat, or aged record */
if
(
!
dtls1_record_replay_check
(
s
,
bitmap
,
rr
->
seq_num
))
if
(
!
dtls1_record_replay_check
(
s
,
bitmap
))
{
s
->
packet_length
=
0
;
/* dump this record */
goto
again
;
/* get another record */
...
...
@@ -1468,8 +1494,7 @@ err:
static
int
dtls1_record_replay_check
(
SSL
*
s
,
DTLS1_BITMAP
*
bitmap
,
unsigned
char
*
seq_num
)
static
int
dtls1_record_replay_check
(
SSL
*
s
,
DTLS1_BITMAP
*
bitmap
)
{
int
cmp
;
unsigned
int
shift
;
...
...
@@ -1478,7 +1503,7 @@ static int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap,
cmp
=
satsub64be
(
seq
,
bitmap
->
max_seq_num
);
if
(
cmp
>
0
)
{
memcpy
(
seq_num
,
seq
,
8
);
memcpy
(
s
->
s3
->
rrec
.
s
eq_num
,
seq
,
8
);
return
1
;
/* this record in new */
}
shift
=
-
cmp
;
...
...
@@ -1487,6 +1512,7 @@ static int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap,
else
if
(
bitmap
->
map
&
(
1UL
<<
shift
))
return
0
;
/* record previously received */
memcpy
(
s
->
s3
->
rrec
.
seq_num
,
seq
,
8
);
return
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录