MCPcopy Create free account
hub / github.com/ElementsProject/lightning / nonconst_time_test

Function nonconst_time_test

bitcoin/test/run-secret_eq_consttime.c:52–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52static struct timerel nonconst_time_test(struct secret *s1,
53 struct secret *s2,
54 size_t off)
55{
56 struct timeabs start, end;
57 int result = 0;
58
59 memset(s1, 0, RUNS * sizeof(*s1));
60 memset(s2, 0, RUNS * sizeof(*s2));
61
62 for (size_t i = 0; i < RUNS; i++)
63 s2[i].data[off] = i;
64
65 start = time_now();
66 for (size_t i = 0; i < RUNS; i++)
67 result += secret_eq_nonconst(&s1[i], &s2[i]);
68 end = time_now();
69
70 if (result != RUNS / 256)
71 errx(1, "Expected %u successes at offset %zu, not %u!",
72 RUNS / 256, off, result);
73
74 return time_between(end, start);
75}
76
77static struct secret *s1, *s2;
78

Callers

nothing calls this directly

Calls 4

time_nowFunction · 0.85
secret_eq_nonconstFunction · 0.85
errxFunction · 0.85
time_betweenFunction · 0.85

Tested by

no test coverage detected