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;