mirror of
git://f0xx.org/ac/ac-mobile-android
synced 2026-07-29 04:18:25 +03:00
initial
This commit is contained in:
30
ndk/obfuscate/obfuscate.h
Normal file
30
ndk/obfuscate/obfuscate.h
Normal 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 */
|
||||
Reference in New Issue
Block a user