Fix NX, add constant time compare
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-riscv64:latest, riscv64-linux-gnu, riscv64, asrock) (push) Successful in 54s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-x86:latest, i386-linux-gnu, 386, asrock) (push) Successful in 54s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-arm64:latest, aarch64-linux-gnu, arm64, asrock) (push) Successful in 55s
Build and Deploy on Tag / 🔨 Build win32 and update the tap 🍺 (push) Successful in 1m11s
Build and Deploy on Tag / 🔨 Build for PowerPC (push) Successful in 2m10s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-x64:latest, x86_64-linux-gnu, amd64, msi-walmart) (push) Successful in 2m15s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-arm:latest, arm-linux-gnueabihf, arm7, msi-walmart) (push) Successful in 2m19s

This commit is contained in:
2026-10-25 17:48:20 -05:00
parent fae86d2eb5
commit d99001d6eb
7 changed files with 16 additions and 89 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
# Changelog # Changelog
## 0.0.10 ## 0.0.10
Fix NX, add constant time compare, add TF_Span Fix NX, add constant time compare
## 0.0.9 ## 0.0.9
Make html parser use case insensitive unordered_map for attributes Make html parser use case insensitive unordered_map for attributes
-59
View File
@@ -40,66 +40,7 @@
namespace Tesses::Framework { namespace Tesses::Framework {
template <typename T>
class TF_Span {
public:
using value_type = T;
using pointer = T*;
using const_pointer = const T*;
using reference = T&;
using const_reference = const T&;
using size_type = std::size_t;
constexpr TF_Span(pointer data, size_type size) : data_(data), size_(size) {}
template <std::size_t N>
constexpr TF_Span(T (&arr)[N]) : data_(arr), size_(N) {}
template <typename Container>
constexpr TF_Span(const Container& container) : data_(container.data()), size_(container.size()) {
static_assert(std::is_same<typename Container::value_type, T>::value,"Container value_type must match Span's type");
}
reference operator[](size_type index) {
return data_[index];
}
const_reference operator[](size_type index) const {
return data_[index];
}
const_reference at(size_type index) const {
if (index >= size_) {
throw std::out_of_range("Index out of range");
}
return data_[index];
}
// Data and size
pointer data() noexcept { return data_; }
const_pointer data() const noexcept { return data_; }
size_type size() const noexcept { return size_; }
bool empty() const noexcept { return size_ == 0; }
// Iterators
pointer begin() noexcept { return data_; }
pointer end() noexcept { return data_ + size_; }
const_pointer begin() const noexcept { return data_; }
const_pointer end() const noexcept { return data_ + size_; }
TF_Span subspan(size_type offset, size_type count = static_cast<size_type>(-1)) const {
if (offset > size_) {
throw std::out_of_range("Offset out of range");
}
count = (count == static_cast<size_type>(-1)) ? (size_ - offset) : count;
if (count > size_ - offset) {
throw std::out_of_range("Count exceeds remaining elements");
}
return TF_Span(data_ + offset, count);
}
private:
pointer data_;
size_type size_;
};
class TF_Timer_Handle; class TF_Timer_Handle;
// Used for internal purposes, don't use unless you want to run timer events on // Used for internal purposes, don't use unless you want to run timer events on
// another thread // another thread
+1 -1
View File
@@ -317,7 +317,7 @@ typedef enum {
bool PBKDF2(std::vector<uint8_t> &output, std::string pass, bool PBKDF2(std::vector<uint8_t> &output, std::string pass,
std::vector<uint8_t> &salt, long itterations, ShaVersion version); std::vector<uint8_t> &salt, long itterations, ShaVersion version);
bool ConstantEquals(const TF_Span<uint8_t> left, const TF_Span<uint8_t> right); bool ConstantEquals(const std::vector<uint8_t>& left, const std::vector<uint8_t>& right);
/** /**
* @brief Get secure random bytes * @brief Get secure random bytes
@@ -80,15 +80,7 @@ class NetworkStream : public Stream {
size_t ReadFrom(uint8_t *buff, size_t sz, std::string &ip, uint16_t &port); size_t ReadFrom(uint8_t *buff, size_t sz, std::string &ip, uint16_t &port);
size_t WriteTo(const uint8_t *buff, size_t sz, std::string ip, size_t WriteTo(const uint8_t *buff, size_t sz, std::string ip,
uint16_t port); uint16_t port);
size_t ReadFrom(TF_Span<uint8_t> buff, std::string &ip, uint16_t &port)
{
return ReadFrom(buff.data(),buff.size(),ip, port);
}
size_t WriteTo(const TF_Span<uint8_t> buff, std::string ip,
uint16_t port)
{
return WriteTo(buff.data(),buff.size(),ip, port);
}
static std::vector<std::pair<std::string, std::string>> static std::vector<std::pair<std::string, std::string>>
GetIPs(bool ipV6 = false); GetIPs(bool ipV6 = false);
@@ -35,22 +35,6 @@ class Stream {
virtual size_t Write(const uint8_t *buff, size_t sz); virtual size_t Write(const uint8_t *buff, size_t sz);
size_t ReadBlock(uint8_t *buff, size_t sz); size_t ReadBlock(uint8_t *buff, size_t sz);
void WriteBlock(const uint8_t *buff, size_t sz); void WriteBlock(const uint8_t *buff, size_t sz);
size_t Read(TF_Span<uint8_t> buff) {
return Read(buff.data(), buff.size());
}
size_t Write(const TF_Span<uint8_t> buff)
{
return Write(buff.data(), buff.size());
}
size_t ReadBlock(TF_Span<uint8_t> buff)
{
return ReadBlock(buff.data(), buff.size());
}
void WriteBlock(const TF_Span<uint8_t> buff)
{
WriteBlock(buff.data(),buff.size());
}
virtual bool CanRead(); virtual bool CanRead();
virtual bool CanWrite(); virtual bool CanWrite();
+1 -1
View File
@@ -377,7 +377,7 @@ bool RandomBytes(std::vector<uint8_t> &output, std::string personal_str) {
#endif #endif
return false; return false;
} }
bool ConstantEquals(const TF_Span<uint8_t> left, const TF_Span<uint8_t> right) bool ConstantEquals(const std::vector<uint8_t>& left, const std::vector<uint8_t>& right)
{ {
if (left.size() != right.size()) return false; if (left.size() != right.size()) return false;
if (left.empty()) return true; if (left.empty()) return true;
+12 -2
View File
@@ -282,13 +282,23 @@ FIFOCreationResult LocalFilesystem::CreateFIFO(VFSPath path, uint32_t mod) {
void LocalFilesystem::Lock(VFSPath path) { void LocalFilesystem::Lock(VFSPath path) {
auto p2 = VFSPathToSystem(path); auto p2 = VFSPathToSystem(path);
const char *fopenPath = p2.c_str(); const char *fopenPath = p2.c_str();
while (true) { for (int i = 0; i < 10; i++) {
FILE *fp = fopen(fopenPath, "wx"); FILE *fp = fopen(fopenPath, "wx");
if (fp) { if (fp) {
fclose(fp); fclose(fp);
break; return;
} }
if (errno != EEXIST) {
std::string error_msg("Failed to acquire lock on ");
error_msg += p2;
error_msg += ": ";
error_msg += strerror(errno);
throw std::runtime_error(error_msg);
}
TF_Sleep(100);
} }
throw std::runtime_error("Lock acquisition timed out for " + p2);
} }
void LocalFilesystem::Unlock(VFSPath path) { void LocalFilesystem::Unlock(VFSPath path) {
std::error_code error; std::error_code error;