Go to the documentation of this file.
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
40 #if (POLY1305_SUPPORT == ENABLED)
62 context->
r[0] &= 0x0FFFFFFF;
63 context->
r[1] &= 0x0FFFFFFC;
64 context->
r[2] &= 0x0FFFFFFC;
65 context->
r[3] &= 0x0FFFFFFC;
110 if(context->
size == 16)
133 if(context->
size != 0)
137 b[0] = context->
a[0] & 0xFFFFFFFF;
138 b[1] = context->
a[1] & 0xFFFFFFFF;
139 b[2] = context->
a[2] & 0xFFFFFFFF;
140 b[3] = context->
a[3] & 0xFFFFFFFF;
146 context->
a[1] += context->
a[0] >> 32;
147 context->
a[2] += context->
a[1] >> 32;
148 context->
a[3] += context->
a[2] >> 32;
149 context->
a[4] += context->
a[3] >> 32;
153 mask = ((context->
a[4] & 0x04) >> 2) - 1;
156 context->
a[0] = (context->
a[0] & ~
mask) | (
b[0] &
mask);
157 context->
a[1] = (context->
a[1] & ~
mask) | (
b[1] &
mask);
158 context->
a[2] = (context->
a[2] & ~
mask) | (
b[2] &
mask);
159 context->
a[3] = (context->
a[3] & ~
mask) | (
b[3] &
mask);
162 context->
a[0] += context->
s[0];
163 context->
a[1] += context->
s[1];
164 context->
a[2] += context->
s[2];
165 context->
a[3] += context->
s[3];
168 context->
a[1] += context->
a[0] >> 32;
169 context->
a[2] += context->
a[1] >> 32;
170 context->
a[3] += context->
a[2] >> 32;
171 context->
a[4] += context->
a[3] >> 32;
174 b[0] = context->
a[0] & 0xFFFFFFFF;
175 b[1] = context->
a[1] & 0xFFFFFFFF;
176 b[2] = context->
a[2] & 0xFFFFFFFF;
177 b[3] = context->
a[3] & 0xFFFFFFFF;
243 context->
a[0] +=
a[0];
244 context->
a[1] +=
a[1];
245 context->
a[2] +=
a[2];
246 context->
a[3] +=
a[3];
247 context->
a[4] +=
a[4];
250 context->
a[1] += context->
a[0] >> 32;
251 context->
a[2] += context->
a[1] >> 32;
252 context->
a[3] += context->
a[2] >> 32;
253 context->
a[4] += context->
a[3] >> 32;
256 a[0] = context->
a[0] & 0xFFFFFFFF;
257 a[1] = context->
a[1] & 0xFFFFFFFF;
258 a[2] = context->
a[2] & 0xFFFFFFFF;
259 a[3] = context->
a[3] & 0xFFFFFFFF;
260 a[4] = context->
a[4] & 0xFFFFFFFF;
263 r[0] = context->
r[0];
264 r[1] = context->
r[1];
265 r[2] = context->
r[2];
266 r[3] = context->
r[3];
269 context->
a[0] = (uint64_t)
a[0] *
r[0];
270 context->
a[1] = (uint64_t)
a[0] *
r[1] + (uint64_t)
a[1] *
r[0];
271 context->
a[2] = (uint64_t)
a[0] *
r[2] + (uint64_t)
a[1] *
r[1] + (uint64_t)
a[2] *
r[0];
272 context->
a[3] = (uint64_t)
a[0] *
r[3] + (uint64_t)
a[1] *
r[2] + (uint64_t)
a[2] *
r[1] + (uint64_t)
a[3] *
r[0];
273 context->
a[4] = (uint64_t)
a[1] *
r[3] + (uint64_t)
a[2] *
r[2] + (uint64_t)
a[3] *
r[1] + (uint64_t)
a[4] *
r[0];
274 context->
a[5] = (uint64_t)
a[2] *
r[3] + (uint64_t)
a[3] *
r[2] + (uint64_t)
a[4] *
r[1];
275 context->
a[6] = (uint64_t)
a[3] *
r[3] + (uint64_t)
a[4] *
r[2];
276 context->
a[7] = (uint64_t)
a[4] *
r[3];
279 context->
a[1] += context->
a[0] >> 32;
280 context->
a[2] += context->
a[1] >> 32;
281 context->
a[3] += context->
a[2] >> 32;
282 context->
a[4] += context->
a[3] >> 32;
283 context->
a[5] += context->
a[4] >> 32;
284 context->
a[6] += context->
a[5] >> 32;
285 context->
a[7] += context->
a[6] >> 32;
288 a[0] = context->
a[4] & 0xFFFFFFFC;
289 a[1] = context->
a[5] & 0xFFFFFFFF;
290 a[2] = context->
a[6] & 0xFFFFFFFF;
291 a[3] = context->
a[7] & 0xFFFFFFFF;
294 context->
a[0] &= 0xFFFFFFFF;
295 context->
a[1] &= 0xFFFFFFFF;
296 context->
a[2] &= 0xFFFFFFFF;
297 context->
a[3] &= 0xFFFFFFFF;
298 context->
a[4] &= 0x00000003;
301 context->
a[0] +=
a[0];
302 context->
a[0] += (
a[0] >> 2) | (
a[1] << 30);
303 context->
a[1] +=
a[1];
304 context->
a[1] += (
a[1] >> 2) | (
a[2] << 30);
305 context->
a[2] +=
a[2];
306 context->
a[2] += (
a[2] >> 2) | (
a[3] << 30);
307 context->
a[3] +=
a[3];
308 context->
a[3] += (
a[3] >> 2);
311 context->
a[1] += context->
a[0] >> 32;
312 context->
a[2] += context->
a[1] >> 32;
313 context->
a[3] += context->
a[2] >> 32;
314 context->
a[4] += context->
a[3] >> 32;
317 a[0] = context->
a[4] & 0xFFFFFFFC;
320 context->
a[0] &= 0xFFFFFFFF;
321 context->
a[1] &= 0xFFFFFFFF;
322 context->
a[2] &= 0xFFFFFFFF;
323 context->
a[3] &= 0xFFFFFFFF;
324 context->
a[4] &= 0x00000003;
327 context->
a[0] +=
a[0];
328 context->
a[0] +=
a[0] >> 2;
331 context->
a[1] += context->
a[0] >> 32;
332 context->
a[2] += context->
a[1] >> 32;
333 context->
a[3] += context->
a[2] >> 32;
334 context->
a[4] += context->
a[3] >> 32;
337 context->
a[0] &= 0xFFFFFFFF;
338 context->
a[1] &= 0xFFFFFFFF;
339 context->
a[2] &= 0xFFFFFFFF;
340 context->
a[3] &= 0xFFFFFFFF;
341 context->
a[4] &= 0x00000003;
void poly1305Init(Poly1305Context *context, const uint8_t *key)
Initialize Poly1305 message-authentication code computation.
#define osMemcpy(dest, src, length)
Poly1305 message-authentication code.
General definitions for cryptographic algorithms.
void poly1305ProcessBlock(Poly1305Context *context)
Process message in 16-byte blocks.
void poly1305Final(Poly1305Context *context, uint8_t *tag)
Finalize Poly1305 message-authentication code computation.
void poly1305Update(Poly1305Context *context, const void *data, size_t length)
Update Poly1305 message-authentication code computation.