// ── Orchestrator kripto yardımcıları — bağımsız TU (yalnız Windows/BCrypt) ─── // Rastgelelik (eşleştirme nonce'u) + hex kodlama (ayar deposu metin tabanlı, anahtar // binary). Kule ve panel-testi bunu paylaşır; ağır kule bağımlılıklarını çekmez. #include "orkestra_kule.hpp" #include #include namespace fiko { void orkestraRastgeleDoldur(uint8_t* p, size_t n) { if (BCryptGenRandom(nullptr, p, (ULONG)n, BCRYPT_USE_SYSTEM_PREFERRED_RNG) != 0) { // Son çare: BCrypt başarısızsa (imkânsıza yakın) QPC + tik karıştır (kripto // iddiası yok, yalnız nonce tahmin edilemez kalsın diye fallback). LARGE_INTEGER qpc; QueryPerformanceCounter(&qpc); uint64_t h = (uint64_t)qpc.QuadPart ^ GetTickCount64(); for (size_t i = 0; i < n; ++i) { h = h * 6364136223846793005ull + 1442695040888963407ull; p[i] = (uint8_t)(h >> 33); } } } std::string orkestraHexKodla(const std::string& binary) { static const char* hx = "0123456789abcdef"; std::string o; o.reserve(binary.size() * 2); for (unsigned char c : binary) { o.push_back(hx[c >> 4]); o.push_back(hx[c & 0xF]); } return o; } std::string orkestraHexCoz(const std::string& hex) { auto yari = [](char c) -> int { if (c >= '0' && c <= '9') return c - '0'; if (c >= 'a' && c <= 'f') return c - 'a' + 10; if (c >= 'A' && c <= 'F') return c - 'A' + 10; return -1; }; std::string o; o.reserve(hex.size() / 2); for (size_t i = 0; i + 1 < hex.size(); i += 2) { const int hi = yari(hex[i]), lo = yari(hex[i + 1]); if (hi < 0 || lo < 0) return {}; // bozuk hex → boş (yukle mevcut kayıtları korur) o.push_back((char)((hi << 4) | lo)); } return o; } } // namespace fiko