From e3501ac18fb88a3eebff2c8d9e468d17bb6bef99 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Thu, 29 Mar 2018 14:55:55 +1000 Subject: [PATCH] wolfSSL: Fix crypto_ec_point_solve_y_coord() Provide full uncompressed DER data length to wc_ecc_import_point_der() even though a compressed form is used here. In addition, use ECC_POINT_COMP_* defined values to make this more readable. Signed-off-by: Sean Parkinson --- src/crypto/crypto_wolfssl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crypto/crypto_wolfssl.c b/src/crypto/crypto_wolfssl.c index c260d4ed0..11f7b361a 100644 --- a/src/crypto/crypto_wolfssl.c +++ b/src/crypto/crypto_wolfssl.c @@ -1586,18 +1586,18 @@ int crypto_ec_point_solve_y_coord(struct crypto_ec *e, struct crypto_ec_point *p, const struct crypto_bignum *x, int y_bit) { - byte buf[MAX_ECC_BYTES + 1]; + byte buf[1 + 2 * MAX_ECC_BYTES]; int ret; int prime_len = crypto_ec_prime_len(e); if (TEST_FAIL()) return -1; - buf[0] = 0x2 + (byte) y_bit; + buf[0] = y_bit ? ECC_POINT_COMP_ODD : ECC_POINT_COMP_EVEN; ret = crypto_bignum_to_bin(x, buf + 1, prime_len, prime_len); if (ret <= 0) return -1; - ret = wc_ecc_import_point_der(buf, ret + 1, e->key.idx, + ret = wc_ecc_import_point_der(buf, 1 + 2 * ret, e->key.idx, (ecc_point *) p); if (ret != 0) return -1;