Fold ssl3_write_bytes into ssl3_write_app_data.

It has no other callers, now that the handshake is written elsewhere.

Change-Id: Ib04bbdc4a54fc7d01405d9b3f765fa9f186244de
Reviewed-on: https://boringssl-review.googlesource.com/13540
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
David Benjamin 2017-02-02 15:05:35 -05:00 committed by CQ bot account: commit-bot@chromium.org
parent 6342111c2e
commit 8671c47bd8
3 changed files with 10 additions and 19 deletions

View File

@ -331,7 +331,7 @@ void dtls1_read_close_notify(SSL *ssl) {
} }
} }
int dtls1_write_app_data(SSL *ssl, const void *buf_, int len) { int dtls1_write_app_data(SSL *ssl, const uint8_t *buf, int len) {
assert(!SSL_in_init(ssl)); assert(!SSL_in_init(ssl));
if (len > SSL3_RT_MAX_PLAIN_LENGTH) { if (len > SSL3_RT_MAX_PLAIN_LENGTH) {
@ -348,7 +348,7 @@ int dtls1_write_app_data(SSL *ssl, const void *buf_, int len) {
return 0; return 0;
} }
int ret = dtls1_write_record(ssl, SSL3_RT_APPLICATION_DATA, buf_, (size_t)len, int ret = dtls1_write_record(ssl, SSL3_RT_APPLICATION_DATA, buf, (size_t)len,
dtls1_use_current_epoch); dtls1_use_current_epoch);
if (ret <= 0) { if (ret <= 0) {
return ret; return ret;

View File

@ -1323,7 +1323,7 @@ struct ssl_protocol_method_st {
int peek); int peek);
int (*read_change_cipher_spec)(SSL *ssl); int (*read_change_cipher_spec)(SSL *ssl);
void (*read_close_notify)(SSL *ssl); void (*read_close_notify)(SSL *ssl);
int (*write_app_data)(SSL *ssl, const void *buf_, int len); int (*write_app_data)(SSL *ssl, const uint8_t *buf, int len);
int (*dispatch_alert)(SSL *ssl); int (*dispatch_alert)(SSL *ssl);
/* supports_cipher returns one if |cipher| is supported by this protocol and /* supports_cipher returns one if |cipher| is supported by this protocol and
* zero otherwise. */ * zero otherwise. */
@ -1796,8 +1796,7 @@ int ssl3_read_app_data(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len,
int ssl3_read_change_cipher_spec(SSL *ssl); int ssl3_read_change_cipher_spec(SSL *ssl);
void ssl3_read_close_notify(SSL *ssl); void ssl3_read_close_notify(SSL *ssl);
int ssl3_read_handshake_bytes(SSL *ssl, uint8_t *buf, int len); int ssl3_read_handshake_bytes(SSL *ssl, uint8_t *buf, int len);
int ssl3_write_app_data(SSL *ssl, const void *buf, int len); int ssl3_write_app_data(SSL *ssl, const uint8_t *buf, int len);
int ssl3_write_bytes(SSL *ssl, int type, const void *buf, int len);
int ssl3_output_cert_chain(SSL *ssl); int ssl3_output_cert_chain(SSL *ssl);
int ssl3_new(SSL *ssl); int ssl3_new(SSL *ssl);
@ -1838,7 +1837,7 @@ int dtls1_read_app_data(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len,
int dtls1_read_change_cipher_spec(SSL *ssl); int dtls1_read_change_cipher_spec(SSL *ssl);
void dtls1_read_close_notify(SSL *ssl); void dtls1_read_close_notify(SSL *ssl);
int dtls1_write_app_data(SSL *ssl, const void *buf, int len); int dtls1_write_app_data(SSL *ssl, const uint8_t *buf, int len);
/* dtls1_write_record sends a record. It returns one on success and <= 0 on /* dtls1_write_record sends a record. It returns one on success and <= 0 on
* error. */ * error. */

View File

@ -188,16 +188,9 @@ again:
return -1; return -1;
} }
int ssl3_write_app_data(SSL *ssl, const void *buf, int len) { int ssl3_write_app_data(SSL *ssl, const uint8_t *buf, int len) {
assert(!SSL_in_init(ssl) || SSL_in_false_start(ssl)); assert(!SSL_in_init(ssl) || SSL_in_false_start(ssl));
return ssl3_write_bytes(ssl, SSL3_RT_APPLICATION_DATA, buf, len);
}
/* Call this to write data in records of type |type|. It will return <= 0 if
* not all data has been sent or non-blocking IO. */
int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) {
const uint8_t *buf = buf_;
unsigned tot, n, nw; unsigned tot, n, nw;
assert(ssl->s3->wnum <= INT_MAX); assert(ssl->s3->wnum <= INT_MAX);
@ -216,7 +209,7 @@ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) {
return -1; return -1;
} }
n = (len - tot); n = len - tot;
for (;;) { for (;;) {
/* max contains the maximum number of bytes that we can put into a /* max contains the maximum number of bytes that we can put into a
* record. */ * record. */
@ -227,14 +220,13 @@ int ssl3_write_bytes(SSL *ssl, int type, const void *buf_, int len) {
nw = n; nw = n;
} }
int ret = do_ssl3_write(ssl, type, &buf[tot], nw); int ret = do_ssl3_write(ssl, SSL3_RT_APPLICATION_DATA, &buf[tot], nw);
if (ret <= 0) { if (ret <= 0) {
ssl->s3->wnum = tot; ssl->s3->wnum = tot;
return ret; return ret;
} }
if (ret == (int)n || (type == SSL3_RT_APPLICATION_DATA && if (ret == (int)n || (ssl->mode & SSL_MODE_ENABLE_PARTIAL_WRITE)) {
(ssl->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) {
return tot + ret; return tot + ret;
} }