All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ell@lists.01.org
Subject: Re: [PATCH 3/4] tls: DHE_RSA key exchange implementation server side
Date: Wed, 09 Jan 2019 11:12:18 -0600	[thread overview]
Message-ID: <822f4e43-ebd3-a198-4527-2018cc3a855c@gmail.com> (raw)
In-Reply-To: <20190109104349.11763-3-andrew.zaborowski@intel.com>

[-- Attachment #1: Type: text/plain, Size: 2069 bytes --]

Hi Andrew,

On 01/09/2019 04:43 AM, Andrew Zaborowski wrote:
> Add the handler for the ClientKeyExchange message and a builder callback
> for the ServerKeyExchange message for DHE_RSA.
> ---
>   ell/tls-suites.c | 187 +++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 187 insertions(+)

<snip>

> +
> +	params->server_dh_params_buf = ptr;

This part seems a bit hacky..

> +
> +	/* RFC 5246, Section 7.4.3 */
> +
> +	l_put_be16(params->prime_len, ptr);
> +	memcpy(ptr + 2, prime_buf, params->prime_len);
> +	ptr += 2 + params->prime_len;
> +
> +	l_put_be16(1, ptr);
> +	memcpy(ptr + 2, &generator_buf, 1);
> +	ptr += 2 + 1;
> +
> +	l_put_be16(public_len - zeros, ptr);
> +	memcpy(ptr + 2, public_buf + zeros, public_len - zeros);
> +	ptr += 2 + public_len - zeros;
> +
> +	params->server_dh_params_len = ptr - params->server_dh_params_buf;
> +	tls->pending.key_xchg_params = params;
> +
> +	sign_len = tls->pending.cipher_suite->key_xchg->sign(tls, ptr,
> +					buf + sizeof(buf) - ptr,
> +					tls_get_server_dh_params_hash);

The way you did it in ecdh seems to be much cleaner.  Perhaps the 
sign/verify operation should be receiving the data to be hashed directly 
(maybe as an iovec), instead of having get_hash function lookup the hash 
id, create the checksum, run it, check for errors, etc).  You are 
already duplicating these steps in tls_get_server_ecdh_params_hash and 
tls_get_server_dh_params_hash.  Admittedly, tls_get_prev_digest_by_id is 
a bit of a special case.

At the very least can we zero out the server_dh_params & 
server_dh_params_len after you're done here (and similarly in patch 2)?

> +	if (sign_len < 0)
> +		return false;
> +
> +	ptr += sign_len;
> +	tls_tx_handshake(tls, TLS_SERVER_KEY_EXCHANGE, buf, ptr - buf);
> +	return true;
> +
> +free_params:
> +	l_key_free(params->prime);
> +	l_key_free(params->generator);
> +	l_key_free(params->private);
> +	l_free(params);
> +	return false;
> +}
> +

Anyway, I applied all 4 of these.

Regards,
-Denis

  reply	other threads:[~2019-01-09 17:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09 10:43 [PATCH 1/4] key: Add l_key_validate_dh_payload Andrew Zaborowski
2019-01-09 10:43 ` [PATCH 2/4] tls: DHE_RSA key exchange implementation client side Andrew Zaborowski
2019-01-09 10:43 ` [PATCH 3/4] tls: DHE_RSA key exchange implementation server side Andrew Zaborowski
2019-01-09 17:12   ` Denis Kenzior [this message]
2019-01-10  1:21     ` Andrew Zaborowski
2019-01-10 17:24       ` Denis Kenzior
2019-01-11 10:50         ` Andrew Zaborowski
2019-01-09 10:43 ` [PATCH 4/4] tls: Add DHE_RSA-based cipher suites Andrew Zaborowski
2019-01-09 13:40 ` [PATCH 1/4] key: Add l_key_validate_dh_payload Jan Engelhardt
2019-01-09 14:54   ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=822f4e43-ebd3-a198-4527-2018cc3a855c@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ell@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.