Merge pull request #9496 from minosgalanakis/doc/add_mbedtls_ecp_check_privkey_comment_bp28
[Backport 2.28] Refactored a minor check in ecp check privkey
diff --git a/library/ecp.c b/library/ecp.c
index cfe02b0..2ed735d 100644
--- a/library/ecp.c
+++ b/library/ecp.c
@@ -3125,7 +3125,7 @@
/* see RFC 7748 sec. 5 para. 5 */
if (mbedtls_mpi_get_bit(d, 0) != 0 ||
mbedtls_mpi_get_bit(d, 1) != 0 ||
- mbedtls_mpi_bitlen(d) - 1 != grp->nbits) { /* mbedtls_mpi_bitlen is one-based! */
+ mbedtls_mpi_bitlen(d) != grp->nbits + 1) { /* mbedtls_mpi_bitlen is one-based! */
return MBEDTLS_ERR_ECP_INVALID_KEY;
}