|  | @@ -74,14 +74,12 @@ tsi_result tsi_frame_protector_protect(tsi_frame_protector *self,
 | 
	
		
			
				|  |  |                                         size_t *unprotected_bytes_size,
 | 
	
		
			
				|  |  |                                         unsigned char *protected_output_frames,
 | 
	
		
			
				|  |  |                                         size_t *protected_output_frames_size) {
 | 
	
		
			
				|  |  | -  if (self == NULL || unprotected_bytes == NULL ||
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || unprotected_bytes == NULL ||
 | 
	
		
			
				|  |  |        unprotected_bytes_size == NULL || protected_output_frames == NULL ||
 | 
	
		
			
				|  |  |        protected_output_frames_size == NULL) {
 | 
	
		
			
				|  |  |      return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->protect == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +  if (self->vtable->protect == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->protect(self, unprotected_bytes, unprotected_bytes_size,
 | 
	
		
			
				|  |  |                                 protected_output_frames,
 | 
	
		
			
				|  |  |                                 protected_output_frames_size);
 | 
	
	
		
			
				|  | @@ -90,13 +88,11 @@ tsi_result tsi_frame_protector_protect(tsi_frame_protector *self,
 | 
	
		
			
				|  |  |  tsi_result tsi_frame_protector_protect_flush(
 | 
	
		
			
				|  |  |      tsi_frame_protector *self, unsigned char *protected_output_frames,
 | 
	
		
			
				|  |  |      size_t *protected_output_frames_size, size_t *still_pending_size) {
 | 
	
		
			
				|  |  | -  if (self == NULL || protected_output_frames == NULL ||
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || protected_output_frames == NULL ||
 | 
	
		
			
				|  |  |        protected_output_frames_size == NULL || still_pending_size == NULL) {
 | 
	
		
			
				|  |  |      return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->protect_flush == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +  if (self->vtable->protect_flush == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->protect_flush(self, protected_output_frames,
 | 
	
		
			
				|  |  |                                       protected_output_frames_size,
 | 
	
		
			
				|  |  |                                       still_pending_size);
 | 
	
	
		
			
				|  | @@ -106,14 +102,12 @@ tsi_result tsi_frame_protector_unprotect(
 | 
	
		
			
				|  |  |      tsi_frame_protector *self, const unsigned char *protected_frames_bytes,
 | 
	
		
			
				|  |  |      size_t *protected_frames_bytes_size, unsigned char *unprotected_bytes,
 | 
	
		
			
				|  |  |      size_t *unprotected_bytes_size) {
 | 
	
		
			
				|  |  | -  if (self == NULL || protected_frames_bytes == NULL ||
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || protected_frames_bytes == NULL ||
 | 
	
		
			
				|  |  |        protected_frames_bytes_size == NULL || unprotected_bytes == NULL ||
 | 
	
		
			
				|  |  |        unprotected_bytes_size == NULL) {
 | 
	
		
			
				|  |  |      return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->unprotect == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +  if (self->vtable->unprotect == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->unprotect(self, protected_frames_bytes,
 | 
	
		
			
				|  |  |                                   protected_frames_bytes_size, unprotected_bytes,
 | 
	
		
			
				|  |  |                                   unprotected_bytes_size);
 | 
	
	
		
			
				|  | @@ -131,48 +125,44 @@ void tsi_frame_protector_destroy(tsi_frame_protector *self) {
 | 
	
		
			
				|  |  |  tsi_result tsi_handshaker_get_bytes_to_send_to_peer(tsi_handshaker *self,
 | 
	
		
			
				|  |  |                                                      unsigned char *bytes,
 | 
	
		
			
				|  |  |                                                      size_t *bytes_size) {
 | 
	
		
			
				|  |  | -  if (self == NULL || bytes == NULL || bytes_size == NULL) {
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || bytes == NULL ||
 | 
	
		
			
				|  |  | +      bytes_size == NULL) {
 | 
	
		
			
				|  |  |      return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->get_bytes_to_send_to_peer == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +  if (self->vtable->get_bytes_to_send_to_peer == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->get_bytes_to_send_to_peer(self, bytes, bytes_size);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  tsi_result tsi_handshaker_process_bytes_from_peer(tsi_handshaker *self,
 | 
	
		
			
				|  |  |                                                    const unsigned char *bytes,
 | 
	
		
			
				|  |  |                                                    size_t *bytes_size) {
 | 
	
		
			
				|  |  | -  if (self == NULL || bytes == NULL || bytes_size == NULL) {
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || bytes == NULL ||
 | 
	
		
			
				|  |  | +      bytes_size == NULL) {
 | 
	
		
			
				|  |  |      return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->process_bytes_from_peer == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +  if (self->vtable->process_bytes_from_peer == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->process_bytes_from_peer(self, bytes, bytes_size);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  tsi_result tsi_handshaker_get_result(tsi_handshaker *self) {
 | 
	
		
			
				|  |  | -  if (self == NULL) return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL) return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->get_result == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +  if (self->vtable->get_result == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->get_result(self);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  tsi_result tsi_handshaker_extract_peer(tsi_handshaker *self, tsi_peer *peer) {
 | 
	
		
			
				|  |  | -  if (self == NULL || peer == NULL) return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || peer == NULL) {
 | 
	
		
			
				|  |  | +    return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |    memset(peer, 0, sizeof(tsi_peer));
 | 
	
		
			
				|  |  |    if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  |    if (tsi_handshaker_get_result(self) != TSI_OK) {
 | 
	
		
			
				|  |  |      return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->extract_peer == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +  if (self->vtable->extract_peer == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->extract_peer(self, peer);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -180,14 +170,12 @@ tsi_result tsi_handshaker_create_frame_protector(
 | 
	
		
			
				|  |  |      tsi_handshaker *self, size_t *max_protected_frame_size,
 | 
	
		
			
				|  |  |      tsi_frame_protector **protector) {
 | 
	
		
			
				|  |  |    tsi_result result;
 | 
	
		
			
				|  |  | -  if (self == NULL || protector == NULL) return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  | -  if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  | -  if (tsi_handshaker_get_result(self) != TSI_OK) {
 | 
	
		
			
				|  |  | -    return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->create_frame_protector == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || protector == NULL) {
 | 
	
		
			
				|  |  | +    return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +  if (self->frame_protector_created) return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  | +  if (tsi_handshaker_get_result(self) != TSI_OK) return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  | +  if (self->vtable->create_frame_protector == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    result = self->vtable->create_frame_protector(self, max_protected_frame_size,
 | 
	
		
			
				|  |  |                                                  protector);
 | 
	
		
			
				|  |  |    if (result == TSI_OK) {
 | 
	
	
		
			
				|  | @@ -201,11 +189,9 @@ tsi_result tsi_handshaker_next(
 | 
	
		
			
				|  |  |      size_t received_bytes_size, unsigned char **bytes_to_send,
 | 
	
		
			
				|  |  |      size_t *bytes_to_send_size, tsi_handshaker_result **handshaker_result,
 | 
	
		
			
				|  |  |      tsi_handshaker_on_next_done_cb cb, void *user_data) {
 | 
	
		
			
				|  |  | -  if (self == NULL) return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL) return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    if (self->handshaker_result_created) return TSI_FAILED_PRECONDITION;
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->next == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +  if (self->vtable->next == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->next(self, received_bytes, received_bytes_size,
 | 
	
		
			
				|  |  |                              bytes_to_send, bytes_to_send_size,
 | 
	
		
			
				|  |  |                              handshaker_result, cb, user_data);
 | 
	
	
		
			
				|  | @@ -220,21 +206,21 @@ void tsi_handshaker_destroy(tsi_handshaker *self) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result *self,
 | 
	
		
			
				|  |  |                                                tsi_peer *peer) {
 | 
	
		
			
				|  |  | -  if (self == NULL || peer == NULL) return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  | -  memset(peer, 0, sizeof(tsi_peer));
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->extract_peer == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || peer == NULL) {
 | 
	
		
			
				|  |  | +    return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +  memset(peer, 0, sizeof(tsi_peer));
 | 
	
		
			
				|  |  | +  if (self->vtable->extract_peer == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->extract_peer(self, peer);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  tsi_result tsi_handshaker_result_create_frame_protector(
 | 
	
		
			
				|  |  |      const tsi_handshaker_result *self, size_t *max_protected_frame_size,
 | 
	
		
			
				|  |  |      tsi_frame_protector **protector) {
 | 
	
		
			
				|  |  | -  if (self == NULL || protector == NULL) return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->create_frame_protector == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || protector == NULL) {
 | 
	
		
			
				|  |  | +    return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +  if (self->vtable->create_frame_protector == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->create_frame_protector(self, max_protected_frame_size,
 | 
	
		
			
				|  |  |                                                protector);
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -242,12 +228,11 @@ tsi_result tsi_handshaker_result_create_frame_protector(
 | 
	
		
			
				|  |  |  tsi_result tsi_handshaker_result_get_unused_bytes(
 | 
	
		
			
				|  |  |      const tsi_handshaker_result *self, const unsigned char **bytes,
 | 
	
		
			
				|  |  |      size_t *bytes_size) {
 | 
	
		
			
				|  |  | -  if (self == NULL || bytes == NULL || bytes_size == NULL) {
 | 
	
		
			
				|  |  | +  if (self == NULL || self->vtable == NULL || bytes == NULL ||
 | 
	
		
			
				|  |  | +      bytes_size == NULL) {
 | 
	
		
			
				|  |  |      return TSI_INVALID_ARGUMENT;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  if (self->vtable == NULL || self->vtable->get_unused_bytes == NULL) {
 | 
	
		
			
				|  |  | -    return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +  if (self->vtable->get_unused_bytes == NULL) return TSI_UNIMPLEMENTED;
 | 
	
		
			
				|  |  |    return self->vtable->get_unused_bytes(self, bytes, bytes_size);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |