POSA_LEAKSMS/firmware/common/jsonbody.h
유창욱 90f121e14c chore: import codebase with security hardening
SHT30 온습도 모니터링 시스템 전체 소스(서버 PHP, STM32 펌웨어, SQL, 테스트).
전체 코드리뷰에서 도출된 보안 하드닝 10건 반영:
- 요청 서명 HMAC-SHA256 전환(펌웨어 sig.c/서버 config.php/호스트 패리티 동시)
- 재전송 방어 + 기본 API_KEY fail-closed + 디바이스 문자열 정제(api/sensor_data.php)
- 오프라인 SMS 중복 발송 경합 제거(cron_heartbeat.php, 원자적 선점)
- CSV 수식 주입 방지(monthly_report.php), 감사로그 회전 락(retention_cleanup.php)
- 브루트포스 카운터 원자화(login.php), 예시 TOTP 비밀키 무효화, 마이그레이션 멱등화

_backup/(하드코딩 실 비밀값 포함)·config.local.php·런타임 상태는 .gitignore 제외.
2026-06-20 09:37:40 +09:00

26 lines
1.2 KiB
C

/* =============================================================================
* jsonbody.h - 서버로 보낼 요청 본문(JSON) 생성
*
* raw-body 서명을 쓰므로 본문은 "유효한 JSON"이기만 하면 되고, 서버가 받은
* 바이트 그대로 서명을 검증한다. 따라서 키 정렬/PHP json_encode 포맷 재현이
* 불필요하다. (단, 서명한 본문 바이트와 실제 전송 바이트는 100% 동일해야 한다.)
*
* RPi 대응:
* jb_sht30_event <- sht30_monitor.py post_reading() data
* ===========================================================================*/
#ifndef JSONBODY_H
#define JSONBODY_H
#include <stdint.h>
#include <stddef.h>
/* SHT30 보드 이벤트 본문. temperature_c/humidity_percent 는 소수 2자리로
* 직렬화된다. 반환값: 기록한 길이(NUL 제외), 버퍼 부족 시 -1. */
int jb_sht30_event(char *out, size_t cap,
const char *device_id, const char *device_location,
int sensor_id, const char *sensor_name,
const char *event_type, uint32_t timestamp,
double temperature_c, double humidity_percent,
const char *metric_status, const char *app_version);
#endif /* JSONBODY_H */