aboutsummaryrefslogtreecommitdiff
path: root/ecdsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'ecdsa.c')
-rw-r--r--ecdsa.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/ecdsa.c b/ecdsa.c
index b9b14d8..d1b8d0c 100644
--- a/ecdsa.c
+++ b/ecdsa.c
@@ -199,7 +199,7 @@ const size_t hal_ecdsa_key_t_size = sizeof(struct hal_ecdsa_key);
* first time anything asks for any of them.
*/
-static const ecdsa_curve_t * const get_curve(const hal_curve_name_t curve)
+static const ecdsa_curve_t * get_curve(const hal_curve_name_t curve)
{
static ecdsa_curve_t curve_p256, curve_p384, curve_p521;
static int initialized = 0;
@@ -806,18 +806,18 @@ static hal_error_t verilog_point_pick_random(const verilog_ecdsa_driver_t * cons
memset(b, 0, sizeof(b));
fp_to_unsigned_bin(k, b + sizeof(b) - len);
- for (int i = 0; i < sizeof(b); i += 4)
+ for (size_t i = 0; i < sizeof(b); i += 4)
check(hal_io_write(core, driver->k_addr + i/4, &b[sizeof(b) - 4 - i], 4));
check(hal_io_write(core, ADDR_CTRL, zero, sizeof(zero)));
check(hal_io_next(core));
check(hal_io_wait_valid(core));
- for (int i = 0; i < sizeof(b); i += 4)
+ for (size_t i = 0; i < sizeof(b); i += 4)
check(hal_io_read(core, driver->x_addr + i/4, &b[sizeof(b) - 4 - i], 4));
fp_read_unsigned_bin(P->x, b, sizeof(b));
- for (int i = 0; i < sizeof(b); i += 4)
+ for (size_t i = 0; i < sizeof(b); i += 4)
check(hal_io_read(core, driver->y_addr + i/4, &b[sizeof(b) - 4 - i], 4));
fp_read_unsigned_bin(P->y, b, sizeof(b));
@@ -970,7 +970,7 @@ static int point_is_on_curve(const ec_point_t * const P,
* Generate a new ECDSA key.
*/
-hal_error_t hal_ecdsa_key_gen(const hal_core_t *core,
+hal_error_t hal_ecdsa_key_gen(hal_core_t *core,
hal_ecdsa_key_t **key_,
void *keybuf, const size_t keybuf_len,
const hal_curve_name_t curve_)
@@ -1422,7 +1422,7 @@ hal_error_t hal_ecdsa_private_key_from_der(hal_ecdsa_key_t **key_,
if ((err = hal_asn1_decode_header(ASN1_EXPLICIT_1, d, der_end - d, &hlen, &vlen)) != HAL_OK)
goto fail;
d += hlen;
- if (vlen > der_end - d)
+ if (vlen > (size_t)(der_end - d))
lose(HAL_ERROR_ASN1_PARSE_FAILED);
if ((err = hal_asn1_decode_header(ASN1_BIT_STRING, d, vlen, &hlen, &vlen)) != HAL_OK)
goto fail;
@@ -1530,7 +1530,7 @@ hal_error_t hal_ecdsa_public_key_from_der(hal_ecdsa_key_t **key_,
memcmp(alg_oid, hal_asn1_oid_ecPublicKey, alg_oid_len) != 0 ||
hal_ecdsa_oid_to_curve(&key->curve, curve_oid, curve_oid_len) != HAL_OK ||
pubkey_len < 3 || (pubkey_len & 1) == 0 || pubkey[0] != 0x04 ||
- pubkey_len / 2 != fp_unsigned_bin_size(unconst_fp_int(get_curve(key->curve)->q)))
+ pubkey_len / 2 != (size_t)(fp_unsigned_bin_size(unconst_fp_int(get_curve(key->curve)->q))))
return HAL_ERROR_ASN1_PARSE_FAILED;
const uint8_t * const Qx = pubkey + 1;
@@ -1596,7 +1596,7 @@ static hal_error_t decode_signature_pkcs11(const ecdsa_curve_t * const curve,
const size_t n_len = signature_len / 2;
- if (n_len > fp_unsigned_bin_size(unconst_fp_int(curve->n)))
+ if (n_len > (size_t)(fp_unsigned_bin_size(unconst_fp_int(curve->n))))
return HAL_ERROR_BAD_ARGUMENTS;
fp_read_unsigned_bin(r, unconst_uint8_t(signature) + 0 * n_len, n_len);
@@ -1609,7 +1609,7 @@ static hal_error_t decode_signature_pkcs11(const ecdsa_curve_t * const curve,
* Sign a caller-supplied hash.
*/
-hal_error_t hal_ecdsa_sign(const hal_core_t *core,
+hal_error_t hal_ecdsa_sign(hal_core_t *core,
const hal_ecdsa_key_t * const key,
const uint8_t * const hash, const size_t hash_len,
uint8_t *signature, size_t *signature_len, const size_t signature_max)
@@ -1690,7 +1690,7 @@ hal_error_t hal_ecdsa_sign(const hal_core_t *core,
* Verify a signature using a caller-supplied hash.
*/
-hal_error_t hal_ecdsa_verify(const hal_core_t *core,
+hal_error_t hal_ecdsa_verify(hal_core_t *core,
const hal_ecdsa_key_t * const key,
const uint8_t * const hash, const size_t hash_len,
const uint8_t * const signature, const size_t signature_len)