MCPcopy Create free account
hub / github.com/F-Stack/f-stack / SipHash24_TestVectors

Function SipHash24_TestVectors

freebsd/crypto/siphash/siphash_test.c:109–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107#define MAXLEN 64
108
109int
110SipHash24_TestVectors(void)
111{
112 int i, fail = 0;
113 uint8_t in[MAXLEN], out[8], k[16];
114 SIPHASH_CTX ctx;
115
116 /* Initialize key. */
117 for (i = 0; i < 16; ++i)
118 k[i] = i;
119
120 /* Step through differnet length. */
121 for (i = 0; i < MAXLEN; ++i) {
122 in[i] = i;
123
124 SipHash24_Init(&ctx);
125 SipHash_SetKey(&ctx, k);
126 SipHash_Update(&ctx, in, i);
127 SipHash_Final(out, &ctx);
128
129 if (memcmp(out, vectors[i], 8))
130#if 0
131 printf("%i: test vector failed\n", i);
132 else
133 printf("%i: test vector correct\n", i);
134#else
135 fail++;
136#endif
137 }
138
139 return ((fail == 0));
140}

Callers

nothing calls this directly

Calls 4

SipHash_SetKeyFunction · 0.85
SipHash_UpdateFunction · 0.85
SipHash_FinalFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected