s8t authenticate(message_v3_t* message, u8t* output, u16t output_len) { #if ENABLE_AUTH u8t hmac[16]; hmac_md5_96(output, output_len, hmac); memcpy(message->msgAuthenticationParameters.ptr, hmac, 12); #endif return 0; }
/* * Checks HMAC-MD5-96. */ static s8t isBadHMAC(u8t* input, u16t input_len, message_v3_t* request) { u8t authParam[12]; memcpy(authParam, request->msgAuthenticationParameters.ptr, 12); memset(request->msgAuthenticationParameters.ptr, 0, 12); u8t hmac[16]; hmac_md5_96(input, input_len, hmac); if (memcmp(authParam, hmac, 12)) { snmp_log("authentication failed\n"); return ERR_USM; } return 0; }
/* * Checks HMAC-MD5-96. */ static s8t isBadHMAC(u8t* input, u16t input_len, message_v3_t* request) { u8t authParam[12]; memcpy(authParam, request->msgAuthenticationParameters.ptr, 12); memset(request->msgAuthenticationParameters.ptr, 0, 12); u8t hmac[16]; hmac_md5_96(input, input_len, hmac); if (memcmp(authParam, hmac, 12)) { #if PDEBUG printf("USM Modul:isBadHMAC: Authentication Failed!\n"); #endif #ifndef DISABLE_HMAC snmp_log("authentication failed\n"); return ERR_USM; #endif #ifdef DISABLE_HMAC printf("Warning Authentication failed but HMAC Check is disabled\n"); return 0; #endif } return 0; }