Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove crc, use one from espressif which is sometimes in rom #10

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ idf_component_register(SRC_DIRS "src"
PRIV_REQUIRES mbedtls cbor
INCLUDE_DIRS "src")

target_compile_features(${COMPONENT_LIB} PRIVATE cxx_std_17)
target_compile_features(${COMPONENT_LIB} PRIVATE cxx_std_20)
target_compile_options(${COMPONENT_LIB} PRIVATE -Ofast)
66 changes: 0 additions & 66 deletions src/crc32.c

This file was deleted.

28 changes: 0 additions & 28 deletions src/crc32.h

This file was deleted.

11 changes: 3 additions & 8 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@

#include "utils.hpp"

extern "C" {

#include "crc32.h"

}

#include <array>
#include <vector>
#include <algorithm>
#include <cctype>
#include <mbedtls/sha256.h>
#include <esp_crc.h>


using namespace std;
Expand All @@ -36,14 +31,14 @@ void sha256(const ByteVector &buf, std::array<uint8_t, SHA256_LEN> &digest) {
}

ByteVector crc32_bytes(const ByteVector &buf) {
uint32_t checksum = ur_crc32n(buf.data(), buf.size());
uint32_t checksum = __builtin_bswap32(crc32_int(buf));
auto *cbegin = (uint8_t*)&checksum;
auto *cend = cbegin + sizeof(uint32_t);
return {cbegin, cend};
}

uint32_t crc32_int(const ByteVector &buf) {
return ur_crc32(buf.data(), buf.size());
return esp_crc32_le(0, buf.data(), buf.size());
}

ByteVector string_to_bytes(const string& s) {
Expand Down
Loading