In case of ctx is NULL or output_size is specified less than expected,
we'd rather bail out earlier without bothering with
see_supported_dhm_size().
Change-Id: I222a7a997de2ce6e27d2525c86a5e6fc9557b147
Signed-off-by: Junyeon LEE <junyeon2.lee@samsung.com>
int ret;
mbedtls_mpi GYb;
+ if (ctx == NULL || output_size < ctx->len) {
+ return (MBEDTLS_ERR_DHM_BAD_INPUT_DATA);
+ }
+
#if defined(CONFIG_HW_DH_PARAM)
if (see_supported_dhm_size(ctx->len)) {
return hw_calculate_dhm_secret(ctx, output, output_size, olen);
}
#endif
- if (ctx == NULL || output_size < ctx->len) {
- return (MBEDTLS_ERR_DHM_BAD_INPUT_DATA);
- }
-
if ((ret = dhm_check_range(&ctx->GY, &ctx->P)) != 0) {
return (ret);
}