mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-18 19:31:02 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63aaad829a |
No files matched your search
+11
-11
@@ -19166,8 +19166,8 @@ static bool mg_tls_server_send_hello(struct mg_connection *c) {
|
|||||||
|
|
||||||
// calculate P-256 keyshare and the shared secret
|
// calculate P-256 keyshare and the shared secret
|
||||||
pub[0] = 0x04; // uncompressed point 0x04 || X || Y
|
pub[0] = 0x04; // uncompressed point 0x04 || X || Y
|
||||||
if (!mg_p256_make_key(pub + 1, prv) ||
|
if (mg_p256_make_key(pub + 1, prv) == 0 ||
|
||||||
!mg_p256_shared_secret(tls->p256_peer, prv, tls->ecdhe_sec)) {
|
mg_p256_shared_secret(tls->p256_peer, prv, tls->ecdhe_sec) == 0) {
|
||||||
mg_bzero(prv, sizeof(prv));
|
mg_bzero(prv, sizeof(prv));
|
||||||
mg_error(c, "bad key");
|
mg_error(c, "bad key");
|
||||||
return false;
|
return false;
|
||||||
@@ -19582,7 +19582,7 @@ static bool mg_tls_send_cert_verify(struct mg_connection *c, bool is_client) {
|
|||||||
size_t sigsz, verifysz = 0;
|
size_t sigsz, verifysz = 0;
|
||||||
int adj1, adj2;
|
int adj1, adj2;
|
||||||
uint8_t sig[64] = {0};
|
uint8_t sig[64] = {0};
|
||||||
if (!mg_p256_sign(tls->ec_key, hash, sizeof(hash), sig)) {
|
if (mg_p256_sign(tls->ec_key, hash, sizeof(hash), sig) != 1) {
|
||||||
mg_error(c, "P-256 sign");
|
mg_error(c, "P-256 sign");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -19714,7 +19714,7 @@ static bool mg_tls_client_send_hello(struct mg_connection *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calc+fill keyshare; X || Y, sent as an uncompressed point 0x04 || X || Y
|
// calc+fill keyshare; X || Y, sent as an uncompressed point 0x04 || X || Y
|
||||||
if (!mg_p256_make_key(msg_client_hello + 95, tls->p256_cli)) {
|
if (mg_p256_make_key(msg_client_hello + 95, tls->p256_cli) == 0) {
|
||||||
mg_error(c, "P-256 key");
|
mg_error(c, "P-256 key");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -19804,8 +19804,8 @@ static int mg_tls_client_recv_hello(struct mg_connection *c) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (key_exchange_len != 65 || key_exchange[0] != 0x04 ||
|
if (key_exchange_len != 65 || key_exchange[0] != 0x04 ||
|
||||||
!mg_p256_shared_secret(key_exchange + 1, tls->p256_cli,
|
mg_p256_shared_secret(key_exchange + 1, tls->p256_cli,
|
||||||
tls->ecdhe_sec)) { // Validates the point
|
tls->ecdhe_sec) == 0) { // Validates the point
|
||||||
mg_error(c, "bad key");
|
mg_error(c, "bad key");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -20186,14 +20186,14 @@ static bool mg_tls_verify_cert_signature(const struct mg_tls_cert *cert,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mg_tls_verify_cert_cn(struct mg_der_tlv *subj, const char *host) {
|
static bool mg_tls_verify_cert_cn(struct mg_der_tlv *subj, const char *host) {
|
||||||
struct mg_der_tlv v;
|
struct mg_der_tlv v;
|
||||||
int matched = 0;
|
bool matched = false;
|
||||||
if (mg_der_find_oid(subj, (uint8_t *) "\x55\x04\x03", 3, &v) > 0) {
|
if (mg_der_find_oid(subj, (uint8_t *) "\x55\x04\x03", 3, &v) > 0) {
|
||||||
struct mg_str hn, cn;
|
struct mg_str hn, cn;
|
||||||
MG_VERBOSE(("using CN: %.*s <-> %s", v.len, v.value, host));
|
MG_VERBOSE(("using CN: %.*s <-> %s", v.len, v.value, host));
|
||||||
hn = mg_str(host), cn = mg_str_n((char *) v.value, v.len);
|
hn = mg_str(host), cn = mg_str_n((char *) v.value, v.len);
|
||||||
matched = (int) (countdots(hn) == countdots(cn) && mg_match(hn, cn, NULL));
|
matched = (countdots(hn) == countdots(cn) && mg_match(hn, cn, NULL));
|
||||||
}
|
}
|
||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
@@ -20316,8 +20316,8 @@ static int mg_tls_recv_cert(struct mg_connection *c, bool is_client) {
|
|||||||
san = mg_tls_verify_cert_san(cert, certsz, tls->hostname,
|
san = mg_tls_verify_cert_san(cert, certsz, tls->hostname,
|
||||||
is_addr ? &addr : NULL);
|
is_addr ? &addr : NULL);
|
||||||
if (san < 0 || // RFC 6125 6.4.4 allow legacy fallback to CN
|
if (san < 0 || // RFC 6125 6.4.4 allow legacy fallback to CN
|
||||||
(san == 0 && (is_addr || mg_tls_verify_cert_cn(
|
(san == 0 &&
|
||||||
&ci->subj, tls->hostname) <= 0))) {
|
(is_addr || !mg_tls_verify_cert_cn(&ci->subj, tls->hostname)))) {
|
||||||
mg_error(c, "failed to verify host");
|
mg_error(c, "failed to verify host");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
#ifndef MONGOOSE_H
|
#ifndef MONGOOSE_H
|
||||||
#define MONGOOSE_H
|
#define MONGOOSE_H
|
||||||
|
|
||||||
#define MG_VERSION "7.24"
|
#define MG_VERSION "7.23"
|
||||||
|
|
||||||
// IMPORTANT:
|
// IMPORTANT:
|
||||||
// Before implementing any functionality, pull this file and use it as a guide:
|
// Before implementing any functionality, pull this file and use it as a guide:
|
||||||
|
|||||||
+5
-5
@@ -3,22 +3,22 @@
|
|||||||
"bomFormat": "CycloneDX",
|
"bomFormat": "CycloneDX",
|
||||||
"specVersion": "1.6",
|
"specVersion": "1.6",
|
||||||
"serialNumber": "urn:uuid:d3f8b1e2-4a7c-4d9e-bf2a-1c3e5f7a9b0d",
|
"serialNumber": "urn:uuid:d3f8b1e2-4a7c-4d9e-bf2a-1c3e5f7a9b0d",
|
||||||
"version": 3,
|
"version": 2,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"timestamp": "2026-11-18T00:00:00Z",
|
"timestamp": "2026-10-13T00:00:00Z",
|
||||||
"component": {
|
"component": {
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"bom-ref": "mongoose",
|
"bom-ref": "mongoose",
|
||||||
"supplier": { "name": "Cesanta Software Limited", "url": ["https://cesanta.com"] },
|
"supplier": { "name": "Cesanta Software Limited", "url": ["https://cesanta.com"] },
|
||||||
"author": "Cesanta Software Limited",
|
"author": "Cesanta Software Limited",
|
||||||
"name": "mongoose",
|
"name": "mongoose",
|
||||||
"version": "7.24",
|
"version": "7.23",
|
||||||
"description": "Two-file C/C++ embedded networking library. HTTP, WebSocket, MQTT, TLS 1.3, OTA firmware updates, device dashboard. Runs on microcontrollers and desktop OS.",
|
"description": "Two-file C/C++ embedded networking library. HTTP, WebSocket, MQTT, TLS 1.3, OTA firmware updates, device dashboard. Runs on microcontrollers and desktop OS.",
|
||||||
"licenses": [
|
"licenses": [
|
||||||
{ "expression": "GPL-2.0-only" },
|
{ "expression": "GPL-2.0-only" },
|
||||||
{ "license": { "name": "Cesanta Commercial License", "url": "https://mongoose.ws/licensing/" } }
|
{ "license": { "name": "Cesanta Commercial License", "url": "https://mongoose.ws/licensing/" } }
|
||||||
],
|
],
|
||||||
"purl": "pkg:github/cesanta/mongoose@7.24",
|
"purl": "pkg:github/cesanta/mongoose@7.23",
|
||||||
"externalReferences": [
|
"externalReferences": [
|
||||||
{ "type": "website", "url": "https://mongoose.ws" },
|
{ "type": "website", "url": "https://mongoose.ws" },
|
||||||
{ "type": "vcs", "url": "https://github.com/cesanta/mongoose" },
|
{ "type": "vcs", "url": "https://github.com/cesanta/mongoose" },
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
{ "type": "distribution", "url": "https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.c" }
|
{ "type": "distribution", "url": "https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.c" }
|
||||||
],
|
],
|
||||||
"properties": [
|
"properties": [
|
||||||
{ "name": "cpe", "value": "cpe:2.3:a:cesanta:mongoose:7.24:*:*:*:*:*:*:*" }
|
{ "name": "cpe", "value": "cpe:2.3:a:cesanta:mongoose:7.23:*:*:*:*:*:*:*" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+11
-11
@@ -761,8 +761,8 @@ static bool mg_tls_server_send_hello(struct mg_connection *c) {
|
|||||||
|
|
||||||
// calculate P-256 keyshare and the shared secret
|
// calculate P-256 keyshare and the shared secret
|
||||||
pub[0] = 0x04; // uncompressed point 0x04 || X || Y
|
pub[0] = 0x04; // uncompressed point 0x04 || X || Y
|
||||||
if (!mg_p256_make_key(pub + 1, prv) ||
|
if (mg_p256_make_key(pub + 1, prv) == 0 ||
|
||||||
!mg_p256_shared_secret(tls->p256_peer, prv, tls->ecdhe_sec)) {
|
mg_p256_shared_secret(tls->p256_peer, prv, tls->ecdhe_sec) == 0) {
|
||||||
mg_bzero(prv, sizeof(prv));
|
mg_bzero(prv, sizeof(prv));
|
||||||
mg_error(c, "bad key");
|
mg_error(c, "bad key");
|
||||||
return false;
|
return false;
|
||||||
@@ -1177,7 +1177,7 @@ static bool mg_tls_send_cert_verify(struct mg_connection *c, bool is_client) {
|
|||||||
size_t sigsz, verifysz = 0;
|
size_t sigsz, verifysz = 0;
|
||||||
int adj1, adj2;
|
int adj1, adj2;
|
||||||
uint8_t sig[64] = {0};
|
uint8_t sig[64] = {0};
|
||||||
if (!mg_p256_sign(tls->ec_key, hash, sizeof(hash), sig)) {
|
if (mg_p256_sign(tls->ec_key, hash, sizeof(hash), sig) != 1) {
|
||||||
mg_error(c, "P-256 sign");
|
mg_error(c, "P-256 sign");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1309,7 +1309,7 @@ static bool mg_tls_client_send_hello(struct mg_connection *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calc+fill keyshare; X || Y, sent as an uncompressed point 0x04 || X || Y
|
// calc+fill keyshare; X || Y, sent as an uncompressed point 0x04 || X || Y
|
||||||
if (!mg_p256_make_key(msg_client_hello + 95, tls->p256_cli)) {
|
if (mg_p256_make_key(msg_client_hello + 95, tls->p256_cli) == 0) {
|
||||||
mg_error(c, "P-256 key");
|
mg_error(c, "P-256 key");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1399,8 +1399,8 @@ static int mg_tls_client_recv_hello(struct mg_connection *c) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (key_exchange_len != 65 || key_exchange[0] != 0x04 ||
|
if (key_exchange_len != 65 || key_exchange[0] != 0x04 ||
|
||||||
!mg_p256_shared_secret(key_exchange + 1, tls->p256_cli,
|
mg_p256_shared_secret(key_exchange + 1, tls->p256_cli,
|
||||||
tls->ecdhe_sec)) { // Validates the point
|
tls->ecdhe_sec) == 0) { // Validates the point
|
||||||
mg_error(c, "bad key");
|
mg_error(c, "bad key");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1781,14 +1781,14 @@ static bool mg_tls_verify_cert_signature(const struct mg_tls_cert *cert,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mg_tls_verify_cert_cn(struct mg_der_tlv *subj, const char *host) {
|
static bool mg_tls_verify_cert_cn(struct mg_der_tlv *subj, const char *host) {
|
||||||
struct mg_der_tlv v;
|
struct mg_der_tlv v;
|
||||||
int matched = 0;
|
bool matched = false;
|
||||||
if (mg_der_find_oid(subj, (uint8_t *) "\x55\x04\x03", 3, &v) > 0) {
|
if (mg_der_find_oid(subj, (uint8_t *) "\x55\x04\x03", 3, &v) > 0) {
|
||||||
struct mg_str hn, cn;
|
struct mg_str hn, cn;
|
||||||
MG_VERBOSE(("using CN: %.*s <-> %s", v.len, v.value, host));
|
MG_VERBOSE(("using CN: %.*s <-> %s", v.len, v.value, host));
|
||||||
hn = mg_str(host), cn = mg_str_n((char *) v.value, v.len);
|
hn = mg_str(host), cn = mg_str_n((char *) v.value, v.len);
|
||||||
matched = (int) (countdots(hn) == countdots(cn) && mg_match(hn, cn, NULL));
|
matched = (countdots(hn) == countdots(cn) && mg_match(hn, cn, NULL));
|
||||||
}
|
}
|
||||||
return matched;
|
return matched;
|
||||||
}
|
}
|
||||||
@@ -1911,8 +1911,8 @@ static int mg_tls_recv_cert(struct mg_connection *c, bool is_client) {
|
|||||||
san = mg_tls_verify_cert_san(cert, certsz, tls->hostname,
|
san = mg_tls_verify_cert_san(cert, certsz, tls->hostname,
|
||||||
is_addr ? &addr : NULL);
|
is_addr ? &addr : NULL);
|
||||||
if (san < 0 || // RFC 6125 6.4.4 allow legacy fallback to CN
|
if (san < 0 || // RFC 6125 6.4.4 allow legacy fallback to CN
|
||||||
(san == 0 && (is_addr || mg_tls_verify_cert_cn(
|
(san == 0 &&
|
||||||
&ci->subj, tls->hostname) <= 0))) {
|
(is_addr || !mg_tls_verify_cert_cn(&ci->subj, tls->hostname)))) {
|
||||||
mg_error(c, "failed to verify host");
|
mg_error(c, "failed to verify host");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
#define MG_VERSION "7.24"
|
#define MG_VERSION "7.23"
|
||||||
Reference in new issue
Block a user