Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
6606d600
O
openssl
项目概览
btwise
/
openssl
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6606d600
编写于
11月 29, 2016
作者:
M
Matt Caswell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix some style issues in the TLSv1.3 nonce construction code
Reviewed-by:
N
Rich Salz
<
rsalz@openssl.org
>
上级
d3ab93e9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
16 deletion
+16
-16
engines/e_ossltest.c
engines/e_ossltest.c
+3
-6
ssl/record/ssl3_record_tls13.c
ssl/record/ssl3_record_tls13.c
+1
-1
test/tls13encryptiontest.c
test/tls13encryptiontest.c
+12
-9
未找到文件。
engines/e_ossltest.c
浏览文件 @
6606d600
...
@@ -619,6 +619,7 @@ int ossltest_aes128_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
...
@@ -619,6 +619,7 @@ int ossltest_aes128_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
{
{
unsigned
char
*
tmpbuf
=
OPENSSL_malloc
(
inl
);
unsigned
char
*
tmpbuf
=
OPENSSL_malloc
(
inl
);
/* OPENSSL_malloc will return NULL if inl == 0 */
if
(
tmpbuf
==
NULL
&&
inl
>
0
)
if
(
tmpbuf
==
NULL
&&
inl
>
0
)
return
-
1
;
return
-
1
;
...
@@ -628,9 +629,7 @@ int ossltest_aes128_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
...
@@ -628,9 +629,7 @@ int ossltest_aes128_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
/* Go through the motions of encrypting it */
/* Go through the motions of encrypting it */
EVP_CIPHER_meth_get_do_cipher
(
EVP_aes_128_gcm
())(
ctx
,
out
,
in
,
inl
);
EVP_CIPHER_meth_get_do_cipher
(
EVP_aes_128_gcm
())(
ctx
,
out
,
in
,
inl
);
/*
/* Throw it all away and just use the plaintext as the output */
* Throw it all away and just use the plaintext as the output
*/
memcpy
(
out
,
tmpbuf
,
inl
);
memcpy
(
out
,
tmpbuf
,
inl
);
OPENSSL_free
(
tmpbuf
);
OPENSSL_free
(
tmpbuf
);
...
@@ -640,10 +639,8 @@ int ossltest_aes128_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
...
@@ -640,10 +639,8 @@ int ossltest_aes128_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
static
int
ossltest_aes128_gcm_ctrl
(
EVP_CIPHER_CTX
*
ctx
,
int
type
,
int
arg
,
static
int
ossltest_aes128_gcm_ctrl
(
EVP_CIPHER_CTX
*
ctx
,
int
type
,
int
arg
,
void
*
ptr
)
void
*
ptr
)
{
{
int
ret
;
/* Pass the ctrl down */
/* Pass the ctrl down */
ret
=
EVP_CIPHER_meth_get_ctrl
(
EVP_aes_128_gcm
())(
ctx
,
type
,
arg
,
ptr
);
int
ret
=
EVP_CIPHER_meth_get_ctrl
(
EVP_aes_128_gcm
())(
ctx
,
type
,
arg
,
ptr
);
if
(
ret
<=
0
)
if
(
ret
<=
0
)
return
ret
;
return
ret
;
...
...
ssl/record/ssl3_record_tls13.c
浏览文件 @
6606d600
...
@@ -80,7 +80,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
...
@@ -80,7 +80,7 @@ int tls13_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
for
(
loop
=
0
;
loop
<
SEQ_NUM_SIZE
;
loop
++
)
for
(
loop
=
0
;
loop
<
SEQ_NUM_SIZE
;
loop
++
)
iv
[
offset
+
loop
]
=
staticiv
[
offset
+
loop
]
^
seq
[
loop
];
iv
[
offset
+
loop
]
=
staticiv
[
offset
+
loop
]
^
seq
[
loop
];
/* TODO(size_t): lenu/lenf should be a size_t but EVP
ca
n't support it */
/* TODO(size_t): lenu/lenf should be a size_t but EVP
does
n't support it */
if
(
EVP_CipherInit_ex
(
ctx
,
NULL
,
NULL
,
NULL
,
iv
,
send
)
<=
0
if
(
EVP_CipherInit_ex
(
ctx
,
NULL
,
NULL
,
NULL
,
iv
,
send
)
<=
0
||
EVP_CipherUpdate
(
ctx
,
rec
->
data
,
&
lenu
,
rec
->
input
,
||
EVP_CipherUpdate
(
ctx
,
rec
->
data
,
&
lenu
,
rec
->
input
,
(
unsigned
int
)
rec
->
length
)
<=
0
(
unsigned
int
)
rec
->
length
)
<=
0
...
...
test/tls13encryptiontest.c
浏览文件 @
6606d600
...
@@ -15,6 +15,11 @@
...
@@ -15,6 +15,11 @@
#include "testutil.h"
#include "testutil.h"
#include "test_main.h"
#include "test_main.h"
/*
* Based on the test vectors provided in:
* https://www.ietf.org/id/draft-thomson-tls-tls13-vectors-01.txt
*/
struct
record_data
{
struct
record_data
{
const
char
*
plaintext
;
const
char
*
plaintext
;
const
char
*
ciphertext
;
const
char
*
ciphertext
;
...
@@ -130,7 +135,7 @@ struct record_data {
...
@@ -130,7 +135,7 @@ struct record_data {
static
int
load_record
(
SSL3_RECORD
*
rec
,
size_t
recnum
,
unsigned
char
**
key
,
static
int
load_record
(
SSL3_RECORD
*
rec
,
size_t
recnum
,
unsigned
char
**
key
,
unsigned
char
*
iv
,
size_t
ivlen
,
unsigned
char
*
seq
)
unsigned
char
*
iv
,
size_t
ivlen
,
unsigned
char
*
seq
)
{
{
unsigned
char
*
pt
=
NULL
,
*
sq
=
NULL
,
*
ivtmp
=
NULL
;
;
unsigned
char
*
pt
=
NULL
,
*
sq
=
NULL
,
*
ivtmp
=
NULL
;
long
ptlen
;
long
ptlen
;
*
key
=
OPENSSL_hexstr2buf
(
refdata
[
recnum
].
key
,
NULL
);
*
key
=
OPENSSL_hexstr2buf
(
refdata
[
recnum
].
key
,
NULL
);
...
@@ -199,6 +204,7 @@ static int test_record(SSL3_RECORD *rec, size_t recnum, int enc)
...
@@ -199,6 +204,7 @@ static int test_record(SSL3_RECORD *rec, size_t recnum, int enc)
OPENSSL_free
(
refd
);
OPENSSL_free
(
refd
);
return
ret
;
return
ret
;
}
}
static
int
test_tls13_encryption
(
void
)
static
int
test_tls13_encryption
(
void
)
{
{
SSL_CTX
*
ctx
=
NULL
;
SSL_CTX
*
ctx
=
NULL
;
...
@@ -231,21 +237,20 @@ static int test_tls13_encryption(void)
...
@@ -231,21 +237,20 @@ static int test_tls13_encryption(void)
}
}
for
(
ctr
=
0
;
ctr
<
OSSL_NELEM
(
refdata
);
ctr
++
)
{
for
(
ctr
=
0
;
ctr
<
OSSL_NELEM
(
refdata
);
ctr
++
)
{
/*
/* Load the record */
* Load the record, set up the read/write sequences and load the key into
* the EVP_CIPHER_CTXs
*/
ivlen
=
EVP_CIPHER_iv_length
(
ciph
);
ivlen
=
EVP_CIPHER_iv_length
(
ciph
);
if
(
!
load_record
(
&
rec
,
ctr
,
&
key
,
s
->
read_iv
,
ivlen
,
if
(
!
load_record
(
&
rec
,
ctr
,
&
key
,
s
->
read_iv
,
ivlen
,
RECORD_LAYER_get_read_sequence
(
&
s
->
rlayer
)))
{
RECORD_LAYER_get_read_sequence
(
&
s
->
rlayer
)))
{
fprintf
(
stderr
,
"Failed loading key into EVP_CIPHER_CTX
\n
"
);
fprintf
(
stderr
,
"Failed loading key into EVP_CIPHER_CTX
\n
"
);
goto
err
;
goto
err
;
}
}
/* Set up the read/write sequences */
memcpy
(
RECORD_LAYER_get_write_sequence
(
&
s
->
rlayer
),
memcpy
(
RECORD_LAYER_get_write_sequence
(
&
s
->
rlayer
),
RECORD_LAYER_get_read_sequence
(
&
s
->
rlayer
),
SEQ_NUM_SIZE
);
RECORD_LAYER_get_read_sequence
(
&
s
->
rlayer
),
SEQ_NUM_SIZE
);
memcpy
(
s
->
write_iv
,
s
->
read_iv
,
ivlen
);
memcpy
(
s
->
write_iv
,
s
->
read_iv
,
ivlen
);
/* Load the key into the EVP_CIPHER_CTXs */
if
(
EVP_CipherInit_ex
(
s
->
enc_write_ctx
,
ciph
,
NULL
,
key
,
NULL
,
1
)
<=
0
if
(
EVP_CipherInit_ex
(
s
->
enc_write_ctx
,
ciph
,
NULL
,
key
,
NULL
,
1
)
<=
0
||
EVP_CipherInit_ex
(
s
->
enc_read_ctx
,
ciph
,
NULL
,
key
,
NULL
,
0
)
||
EVP_CipherInit_ex
(
s
->
enc_read_ctx
,
ciph
,
NULL
,
key
,
NULL
,
0
)
<=
0
)
{
<=
0
)
{
...
@@ -258,7 +263,6 @@ static int test_tls13_encryption(void)
...
@@ -258,7 +263,6 @@ static int test_tls13_encryption(void)
fprintf
(
stderr
,
"Failed to encrypt record
\n
"
);
fprintf
(
stderr
,
"Failed to encrypt record
\n
"
);
goto
err
;
goto
err
;
}
}
if
(
!
test_record
(
&
rec
,
ctr
,
1
))
{
if
(
!
test_record
(
&
rec
,
ctr
,
1
))
{
fprintf
(
stderr
,
"Record encryption test failed
\n
"
);
fprintf
(
stderr
,
"Record encryption test failed
\n
"
);
goto
err
;
goto
err
;
...
@@ -269,7 +273,6 @@ static int test_tls13_encryption(void)
...
@@ -269,7 +273,6 @@ static int test_tls13_encryption(void)
fprintf
(
stderr
,
"Failed to decrypt record
\n
"
);
fprintf
(
stderr
,
"Failed to decrypt record
\n
"
);
goto
err
;
goto
err
;
}
}
if
(
!
test_record
(
&
rec
,
ctr
,
0
))
{
if
(
!
test_record
(
&
rec
,
ctr
,
0
))
{
fprintf
(
stderr
,
"Record decryption test failed
\n
"
);
fprintf
(
stderr
,
"Record decryption test failed
\n
"
);
goto
err
;
goto
err
;
...
@@ -287,6 +290,7 @@ static int test_tls13_encryption(void)
...
@@ -287,6 +290,7 @@ static int test_tls13_encryption(void)
fprintf
(
stderr
,
"PASS: %"
OSSLzu
" records tested
\n
"
,
ctr
);
fprintf
(
stderr
,
"PASS: %"
OSSLzu
" records tested
\n
"
,
ctr
);
ret
=
1
;
ret
=
1
;
err:
err:
OPENSSL_free
(
rec
.
data
);
OPENSSL_free
(
rec
.
data
);
OPENSSL_free
(
key
);
OPENSSL_free
(
key
);
...
@@ -294,7 +298,6 @@ static int test_tls13_encryption(void)
...
@@ -294,7 +298,6 @@ static int test_tls13_encryption(void)
OPENSSL_free
(
seq
);
OPENSSL_free
(
seq
);
SSL_free
(
s
);
SSL_free
(
s
);
SSL_CTX_free
(
ctx
);
SSL_CTX_free
(
ctx
);
return
ret
;
return
ret
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录