Switch ssl3_send_channel_id to BN_bn2bin_padded.

Check the return value while we're here. This avoids some arithmetic and
appease scan-build's dead assignment flagger.

Change-Id: If3615076e091eb44b9e3e9d50cd64f80e645337e
Reviewed-on: https://boringssl-review.googlesource.com/2204
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2014-11-02 17:32:40 -05:00 committed by Adam Langley
parent 626fb8b75c
commit f2b32a2de2

View File

@ -2699,11 +2699,12 @@ int ssl3_send_channel_id(SSL *s)
/* The first byte of public_key will be 0x4, denoting an uncompressed key. */
memcpy(d, public_key + 1, 64);
d += 64;
memset(d, 0, 2 * 32);
BN_bn2bin(sig->r, d + 32 - BN_num_bytes(sig->r));
d += 32;
BN_bn2bin(sig->s, d + 32 - BN_num_bytes(sig->s));
d += 32;
if (!BN_bn2bin_padded(d, 32, sig->r) ||
!BN_bn2bin_padded(d + 32, 32, sig->s))
{
OPENSSL_PUT_ERROR(SSL, ssl3_send_channel_id, ERR_R_INTERNAL_ERROR);
goto err;
}
s->state = SSL3_ST_CW_CHANNEL_ID_B;
s->init_num = 4 + 2 + 2 + TLSEXT_CHANNEL_ID_SIZE;