From 33a4649733e5cdfc61af33363552c4bfb11f1cd3 Mon Sep 17 00:00:00 2001 From: Mathias Raoul Date: Wed, 27 Jan 2021 15:35:54 +0000 Subject: quic: clean setup_cipher function Type: fix Change-Id: I02e473440a8732ddfb1a13ad6552779adaa67f60 Signed-off-by: Mathias Raoul --- src/plugins/quic/quic_crypto.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/plugins/quic') diff --git a/src/plugins/quic/quic_crypto.c b/src/plugins/quic/quic_crypto.c index 5e90563885e..15e5f0d52fb 100644 --- a/src/plugins/quic/quic_crypto.c +++ b/src/plugins/quic/quic_crypto.c @@ -55,18 +55,18 @@ quic_crypto_setup_cipher (quicly_crypto_engine_t *engine, quicly_conn_t *conn, int ret; *packet_protect_ctx = NULL; - /* generate new header protection key */ if (header_protect_ctx != NULL) { *header_protect_ctx = NULL; - if ((ret = ptls_hkdf_expand_label ( - hash, hpkey, aead->ctr_cipher->key_size, - ptls_iovec_init (secret, hash->digest_size), "quic hp", - ptls_iovec_init (NULL, 0), NULL)) != 0) + ret = + ptls_hkdf_expand_label (hash, hpkey, aead->ctr_cipher->key_size, + ptls_iovec_init (secret, hash->digest_size), + "quic hp", ptls_iovec_init (NULL, 0), NULL); + if (ret) goto Exit; - if ((*header_protect_ctx = - ptls_cipher_new (aead->ctr_cipher, is_enc, hpkey)) == NULL) + *header_protect_ctx = ptls_cipher_new (aead->ctr_cipher, is_enc, hpkey); + if (NULL == *header_protect_ctx) { ret = PTLS_ERROR_NO_MEMORY; goto Exit; @@ -74,8 +74,9 @@ quic_crypto_setup_cipher (quicly_crypto_engine_t *engine, quicly_conn_t *conn, } /* generate new AEAD context */ - if ((*packet_protect_ctx = ptls_aead_new (aead, hash, is_enc, secret, - QUICLY_AEAD_BASE_LABEL)) == NULL) + *packet_protect_ctx = + ptls_aead_new (aead, hash, is_enc, secret, QUICLY_AEAD_BASE_LABEL); + if (NULL == *packet_protect_ctx) { ret = PTLS_ERROR_NO_MEMORY; goto Exit; @@ -97,7 +98,7 @@ quic_crypto_setup_cipher (quicly_crypto_engine_t *engine, quicly_conn_t *conn, Exit: if (ret) { - if (packet_protect_ctx && *packet_protect_ctx != NULL) + if (*packet_protect_ctx != NULL) { ptls_aead_free (*packet_protect_ctx); *packet_protect_ctx = NULL; -- cgit 1.2.3-korg