/* * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */#include<string.h>#include<openssl/bio.h>#include<openssl/x509_vfy.h>#include<openssl/ssl.h>#ifndef OPENSSL_NO_SRP#include<openssl/srp.h>#endif#include"handshake_helper.h"#include"testutil.h"HANDSHAKE_RESULT*HANDSHAKE_RESULT_new(){HANDSHAKE_RESULT*ret=OPENSSL_zalloc(sizeof(*ret));TEST_check(ret!=NULL);returnret;}voidHANDSHAKE_RESULT_free(HANDSHAKE_RESULT*result){if(result==NULL)return;OPENSSL_free(result->client_npn_negotiated);OPENSSL_free(result->server_npn_negotiated);OPENSSL_free(result->client_alpn_negotiated);OPENSSL_free(result->server_alpn_negotiated);sk_X509_NAME_pop_free(result->server_ca_names,X509_NAME_free);sk_X509_NAME_pop_free(result->client_ca_names,X509_NAME_free);OPENSSL_free(result);}/* * Since there appears to be no way to extract the sent/received alert * from the SSL object directly, we use the info callback and stash * the result in ex_data. */typedefstructhandshake_ex_data_st{intalert_sent;intnum_fatal_alerts_sent;intalert_received;intsession_ticket_do_not_call;ssl_servername_tservername;}HANDSHAKE_EX_DATA;typedefstructctx_data_st{unsignedchar*npn_protocols;size_tnpn_protocols_len;unsignedchar*alpn_protocols;size_talpn_protocols_len;char*srp_user;char*srp_password;}CTX_DATA;/* |ctx_data| itself is stack-allocated. */staticvoidctx_data_free_data(CTX_DATA*ctx_data){OPENSSL_free(ctx_data->npn_protocols);ctx_data->npn_protocols=NULL;