/* * SHEIKHA SILICON & SENSOR HEADER SDK — V94.0 (ISO C11 / Bare-Metal / Linux Kernel) * Entity: Salman Alrajeh Trading Est. (CR: 2051263653) * Covenant: BOUND_BY_QURAN_SUNNAH_LA_DARAR_HONEST_MIZAN */ #ifndef SHEIKHA_SEAL_V94_H #define SHEIKHA_SEAL_V94_H #include #include #define SHK_BRAND_MAGIC_U32 0x53484B5EU /* "SHK^" */ #define SHK_CR_NUMBER_U64 2051263653ULL #define SHK_SDK_VERSION_MAJOR 94U #define SHK_CCSDS_APID_ORBIT 0x0394U /* 11-bit CCSDS Satellite APID */ typedef struct __attribute__((packed)) { uint32_t magic; /* Must equal SHK_BRAND_MAGIC_U32 */ uint16_t sdk_version; /* 94 */ uint16_t ccsds_apid; /* Orbital / Ground APID */ uint64_t cr_identity; /* 2051263653 */ uint64_t timestamp_utc_ms; /* Monotonic / Atomic UTC timestamp */ uint32_t sensor_id; /* Factory calibrated probe ID */ int32_t metric_milli; /* Fixed-point measurement (x1000, zero float drift) */ uint8_t safety_lock; /* 1 = Simulation/Safe Read-Only, 0 = Unlocked */ uint32_t fnv1a_seal; /* Deterministic integrity hash */ } shk_sensor_frame_t; static inline uint32_t shk_fnv1a_hash(const uint8_t *buf, uint32_t len) { uint32_t h = 2166136261U; for (uint32_t i = 0; i < len; ++i) { h ^= (uint32_t)buf[i]; h *= 16777619U; } return h; } static inline void shk_seal_sensor_frame(shk_sensor_frame_t *f, uint32_t sensor_id, int32_t val_milli, uint64_t ts_ms) { f->magic = SHK_BRAND_MAGIC_U32; f->sdk_version = (uint16_t)SHK_SDK_VERSION_MAJOR; f->ccsds_apid = (uint16_t)SHK_CCSDS_APID_ORBIT; f->cr_identity = SHK_CR_NUMBER_U64; f->timestamp_utc_ms = ts_ms; f->sensor_id = sensor_id; f->metric_milli = val_milli; f->safety_lock = 1U; /* Fail-Closed by default (La Darar) */ f->fnv1a_seal = 0U; f->fnv1a_seal = shk_fnv1a_hash((const uint8_t *)f, (uint32_t)(sizeof(shk_sensor_frame_t) - sizeof(uint32_t))); } static inline bool shk_verify_sensor_frame(const shk_sensor_frame_t *f) { if (!f || f->magic != SHK_BRAND_MAGIC_U32 || f->cr_identity != SHK_CR_NUMBER_U64) return false; uint32_t expected = shk_fnv1a_hash((const uint8_t *)f, (uint32_t)(sizeof(shk_sensor_frame_t) - sizeof(uint32_t))); return (f->fnv1a_seal == expected); } static inline bool shk_allow_physical_actuation(bool twin_verified, bool supervisor_dual_key, bool hazard_detected) { return (twin_verified && supervisor_dual_key && !hazard_detected); } #endif /* SHEIKHA_SEAL_V94_H */