@@ -189,7 +189,8 @@ struct tsi_ssl_handshaker : public tsi_handshaker,
189189 // Will be set if there is a pending call to tsi_handshaker_next(),
190190 // or nullopt if not.
191191 std::optional<HandshakerNextArgs> handshaker_next_args ABSL_GUARDED_BY (mu);
192- void MaybeSetError (std::string error) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu) {
192+ const void MaybeSetError (std::string error)
193+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu) {
193194 if (!handshaker_next_args.has_value ()) return ;
194195 if (handshaker_next_args->error_ptr == nullptr ) return ;
195196 *handshaker_next_args->error_ptr = std::move (error);
@@ -455,11 +456,6 @@ enum ssl_private_key_result_t TlsPrivateKeySignWrapper(
455456 [&](absl::StatusOr<std::string>* status_or_string)
456457 ABSL_NO_THREAD_SAFETY_ANALYSIS {
457458 if (status_or_string->ok ()) {
458- if ((*status_or_string)->size () > max_out) {
459- handshaker->MaybeSetError (
460- " Private Key Signature exceeds maximum allowed size." );
461- return ssl_private_key_failure;
462- }
463459 handshaker->signed_bytes = std::move (*status_or_string);
464460 return TlsPrivateKeyOffloadComplete (ssl, out, out_len, max_out);
465461 } else {
@@ -2233,7 +2229,6 @@ static tsi_result ssl_handshaker_write_output_buffer(tsi_handshaker* self,
22332229
22342230static tsi_result ssl_handshaker_next_impl (tsi_ssl_handshaker* self)
22352231 ABSL_EXCLUSIVE_LOCKS_REQUIRED(&self->mu) {
2236- std::string* error = self->handshaker_next_args ->error_ptr ;
22372232 // If there are received bytes, process them first.
22382233 tsi_result status = TSI_OK;
22392234 size_t bytes_written = 0 ;
@@ -2254,17 +2249,18 @@ static tsi_result ssl_handshaker_next_impl(tsi_ssl_handshaker* self)
22542249 remaining_bytes_to_write_to_openssl_size;
22552250 status = ssl_handshaker_process_bytes_from_peer (
22562251 self, remaining_bytes_to_write_to_openssl, &bytes_written_to_openssl,
2257- error );
2252+ self-> handshaker_next_args -> error_ptr );
22582253 // As long as the BIO is full, drive the SSL handshake to consume bytes
22592254 // from the BIO. If the SSL handshake returns any bytes, write them to
22602255 // the peer.
22612256 while (status == TSI_DRAIN_BUFFER) {
2262- status =
2263- ssl_handshaker_write_output_buffer ( self, &bytes_written, error );
2257+ status = ssl_handshaker_write_output_buffer (
2258+ self, &bytes_written, self-> handshaker_next_args -> error_ptr );
22642259 if (status != TSI_OK) {
22652260 return status;
22662261 }
2267- status = ssl_handshaker_do_handshake (self, error);
2262+ status = ssl_handshaker_do_handshake (
2263+ self, self->handshaker_next_args ->error_ptr );
22682264 }
22692265 // Move the pointer to the first byte not yet successfully written to
22702266 // the BIO.
@@ -2287,16 +2283,17 @@ static tsi_result ssl_handshaker_next_impl(tsi_ssl_handshaker* self)
22872283 // During the PrivateKeyOffload signature, an empty call to
22882284 // ssl_handshaker_do_handshake needs to be forced after the async offload
22892285 // has completed.
2290- status = ssl_handshaker_do_handshake (self, error);
2291- self->signed_bytes = " " ;
2286+ status = ssl_handshaker_do_handshake (self,
2287+ self->handshaker_next_args -> error_ptr ) ;
22922288#endif
22932289 }
22942290
22952291 if (status != TSI_OK) {
22962292 return status;
22972293 }
22982294 // Get bytes to send to the peer, if available.
2299- status = ssl_handshaker_write_output_buffer (self, &bytes_written, error);
2295+ status = ssl_handshaker_write_output_buffer (
2296+ self, &bytes_written, self->handshaker_next_args ->error_ptr );
23002297 if (status != TSI_OK) {
23012298 return status;
23022299 }
@@ -2312,21 +2309,22 @@ static tsi_result ssl_handshaker_next_impl(tsi_ssl_handshaker* self)
23122309 // bytes from the peer that must be processed.
23132310 unsigned char * unused_bytes = nullptr ;
23142311 size_t unused_bytes_size = 0 ;
2315- status =
2316- ssl_bytes_remaining (self, &unused_bytes, &unused_bytes_size, error );
2312+ status = ssl_bytes_remaining (self, &unused_bytes, &unused_bytes_size,
2313+ self-> handshaker_next_args -> error_ptr );
23172314 if (status != TSI_OK) {
23182315 return status;
23192316 }
23202317 if (unused_bytes_size >
23212318 self->handshaker_next_args ->original_received_bytes_size ) {
23222319 LOG (ERROR) << " More unused bytes than received bytes." ;
23232320 gpr_free (unused_bytes);
2324- if (error != nullptr ) *error = " More unused bytes than received bytes." ;
2321+ self-> MaybeSetError ( " More unused bytes than received bytes." ) ;
23252322 return TSI_INTERNAL_ERROR;
23262323 }
23272324 status = ssl_handshaker_result_create (
23282325 self, unused_bytes, unused_bytes_size,
2329- &self->handshaker_next_args ->handshaker_result , error);
2326+ &self->handshaker_next_args ->handshaker_result ,
2327+ self->handshaker_next_args ->error_ptr );
23302328 if (status == TSI_OK) {
23312329 // Indicates that the handshake has completed and that a
23322330 // handshaker_result has been created.
0 commit comments