Add tests for round 2
Also move one check earlier as it makes more sense
diff --git a/library/ecjpake.c b/library/ecjpake.c
index 4ffeaa3..f5863bc 100644
--- a/library/ecjpake.c
+++ b/library/ecjpake.c
@@ -548,7 +548,15 @@
* } Client/ServerECJPAKEParams;
*/
if( ctx->role == MBEDTLS_ECJPAKE_CLIENT )
+ {
MBEDTLS_MPI_CHK( mbedtls_ecp_tls_read_group( &grp, &p, len ) );
+ if( grp.id != ctx->grp.id )
+ {
+ ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE;
+ goto cleanup;
+ }
+ }
+
MBEDTLS_MPI_CHK( ecjpake_kkp_read( ctx->md_info, &ctx->grp,
&G, &ctx->Xp, ID_PEER, &p, end ) );
@@ -558,14 +566,6 @@
goto cleanup;
}
- /*
- * Xs already checked, only thing left to check is the group,
- */
- if( ctx->role == MBEDTLS_ECJPAKE_CLIENT && grp.id != ctx->grp.id )
- {
- ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE;
- goto cleanup;
- }
cleanup:
mbedtls_ecp_group_free( &grp );
mbedtls_ecp_point_free( &G );