inline int anonymize_mac(uint8_t mac[ETH_ALEN], uint8_t digest[ETH_ALEN]) { unsigned char mac_digest[ANONYMIZATION_DIGEST_LENGTH]; anonymization_process(mac, ETH_ALEN, mac_digest); memcpy(digest, mac_digest, ETH_ALEN); memcpy(digest, mac, ETH_ALEN / 2); return 0; }
inline int anonymize_ip(uint32_t address, uint64_t* digest) { unsigned char address_digest[ANONYMIZATION_DIGEST_LENGTH]; anonymization_process((unsigned char*)&address, sizeof(address), address_digest); *digest = *(uint64_t*)address_digest; return 0; }
static int init_hex_seed_digest() { unsigned char seed_digest[SHA_DIGEST_LENGTH]; anonymization_process(seed, ANONYMIZATION_SEED_LEN, seed_digest); const char* hex_digest = buffer_to_hex(seed_digest, SHA_DIGEST_LENGTH); if (!hex_digest) { return -1; } memcpy(seed_hex_digest, hex_digest, sizeof(seed_hex_digest)); seed_hex_digest[sizeof(seed_hex_digest) - 1] = '\0'; return 0; }
static int init_hex_seed_digest() { unsigned char seed_digest[SHA_DIGEST_LENGTH]; if (anonymization_process(seed, ANONYMIZATION_SEED_LEN, seed_digest)) { return -1; } const char* hex_digest = buffer_to_hex(seed_digest, SHA_DIGEST_LENGTH); if (!hex_digest) { return -1; } int idx; for (idx = 0; idx < SHA_DIGEST_LENGTH; ++idx) { if (sprintf(seed_hex_digest + 2 * idx, "%02x", seed_digest[idx]) < 2) { #ifndef NDEBUG perror("Error writing update"); #endif return -1; } } seed_hex_digest[SHA_DIGEST_LENGTH * 2] = '\0'; return 0; }
inline int anonymize_domain(const char* domain, unsigned char* digest) { return anonymization_process((unsigned char*)domain, strlen(domain), digest); }