mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-01-29 13:50:48 +03:00
new cspot/bell
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
#include "X509Bundle.h"
|
||||
|
||||
#include <mbedtls/md.h> // for mbedtls_md, mbedtls_md_get_size
|
||||
#include <mbedtls/pk.h> // for mbedtls_pk_can_do, mbedtls_pk_pa...
|
||||
#include <mbedtls/ssl.h> // for mbedtls_ssl_conf_ca_chain, mbedt...
|
||||
#include <mbedtls/x509.h> // for mbedtls_x509_buf, MBEDTLS_ERR_X5...
|
||||
#include <stdlib.h> // for free, calloc
|
||||
#include <string.h> // for memcmp, memcpy
|
||||
#include <stdexcept> // for runtime_error
|
||||
|
||||
#include "BellLogger.h" // for AbstractLogger, BELL_LOG
|
||||
|
||||
using namespace bell::X509Bundle;
|
||||
|
||||
static mbedtls_x509_crt s_dummy_crt;
|
||||
@@ -21,7 +31,8 @@ int bell::X509Bundle::crtCheckCertificate(mbedtls_x509_crt* child,
|
||||
|
||||
if ((ret = mbedtls_pk_parse_public_key(&parent.pk, pub_key_buf,
|
||||
pub_key_len)) != 0) {
|
||||
BELL_LOG(error, TAG, "PK parse failed with error %X", ret);
|
||||
BELL_LOG(error, TAG, "PK parse failed with error 0x%04x, key len = %d", ret,
|
||||
pub_key_len);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -110,6 +121,8 @@ int bell::X509Bundle::crtVerifyCallback(void* buf, mbedtls_x509_crt* crt,
|
||||
ret = crtCheckCertificate(
|
||||
child, s_crt_bundle.crts[middle] + CRT_HEADER_OFFSET + name_len,
|
||||
key_len);
|
||||
} else {
|
||||
BELL_LOG(error, TAG, "Certificate not found in bundle");
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
@@ -138,10 +151,13 @@ void bell::X509Bundle::init(const uint8_t* x509_bundle, size_t bundle_size) {
|
||||
throw std::runtime_error("Unable to allocate memory for bundle");
|
||||
}
|
||||
|
||||
bundleBytes.resize(bundle_size);
|
||||
memcpy(bundleBytes.data(), x509_bundle, bundle_size);
|
||||
|
||||
const uint8_t* cur_crt;
|
||||
/* This is the maximum region that is allowed to access */
|
||||
const uint8_t* bundle_end = x509_bundle + bundle_size;
|
||||
cur_crt = x509_bundle + BUNDLE_HEADER_OFFSET;
|
||||
const uint8_t* bundle_end = bundleBytes.data() + bundle_size;
|
||||
cur_crt = bundleBytes.data() + BUNDLE_HEADER_OFFSET;
|
||||
|
||||
for (int i = 0; i < num_certs; i++) {
|
||||
crts[i] = cur_crt;
|
||||
|
||||
Reference in New Issue
Block a user