Fix NX, add constant time compare, add TF_Span
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 1m44s
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 2m11s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-x86:latest, i386-linux-gnu, 386, asrock) (push) Successful in 2m33s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-riscv64:latest, riscv64-linux-gnu, riscv64, asrock) (push) Successful in 2m34s
Build and Deploy on Tag / 🔨 Build for everything else (git.tesses.org/tesses50/linux-arm64:latest, aarch64-linux-gnu, arm64, asrock) (push) Successful in 2m38s
Build and Deploy on Tag / 🔨 Build for PowerPC (push) Successful in 2m57s
Build and Deploy on Tag / 🔨 Build win32 and update the tap 🍺 (push) Successful in 3m13s

This commit is contained in:
2026-10-25 16:57:42 -05:00
parent b964ea04df
commit fae86d2eb5
10 changed files with 213 additions and 46 deletions
+62
View File
@@ -36,8 +36,70 @@
#include <string>
#include <vector>
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;
// Used for internal purposes, don't use unless you want to run timer events on
// another thread
@@ -316,6 +316,9 @@ typedef enum {
*/
bool PBKDF2(std::vector<uint8_t> &output, std::string pass,
std::vector<uint8_t> &salt, long itterations, ShaVersion version);
bool ConstantEquals(const TF_Span<uint8_t> left, const TF_Span<uint8_t> right);
/**
* @brief Get secure random bytes
*
@@ -80,6 +80,15 @@ class NetworkStream : public Stream {
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,
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>>
GetIPs(bool ipV6 = false);
@@ -35,6 +35,23 @@ class Stream {
virtual size_t Write(const uint8_t *buff, size_t sz);
size_t ReadBlock(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 CanWrite();
virtual bool CanSeek();