Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
8e6d03ca
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看板
提交
8e6d03ca
编写于
9月 06, 2016
作者:
M
Matt Caswell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert record layer to use size_t
Reviewed-by:
N
Rich Salz
<
rsalz@openssl.org
>
上级
a1ca39c0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
42 deletion
+55
-42
ssl/record/rec_layer_s3.c
ssl/record/rec_layer_s3.c
+26
-17
ssl/record/record.h
ssl/record/record.h
+3
-3
ssl/record/record_locl.h
ssl/record/record_locl.h
+2
-1
ssl/record/ssl3_record.c
ssl/record/ssl3_record.c
+24
-21
未找到文件。
ssl/record/rec_layer_s3.c
浏览文件 @
8e6d03ca
...
...
@@ -179,11 +179,12 @@ const char *SSL_rstate_string(const SSL *s)
/*
* Return values are as per SSL_read(), i.e.
*
>0 The number of read byte
s
*
1 Succes
s
* 0 Failure (not retryable)
* <0 Failure (may be retryable)
*/
int
ssl3_read_n
(
SSL
*
s
,
int
n
,
int
max
,
int
extend
,
int
clearold
)
int
ssl3_read_n
(
SSL
*
s
,
size_t
n
,
size_t
max
,
int
extend
,
int
clearold
,
size_t
*
read
)
{
/*
* If extend == 0, obtain new n-byte packet; if extend == 1, increase
...
...
@@ -194,13 +195,12 @@ int ssl3_read_n(SSL *s, int n, int max, int extend, int clearold)
* if clearold == 1, move the packet to the start of the buffer; if
* clearold == 0 then leave any old packets where they were
*/
int
i
,
len
,
left
;
size_t
align
=
0
;
size_t
len
,
left
,
align
=
0
;
unsigned
char
*
pkt
;
SSL3_BUFFER
*
rb
;
if
(
n
<
=
0
)
return
n
;
if
(
n
=
=
0
)
return
0
;
rb
=
&
s
->
rlayer
.
rbuf
;
if
(
rb
->
buf
==
NULL
)
...
...
@@ -270,12 +270,13 @@ int ssl3_read_n(SSL *s, int n, int max, int extend, int clearold)
s
->
rlayer
.
packet_length
+=
n
;
rb
->
left
=
left
-
n
;
rb
->
offset
+=
n
;
return
(
n
);
*
read
=
n
;
return
1
;
}
/* else we need to read more data */
if
(
n
>
(
int
)(
rb
->
len
-
rb
->
offset
))
{
/* does not happen */
if
(
n
>
(
rb
->
len
-
rb
->
offset
))
{
/* does not happen */
SSLerr
(
SSL_F_SSL3_READ_N
,
ERR_R_INTERNAL_ERROR
);
return
-
1
;
}
...
...
@@ -287,11 +288,14 @@ int ssl3_read_n(SSL *s, int n, int max, int extend, int clearold)
else
{
if
(
max
<
n
)
max
=
n
;
if
(
max
>
(
int
)(
rb
->
len
-
rb
->
offset
))
if
(
max
>
(
rb
->
len
-
rb
->
offset
))
max
=
rb
->
len
-
rb
->
offset
;
}
while
(
left
<
n
)
{
size_t
bioread
;
int
ret
;
/*
* Now we have len+left bytes at the front of s->s3->rbuf.buf and
* need to read in more until we have len+n (up to len+max if
...
...
@@ -301,20 +305,23 @@ int ssl3_read_n(SSL *s, int n, int max, int extend, int clearold)
clear_sys_error
();
if
(
s
->
rbio
!=
NULL
)
{
s
->
rwstate
=
SSL_READING
;
i
=
BIO_read
(
s
->
rbio
,
pkt
+
len
+
left
,
max
-
left
);
/* TODO(size_t): Convert this function */
ret
=
BIO_read
(
s
->
rbio
,
pkt
+
len
+
left
,
max
-
left
);
if
(
ret
>=
0
)
bioread
=
ret
;
}
else
{
SSLerr
(
SSL_F_SSL3_READ_N
,
SSL_R_READ_BIO_NOT_SET
);
i
=
-
1
;
ret
=
-
1
;
}
if
(
i
<=
0
)
{
if
(
ret
<=
0
)
{
rb
->
left
=
left
;
if
(
s
->
mode
&
SSL_MODE_RELEASE_BUFFERS
&&
!
SSL_IS_DTLS
(
s
))
if
(
len
+
left
==
0
)
ssl3_release_read_buffer
(
s
);
return
-
1
;
}
left
+=
i
;
left
+=
bioread
;
/*
* reads should *never* span multiple packets for DTLS because the
* underlying transport protocol is message oriented as opposed to
...
...
@@ -331,7 +338,8 @@ int ssl3_read_n(SSL *s, int n, int max, int extend, int clearold)
rb
->
left
=
left
-
n
;
s
->
rlayer
.
packet_length
+=
n
;
s
->
rwstate
=
SSL_NOTHING
;
return
(
n
);
*
read
=
n
;
return
1
;
}
/*
...
...
@@ -411,7 +419,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK
)
{
unsigned
char
aad
[
13
];
EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM
mb_param
;
in
t
packlen
;
size_
t
packlen
;
/* minimize address aliasing conflicts */
if
((
max_send_fragment
&
0xfff
)
==
0
)
...
...
@@ -470,11 +478,12 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len)
mb_param
.
inp
=
aad
;
mb_param
.
len
=
nw
;
/* TODO: CHECK ME - CAN THIS EVER BE NEGATIVE???? */
packlen
=
EVP_CIPHER_CTX_ctrl
(
s
->
enc_write_ctx
,
EVP_CTRL_TLS1_1_MULTIBLOCK_AAD
,
sizeof
(
mb_param
),
&
mb_param
);
if
(
packlen
<=
0
||
packlen
>
(
int
)
wb
->
len
)
{
/* never happens */
if
(
packlen
<=
0
||
packlen
>
wb
->
len
)
{
/* never happens */
/* free jumbo buffer */
ssl3_release_write_buffer
(
s
);
break
;
...
...
@@ -921,7 +930,7 @@ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
SSLerr
(
SSL_F_SSL3_WRITE_PENDING
,
SSL_R_BIO_NOT_SET
);
i
=
-
1
;
}
if
(
i
==
SSL3_BUFFER_get_left
(
&
wb
[
currbuf
]))
{
if
(
i
==
(
int
)
SSL3_BUFFER_get_left
(
&
wb
[
currbuf
]))
{
SSL3_BUFFER_set_left
(
&
wb
[
currbuf
],
0
);
SSL3_BUFFER_add_offset
(
&
wb
[
currbuf
],
i
);
if
(
currbuf
+
1
<
s
->
rlayer
.
numwpipes
)
...
...
ssl/record/record.h
浏览文件 @
8e6d03ca
...
...
@@ -22,9 +22,9 @@ typedef struct ssl3_buffer_st {
/* buffer size */
size_t
len
;
/* where to 'copy from' */
in
t
offset
;
size_
t
offset
;
/* how many bytes left */
in
t
left
;
size_
t
left
;
}
SSL3_BUFFER
;
#define SEQ_NUM_SIZE 8
...
...
@@ -154,7 +154,7 @@ typedef struct record_layer_st {
SSL3_RECORD
rrec
[
SSL_MAX_PIPELINES
];
/* used internally to point at a raw packet */
unsigned
char
*
packet
;
unsigned
in
t
packet_length
;
size_
t
packet_length
;
/* number of bytes sent so far */
unsigned
int
wnum
;
/*
...
...
ssl/record/record_locl.h
浏览文件 @
8e6d03ca
...
...
@@ -38,7 +38,8 @@
#define RECORD_LAYER_clear_first_record(rl) ((rl)->is_first_record = 0)
#define DTLS_RECORD_LAYER_get_r_epoch(rl) ((rl)->d->r_epoch)
__owur
int
ssl3_read_n
(
SSL
*
s
,
int
n
,
int
max
,
int
extend
,
int
clearold
);
__owur
int
ssl3_read_n
(
SSL
*
s
,
size_t
n
,
size_t
max
,
int
extend
,
int
clearold
,
size_t
*
read
);
void
RECORD_LAYER_set_write_sequence
(
RECORD_LAYER
*
rl
,
const
unsigned
char
*
ws
);
DTLS1_BITMAP
*
dtls1_get_bitmap
(
SSL
*
s
,
SSL3_RECORD
*
rr
,
...
...
ssl/record/ssl3_record.c
浏览文件 @
8e6d03ca
...
...
@@ -68,7 +68,7 @@ void SSL3_RECORD_set_seq_num(SSL3_RECORD *r, const unsigned char *seq_num)
static
int
ssl3_record_app_data_waiting
(
SSL
*
s
)
{
SSL3_BUFFER
*
rbuf
;
in
t
left
,
len
;
size_
t
left
,
len
;
unsigned
char
*
p
;
rbuf
=
RECORD_LAYER_get_rbuf
(
&
s
->
rlayer
);
...
...
@@ -125,7 +125,9 @@ static int ssl3_record_app_data_waiting(SSL *s)
int
ssl3_get_record
(
SSL
*
s
)
{
int
ssl_major
,
ssl_minor
,
al
;
int
enc_err
,
n
,
i
,
ret
=
-
1
;
int
enc_err
,
rret
,
ret
=
-
1
;
int
i
;
size_t
more
,
n
;
SSL3_RECORD
*
rr
;
SSL3_BUFFER
*
rbuf
;
SSL_SESSION
*
sess
;
...
...
@@ -149,11 +151,11 @@ int ssl3_get_record(SSL *s)
if
((
RECORD_LAYER_get_rstate
(
&
s
->
rlayer
)
!=
SSL_ST_READ_BODY
)
||
(
RECORD_LAYER_get_packet_length
(
&
s
->
rlayer
)
<
SSL3_RT_HEADER_LENGTH
))
{
n
=
ssl3_read_n
(
s
,
SSL3_RT_HEADER_LENGTH
,
SSL3_BUFFER_get_len
(
rbuf
),
0
,
num_recs
==
0
?
1
:
0
);
if
(
n
<=
0
)
return
(
n
)
;
/* error or non-blocking */
rret
=
ssl3_read_n
(
s
,
SSL3_RT_HEADER_LENGTH
,
SSL3_BUFFER_get_len
(
rbuf
),
0
,
num_recs
==
0
?
1
:
0
,
&
n
);
if
(
rret
<=
0
)
return
rret
;
/* error or non-blocking */
RECORD_LAYER_set_rstate
(
&
s
->
rlayer
,
SSL_ST_READ_BODY
);
p
=
RECORD_LAYER_get_packet
(
&
s
->
rlayer
);
...
...
@@ -274,17 +276,17 @@ int ssl3_get_record(SSL *s)
* record
*/
if
(
rr
[
num_recs
].
rec_version
==
SSL2_VERSION
)
{
i
=
rr
[
num_recs
].
length
+
SSL2_RT_HEADER_LENGTH
more
=
rr
[
num_recs
].
length
+
SSL2_RT_HEADER_LENGTH
-
SSL3_RT_HEADER_LENGTH
;
}
else
{
i
=
rr
[
num_recs
].
length
;
more
=
rr
[
num_recs
].
length
;
}
if
(
i
>
0
)
{
if
(
more
>
0
)
{
/* now s->packet_length == SSL3_RT_HEADER_LENGTH */
n
=
ssl3_read_n
(
s
,
i
,
i
,
1
,
0
);
if
(
n
<=
0
)
return
(
n
)
;
/* error or non-blocking io */
rret
=
ssl3_read_n
(
s
,
more
,
more
,
1
,
0
,
&
n
);
if
(
rret
<=
0
)
return
rret
;
/* error or non-blocking io */
}
/* set state for later operations */
...
...
@@ -1482,7 +1484,8 @@ int dtls1_process_record(SSL *s, DTLS1_BITMAP *bitmap)
int
dtls1_get_record
(
SSL
*
s
)
{
int
ssl_major
,
ssl_minor
;
int
i
,
n
;
int
rret
;
size_t
more
,
n
;
SSL3_RECORD
*
rr
;
unsigned
char
*
p
=
NULL
;
unsigned
short
version
;
...
...
@@ -1508,11 +1511,11 @@ int dtls1_get_record(SSL *s)
/* check if we have the header */
if
((
RECORD_LAYER_get_rstate
(
&
s
->
rlayer
)
!=
SSL_ST_READ_BODY
)
||
(
RECORD_LAYER_get_packet_length
(
&
s
->
rlayer
)
<
DTLS1_RT_HEADER_LENGTH
))
{
n
=
ssl3_read_n
(
s
,
DTLS1_RT_HEADER_LENGTH
,
SSL3_BUFFER_get_len
(
&
s
->
rlayer
.
rbuf
),
0
,
1
);
rret
=
ssl3_read_n
(
s
,
DTLS1_RT_HEADER_LENGTH
,
SSL3_BUFFER_get_len
(
&
s
->
rlayer
.
rbuf
),
0
,
1
,
&
n
);
/* read timeout is handled by dtls1_read_bytes */
if
(
n
<=
0
)
return
(
n
)
;
/* error or non-blocking */
if
(
rret
<=
0
)
return
rret
;
/* error or non-blocking */
/* this packet contained a partial record, dump it */
if
(
RECORD_LAYER_get_packet_length
(
&
s
->
rlayer
)
!=
...
...
@@ -1575,10 +1578,10 @@ int dtls1_get_record(SSL *s)
if
(
rr
->
length
>
RECORD_LAYER_get_packet_length
(
&
s
->
rlayer
)
-
DTLS1_RT_HEADER_LENGTH
)
{
/* now s->packet_length == DTLS1_RT_HEADER_LENGTH */
i
=
rr
->
length
;
n
=
ssl3_read_n
(
s
,
i
,
i
,
1
,
1
);
more
=
rr
->
length
;
rret
=
ssl3_read_n
(
s
,
more
,
more
,
1
,
1
,
&
n
);
/* this packet contained a partial record, dump it */
if
(
n
!=
i
)
{
if
(
rret
<=
0
||
n
!=
more
)
{
rr
->
length
=
0
;
RECORD_LAYER_reset_packet_length
(
&
s
->
rlayer
);
goto
again
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录