mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-07 14:44:32 +02:00
ci(mbedtls/esp_crt_bundle): Format esp_crt_bundle.c using astyle
This commit is contained in:
@@ -65,7 +65,8 @@ typedef const uint8_t* cert_t;
|
|||||||
static bundle_t s_crt_bundle;
|
static bundle_t s_crt_bundle;
|
||||||
|
|
||||||
// Read a 16-bit value stored in little-endian format from the given address
|
// Read a 16-bit value stored in little-endian format from the given address
|
||||||
static uint16_t get16_le (const uint8_t* ptr) {
|
static uint16_t get16_le(const uint8_t* ptr)
|
||||||
|
{
|
||||||
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||||
return *((const uint16_t*)ptr);
|
return *((const uint16_t*)ptr);
|
||||||
#else
|
#else
|
||||||
@@ -73,31 +74,38 @@ static uint16_t get16_le (const uint8_t* ptr) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t esp_crt_get_name_len(const cert_t cert) {
|
static uint16_t esp_crt_get_name_len(const cert_t cert)
|
||||||
|
{
|
||||||
return get16_le(cert + CRT_NAME_LEN_OFFSET);
|
return get16_le(cert + CRT_NAME_LEN_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint8_t* esp_crt_get_name(const cert_t cert) {
|
static const uint8_t* esp_crt_get_name(const cert_t cert)
|
||||||
|
{
|
||||||
return cert + CRT_NAME_OFFSET;
|
return cert + CRT_NAME_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t esp_crt_get_key_len(const cert_t cert) {
|
static uint16_t esp_crt_get_key_len(const cert_t cert)
|
||||||
|
{
|
||||||
return get16_le(cert + CRT_KEY_LEN_OFFSET);
|
return get16_le(cert + CRT_KEY_LEN_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint8_t* esp_crt_get_key(const cert_t cert) {
|
static const uint8_t* esp_crt_get_key(const cert_t cert)
|
||||||
|
{
|
||||||
return esp_crt_get_name(cert) + esp_crt_get_name_len(cert);
|
return esp_crt_get_name(cert) + esp_crt_get_name_len(cert);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t esp_crt_get_len(const cert_t cert) {
|
static uint16_t esp_crt_get_len(const cert_t cert)
|
||||||
|
{
|
||||||
return CRT_HEADER_SIZE + esp_crt_get_name_len(cert) + esp_crt_get_key_len(cert);
|
return CRT_HEADER_SIZE + esp_crt_get_name_len(cert) + esp_crt_get_key_len(cert);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t esp_crt_get_cert_offset(const bundle_t bundle, const uint32_t index) {
|
static uint32_t esp_crt_get_cert_offset(const bundle_t bundle, const uint32_t index)
|
||||||
|
{
|
||||||
return ((const uint32_t*)bundle)[index];
|
return ((const uint32_t*)bundle)[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t esp_crt_get_certcount(const bundle_t bundle) {
|
static uint32_t esp_crt_get_certcount(const bundle_t bundle)
|
||||||
|
{
|
||||||
// Offset of 1st certificate == end of offset list == size of offset list == # of certs * sizeof(uint32_t)
|
// Offset of 1st certificate == end of offset list == size of offset list == # of certs * sizeof(uint32_t)
|
||||||
return esp_crt_get_cert_offset(bundle, 0) / sizeof(uint32_t);
|
return esp_crt_get_cert_offset(bundle, 0) / sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
@@ -109,7 +117,8 @@ static uint32_t esp_crt_get_certcount(const bundle_t bundle) {
|
|||||||
* @param index of the certificate; must be less than \c esp_crt_get_certcount(...) !
|
* @param index of the certificate; must be less than \c esp_crt_get_certcount(...) !
|
||||||
* @return pointer to the certificate
|
* @return pointer to the certificate
|
||||||
*/
|
*/
|
||||||
static cert_t esp_crt_get_cert(const bundle_t bundle, const uint32_t index) {
|
static cert_t esp_crt_get_cert(const bundle_t bundle, const uint32_t index)
|
||||||
|
{
|
||||||
return bundle + esp_crt_get_cert_offset(bundle, index);
|
return bundle + esp_crt_get_cert_offset(bundle, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,6 +225,7 @@ int esp_crt_verify_callback(void *buf, mbedtls_x509_crt* const crt, const int de
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (unlikely(s_crt_bundle == NULL)) {
|
if (unlikely(s_crt_bundle == NULL)) {
|
||||||
ESP_LOGE(TAG, "No certificates in bundle");
|
ESP_LOGE(TAG, "No certificates in bundle");
|
||||||
return MBEDTLS_ERR_X509_FATAL_ERROR;
|
return MBEDTLS_ERR_X509_FATAL_ERROR;
|
||||||
|
Reference in New Issue
Block a user