Replace octet_string_is_eq with a constant-time implementation

This function is used to check authentication tags in srtp_unprotect.
The current early-exit implementation might offer a timing sidechannel,
enabling attackers to brute-force a correct HMAC to a forged message.

Such attacks shouldn't be possible if replay protection is enabled, but
this is nonetheless good defense in depth.

The implementation is similar to CRYPTO_memcmp from OpenSSL/BoringSSL.
2 files changed