Some more bools. Change-Id: I60d9e728c1ca5e788ee7df5e874fb6e8ea182fec Reviewed-on: https://boringssl-review.googlesource.com/31524 Commit-Queue: Steven Valdez <svaldez@google.com> Reviewed-by: Steven Valdez <svaldez@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/ssl/handshake_client.cc b/ssl/handshake_client.cc index 9f9e483..907fcb6 100644 --- a/ssl/handshake_client.cc +++ b/ssl/handshake_client.cc
@@ -212,20 +212,20 @@ } } -static int ssl_write_client_cipher_list(SSL_HANDSHAKE *hs, CBB *out) { +static bool ssl_write_client_cipher_list(SSL_HANDSHAKE *hs, CBB *out) { SSL *const ssl = hs->ssl; uint32_t mask_a, mask_k; ssl_get_client_disabled(hs, &mask_a, &mask_k); CBB child; if (!CBB_add_u16_length_prefixed(out, &child)) { - return 0; + return false; } // Add a fake cipher suite. See draft-davidben-tls-grease-01. if (ssl->ctx->grease_enabled && !CBB_add_u16(&child, ssl_get_grease_value(hs, ssl_grease_cipher))) { - return 0; + return false; } // Add TLS 1.3 ciphers. Order ChaCha20-Poly1305 relative to AES-GCM based on @@ -233,20 +233,20 @@ if (hs->max_version >= TLS1_3_VERSION) { if (!EVP_has_aes_hardware() && !CBB_add_u16(&child, TLS1_CK_CHACHA20_POLY1305_SHA256 & 0xffff)) { - return 0; + return false; } if (!CBB_add_u16(&child, TLS1_CK_AES_128_GCM_SHA256 & 0xffff) || !CBB_add_u16(&child, TLS1_CK_AES_256_GCM_SHA384 & 0xffff)) { - return 0; + return false; } if (EVP_has_aes_hardware() && !CBB_add_u16(&child, TLS1_CK_CHACHA20_POLY1305_SHA256 & 0xffff)) { - return 0; + return false; } } if (hs->min_version < TLS1_3_VERSION) { - int any_enabled = 0; + bool any_enabled = false; for (const SSL_CIPHER *cipher : SSL_get_ciphers(ssl)) { // Skip disabled ciphers if ((cipher->algorithm_mkey & mask_k) || @@ -257,53 +257,53 @@ SSL_CIPHER_get_max_version(cipher) < hs->min_version) { continue; } - any_enabled = 1; + any_enabled = true; if (!CBB_add_u16(&child, ssl_cipher_get_value(cipher))) { - return 0; + return false; } } // If all ciphers were disabled, return the error to the caller. if (!any_enabled && hs->max_version < TLS1_3_VERSION) { OPENSSL_PUT_ERROR(SSL, SSL_R_NO_CIPHERS_AVAILABLE); - return 0; + return false; } } if (ssl->mode & SSL_MODE_SEND_FALLBACK_SCSV) { if (!CBB_add_u16(&child, SSL3_CK_FALLBACK_SCSV & 0xffff)) { - return 0; + return false; } } return CBB_flush(out); } -int ssl_write_client_hello(SSL_HANDSHAKE *hs) { +bool ssl_write_client_hello(SSL_HANDSHAKE *hs) { SSL *const ssl = hs->ssl; ScopedCBB cbb; CBB body; if (!ssl->method->init_message(ssl, cbb.get(), &body, SSL3_MT_CLIENT_HELLO)) { - return 0; + return false; } CBB child; if (!CBB_add_u16(&body, hs->client_version) || !CBB_add_bytes(&body, ssl->s3->client_random, SSL3_RANDOM_SIZE) || !CBB_add_u8_length_prefixed(&body, &child)) { - return 0; + return false; } // Do not send a session ID on renegotiation. if (!ssl->s3->initial_handshake_complete && !CBB_add_bytes(&child, hs->session_id, hs->session_id_len)) { - return 0; + return false; } if (SSL_is_dtls(ssl)) { if (!CBB_add_u8_length_prefixed(&body, &child) || !CBB_add_bytes(&child, ssl->d1->cookie, ssl->d1->cookie_len)) { - return 0; + return false; } } @@ -313,19 +313,19 @@ !CBB_add_u8(&body, 1 /* one compression method */) || !CBB_add_u8(&body, 0 /* null compression */) || !ssl_add_clienthello_tlsext(hs, &body, header_len + CBB_len(&body))) { - return 0; + return false; } Array<uint8_t> msg; if (!ssl->method->finish_message(ssl, cbb.get(), &msg)) { - return 0; + return false; } // Now that the length prefixes have been computed, fill in the placeholder // PSK binder. if (hs->needs_psk_binder && !tls13_write_psk_binder(hs, msg.data(), msg.size())) { - return 0; + return false; } return ssl->method->add_message(ssl, std::move(msg));