1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 04:18:09 +03:00

docs, obfuscation

This commit is contained in:
Anton Afanasyeu
2026-06-19 22:41:27 +02:00
parent 55cdcb49bf
commit b9f94fe005
57 changed files with 3229 additions and 105 deletions

30
ndk/obfuscate/obfuscate.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef OBFUSCATE_H
#define OBFUSCATE_H
#include <stdint.h>
/* Payload uses lower 40 bits; upper 24 bits hold verification tag. */
#define OBF_PAYLOAD_BITS 40u
#define OBF_PAYLOAD_MASK ((1ULL << OBF_PAYLOAD_BITS) - 1ULL)
/* Return codes */
#define OBF_OK 0
#define OBF_ERR_NULL -1 /* out pointer is NULL */
#define OBF_ERR_RANGE -2 /* val exceeds encodable payload width */
#define OBF_ERR_VERIFY -3 /* tag mismatch (wrong seed or corrupted data) */
/*
* Encode uint64_t payload (e.g. flag bits) using seed-derived keystream.
* seed is typically unix time in whole seconds shared by encoder and decoder.
*
* On success writes single uint64_t to *out and returns OBF_OK.
*/
int32_t encode(uint64_t val, uint64_t seed, uint64_t *out);
/*
* Decode and verify. seed must match the value used at encode time.
* On success writes recovered payload to *out and returns OBF_OK.
*/
int32_t decode(uint64_t encoded_val, uint64_t seed, uint64_t *out);
#endif /* OBFUSCATE_H */