cybersecurity · beginner · ~15 min
Identify the timing-safe comparison strategy.
Identify which comparison strategy is safe to use on secrets like MACs and tokens.
Implement int is_timing_safe(const char *method) that returns 1 for the timing-safe strategy and 0 for the leaky one.
method: a NUL-terminated strategy name the grader passes — either "xor-accumulate" or "early-return-memcmp".Returns int: 1 for "xor-accumulate", 0 for "early-return-memcmp".
is_timing_safe("xor-accumulate") -> 1
is_timing_safe("early-return-memcmp") -> 0
A NUL-terminated strategy name method.
An int: 1 for "xor-accumulate", else 0.
Only "xor-accumulate" is timing-safe.
#include <string.h>
int is_timing_safe(const char *method) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.