#include <ipxe/sha1.h>
#include <ipxe/sha256.h>
#include <ipxe/x509.h>
+#include <ipxe/pending.h>
/** A TLS header */
struct tls_header {
/** Certificate validator */
struct interface validator;
- /** Client has finished security negotiation */
- unsigned int client_finished;
- /** Server has finished security negotiation */
- unsigned int server_finished;
+ /** Client security negotiation pending operation */
+ struct pending_operation client_negotiation;
+ /** Server security negotiation pending operation */
+ struct pending_operation server_negotiation;
/** TX sequence number */
uint64_t tx_seq;
#include <time.h>
#include <errno.h>
#include <byteswap.h>
+#include <ipxe/pending.h>
#include <ipxe/hmac.h>
#include <ipxe/md5.h>
#include <ipxe/sha1.h>
* @ret is_ready TLS session is ready
*/
static int tls_ready ( struct tls_session *tls ) {
- return ( tls->client_finished && tls->server_finished );
+ return ( ( ! is_pending ( &tls->client_negotiation ) ) &&
+ ( ! is_pending ( &tls->server_negotiation ) ) );
}
/******************************************************************************
*/
static void tls_close ( struct tls_session *tls, int rc ) {
+ /* Remove pending operations, if applicable */
+ pending_put ( &tls->client_negotiation );
+ pending_put ( &tls->server_negotiation );
+
/* Remove process */
process_del ( &tls->process );
return rc;
/* Mark client as finished */
- tls->client_finished = 1;
+ pending_put ( &tls->client_negotiation );
return 0;
}
}
/* Mark server as finished */
- tls->server_finished = 1;
+ pending_put ( &tls->server_negotiation );
/* Send notification of a window change */
xfer_window_changed ( &tls->plainstream );
tls->handshake_ctx = tls->handshake_sha256_ctx;
tls->tx_pending = TLS_TX_CLIENT_HELLO;
+ /* Add pending operations for server and client Finished messages */
+ pending_get ( &tls->client_negotiation );
+ pending_get ( &tls->server_negotiation );
+
/* Attach to parent interface, mortalise self, and return */
intf_plug_plug ( &tls->plainstream, xfer );
*next = &tls->cipherstream;