Merge pull request #3412 from cesanta/unbreak

unbreak stuff after last commit
This commit is contained in:
Sergio R. Caprile authored and GitHub committed 2026-01-20 18:58:12 -03:00
commit 3f59974639
3 files changed
+30 -30

No files matched your search

+15 -15
View File
@@ -13319,17 +13319,17 @@ static void mg_tls_mgf1(uint8_t *mask, size_t mask_len, const uint8_t *seed,
}
}
static unsigned mg_tls_rsa_bits(const struct mg_str *n) {
static unsigned int mg_tls_rsa_bits(const struct mg_str *n) {
size_t i = 0;
unsigned bits = 0;
unsigned int bits = 0;
while (i < n->len && n->buf[i] == 0) i++;
if (i == n->len) return 0;
bits = (unsigned) ((n->len - i) * 8);
bits = (unsigned int) ((n->len - i) * 8);
{
uint8_t byte = (uint8_t) n->buf[i];
while ((byte & 0x80U) == 0) {
bits--;
byte <<= 1;
byte = (uint8_t) (byte << 1);
}
}
return bits;
@@ -13492,9 +13492,9 @@ static bool mg_tls_send_cert_verify(struct mg_connection *c, bool is_client) {
// Build verify packet header, then sign directly into the packet
verify[0] = 0x0f;
MG_STORE_BE24(verify + 1, (uint32_t) (emlen + 4));
MG_STORE_BE24(verify + 1, emlen + 4);
MG_STORE_BE16(verify + 4, 0x0804);
MG_STORE_BE16(verify + 6, (uint16_t) emlen);
MG_STORE_BE16(verify + 6, emlen);
// Sign directly into the verify buffer (verify + 8 = signature location)
memset(verify + 8, 0, emlen); // Initialize signature area
@@ -14447,7 +14447,7 @@ static int mg_rsa_parse_der_int(const uint8_t **p, const uint8_t *end,
*p = value_end;
MG_VERBOSE(("DER INT: parsed %u bytes (skipped zero=%d)", len,
value_end - value_start != len ? 1 : 0));
(size_t)(value_end - value_start) != (size_t) len ? 1 : 0));
return 0;
}
@@ -14499,7 +14499,7 @@ static int mg_parse_ec_private_key(const uint8_t *der, size_t dersz,
// exponent2 INTEGER, -- dQ = d mod (q-1)
// coefficient INTEGER, -- qInv = (inverse of q) mod p
// }
int mg_rsa_parse_key(const uint8_t *der, size_t dersz, struct mg_rsa_key *key) {
static int mg_rsa_parse_key(const uint8_t *der, size_t dersz, struct mg_rsa_key *key) {
const uint8_t *p = der;
const uint8_t *end = der + dersz;
uint32_t seq_len;
@@ -18586,12 +18586,12 @@ int mg_rsa_crt_sign(const uint8_t *em, size_t em_len,
return -1;
}
em_bi = bi_import(ctx, em, em_len);
dP_bi = bi_import(ctx, dP, dP_len);
dQ_bi = bi_import(ctx, dQ, dQ_len);
p_bi = bi_import(ctx, p, p_len);
q_bi = bi_import(ctx, q, q_len);
qInv_bi = bi_import(ctx, qInv, qInv_len);
em_bi = bi_import(ctx, em, (int) em_len);
dP_bi = bi_import(ctx, dP, (int) dP_len);
dQ_bi = bi_import(ctx, dQ, (int) dQ_len);
p_bi = bi_import(ctx, p, (int) p_len);
q_bi = bi_import(ctx, q, (int) q_len);
qInv_bi = bi_import(ctx, qInv, (int) qInv_len);
if (em_bi == NULL || dP_bi == NULL || dQ_bi == NULL ||
p_bi == NULL || q_bi == NULL || qInv_bi == NULL) {
@@ -18605,7 +18605,7 @@ int mg_rsa_crt_sign(const uint8_t *em, size_t em_len,
if (result_bi == NULL) {
goto cleanup;
}
bi_export(ctx, result_bi, signature, sig_len);
bi_export(ctx, result_bi, signature, (int) sig_len);
ret = 0; // Success!
cleanup:
bi_free_mod(ctx, BIGINT_P_OFFSET); // cloned p_bi stored in mod context
+8 -8
View File
@@ -857,17 +857,17 @@ static void mg_tls_mgf1(uint8_t *mask, size_t mask_len, const uint8_t *seed,
}
}
static unsigned mg_tls_rsa_bits(const struct mg_str *n) {
static unsigned int mg_tls_rsa_bits(const struct mg_str *n) {
size_t i = 0;
unsigned bits = 0;
unsigned int bits = 0;
while (i < n->len && n->buf[i] == 0) i++;
if (i == n->len) return 0;
bits = (unsigned) ((n->len - i) * 8);
bits = (unsigned int) ((n->len - i) * 8);
{
uint8_t byte = (uint8_t) n->buf[i];
while ((byte & 0x80U) == 0) {
bits--;
byte <<= 1;
byte = (uint8_t) (byte << 1);
}
}
return bits;
@@ -1030,9 +1030,9 @@ static bool mg_tls_send_cert_verify(struct mg_connection *c, bool is_client) {
// Build verify packet header, then sign directly into the packet
verify[0] = 0x0f;
MG_STORE_BE24(verify + 1, (uint32_t) (emlen + 4));
MG_STORE_BE24(verify + 1, emlen + 4);
MG_STORE_BE16(verify + 4, 0x0804);
MG_STORE_BE16(verify + 6, (uint16_t) emlen);
MG_STORE_BE16(verify + 6, emlen);
// Sign directly into the verify buffer (verify + 8 = signature location)
memset(verify + 8, 0, emlen); // Initialize signature area
@@ -1985,7 +1985,7 @@ static int mg_rsa_parse_der_int(const uint8_t **p, const uint8_t *end,
*p = value_end;
MG_VERBOSE(("DER INT: parsed %u bytes (skipped zero=%d)", len,
value_end - value_start != len ? 1 : 0));
(size_t)(value_end - value_start) != (size_t) len ? 1 : 0));
return 0;
}
@@ -2037,7 +2037,7 @@ static int mg_parse_ec_private_key(const uint8_t *der, size_t dersz,
// exponent2 INTEGER, -- dQ = d mod (q-1)
// coefficient INTEGER, -- qInv = (inverse of q) mod p
// }
int mg_rsa_parse_key(const uint8_t *der, size_t dersz, struct mg_rsa_key *key) {
static int mg_rsa_parse_key(const uint8_t *der, size_t dersz, struct mg_rsa_key *key) {
const uint8_t *p = der;
const uint8_t *end = der + dersz;
uint32_t seq_len;
+7 -7
View File
@@ -1603,12 +1603,12 @@ int mg_rsa_crt_sign(const uint8_t *em, size_t em_len,
return -1;
}
em_bi = bi_import(ctx, em, em_len);
dP_bi = bi_import(ctx, dP, dP_len);
dQ_bi = bi_import(ctx, dQ, dQ_len);
p_bi = bi_import(ctx, p, p_len);
q_bi = bi_import(ctx, q, q_len);
qInv_bi = bi_import(ctx, qInv, qInv_len);
em_bi = bi_import(ctx, em, (int) em_len);
dP_bi = bi_import(ctx, dP, (int) dP_len);
dQ_bi = bi_import(ctx, dQ, (int) dQ_len);
p_bi = bi_import(ctx, p, (int) p_len);
q_bi = bi_import(ctx, q, (int) q_len);
qInv_bi = bi_import(ctx, qInv, (int) qInv_len);
if (em_bi == NULL || dP_bi == NULL || dQ_bi == NULL ||
p_bi == NULL || q_bi == NULL || qInv_bi == NULL) {
@@ -1622,7 +1622,7 @@ int mg_rsa_crt_sign(const uint8_t *em, size_t em_len,
if (result_bi == NULL) {
goto cleanup;
}
bi_export(ctx, result_bi, signature, sig_len);
bi_export(ctx, result_bi, signature, (int) sig_len);
ret = 0; // Success!
cleanup:
bi_free_mod(ctx, BIGINT_P_OFFSET); // cloned p_bi stored in mod context