mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Use size_t cast for pointer subtractions
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
@ -168,7 +168,7 @@ static int ecjpake_write_len_point(unsigned char **p,
|
||||
}
|
||||
|
||||
ret = mbedtls_ecp_point_write_binary(grp, P, pf,
|
||||
&len, *p + 4, end - (*p + 4));
|
||||
&len, *p + 4, (size_t) (end - (*p + 4)));
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -226,7 +226,7 @@ static int ecjpake_hash(const mbedtls_md_type_t md_type,
|
||||
|
||||
/* Compute hash */
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecjpake_compute_hash(md_type,
|
||||
buf, p - buf, hash));
|
||||
buf, (size_t) (p - buf), hash));
|
||||
|
||||
/* Turn it into an integer mod n */
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(h, hash,
|
||||
@ -269,7 +269,7 @@ static int ecjpake_zkp_read(const mbedtls_md_type_t md_type,
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecp_tls_read_point(grp, &V, p, end - *p));
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecp_tls_read_point(grp, &V, p, (size_t) (end - *p)));
|
||||
|
||||
if (end < *p || (size_t) (end - *p) < 1) {
|
||||
ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
@ -346,7 +346,7 @@ static int ecjpake_zkp_write(const mbedtls_md_type_t md_type,
|
||||
|
||||
/* Write it out */
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecp_tls_write_point(grp, &V,
|
||||
pf, &len, *p, end - *p));
|
||||
pf, &len, *p, (size_t) (end - *p)));
|
||||
*p += len;
|
||||
|
||||
len = mbedtls_mpi_size(&h); /* actually r */
|
||||
@ -392,7 +392,7 @@ static int ecjpake_kkp_read(const mbedtls_md_type_t md_type,
|
||||
* ECSchnorrZKP zkp;
|
||||
* } ECJPAKEKeyKP;
|
||||
*/
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecp_tls_read_point(grp, X, p, end - *p));
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecp_tls_read_point(grp, X, p, (size_t) (end - *p)));
|
||||
if (mbedtls_ecp_is_zero(X)) {
|
||||
ret = MBEDTLS_ERR_ECP_INVALID_KEY;
|
||||
goto cleanup;
|
||||
@ -431,7 +431,7 @@ static int ecjpake_kkp_write(const mbedtls_md_type_t md_type,
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecp_gen_keypair_base((mbedtls_ecp_group *) grp, G, x, X,
|
||||
f_rng, p_rng));
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecp_tls_write_point(grp, X,
|
||||
pf, &len, *p, end - *p));
|
||||
pf, &len, *p, (size_t) (end - *p)));
|
||||
*p += len;
|
||||
|
||||
/* Generate and write proof */
|
||||
@ -504,7 +504,7 @@ static int ecjpake_kkpp_write(const mbedtls_md_type_t md_type,
|
||||
MBEDTLS_MPI_CHK(ecjpake_kkp_write(md_type, grp, pf, G, xm2, Xb, id,
|
||||
&p, end, f_rng, p_rng));
|
||||
|
||||
*olen = p - buf;
|
||||
*olen = (size_t) (p - buf);
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
@ -693,7 +693,7 @@ int mbedtls_ecjpake_write_round_two(mbedtls_ecjpake_context *ctx,
|
||||
goto cleanup;
|
||||
}
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecp_tls_write_group(&ctx->grp, &ec_len,
|
||||
p, end - p));
|
||||
p, (size_t) (end - p)));
|
||||
p += ec_len;
|
||||
}
|
||||
|
||||
@ -702,7 +702,7 @@ int mbedtls_ecjpake_write_round_two(mbedtls_ecjpake_context *ctx,
|
||||
goto cleanup;
|
||||
}
|
||||
MBEDTLS_MPI_CHK(mbedtls_ecp_tls_write_point(&ctx->grp, &Xm,
|
||||
ctx->point_format, &ec_len, p, end - p));
|
||||
ctx->point_format, &ec_len, p, (size_t) (end - p)));
|
||||
p += ec_len;
|
||||
|
||||
MBEDTLS_MPI_CHK(ecjpake_zkp_write(ctx->md_type, &ctx->grp,
|
||||
@ -710,7 +710,7 @@ int mbedtls_ecjpake_write_round_two(mbedtls_ecjpake_context *ctx,
|
||||
&G, &xm, &Xm, ID_MINE,
|
||||
&p, end, f_rng, p_rng));
|
||||
|
||||
*olen = p - buf;
|
||||
*olen = (size_t) (p - buf);
|
||||
|
||||
cleanup:
|
||||
mbedtls_ecp_point_free(&G);
|
||||
|
Reference in New Issue
Block a user