1#![allow(unused_parens)]
16#![allow(non_camel_case_types)]
17
18pub type fiat_poly1305_u1 = u8;
20pub type fiat_poly1305_i1 = i8;
22pub type fiat_poly1305_u2 = u8;
24pub type fiat_poly1305_i2 = i8;
26
27#[derive(Clone, Copy)]
30pub struct fiat_poly1305_loose_field_element(pub [u32; 5]);
31
32impl core::ops::Index<usize> for fiat_poly1305_loose_field_element {
33 type Output = u32;
34 #[inline]
35 fn index(&self, index: usize) -> &Self::Output {
36 &self.0[index]
37 }
38}
39
40impl core::ops::IndexMut<usize> for fiat_poly1305_loose_field_element {
41 #[inline]
42 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
43 &mut self.0[index]
44 }
45}
46
47#[derive(Clone, Copy)]
50pub struct fiat_poly1305_tight_field_element(pub [u32; 5]);
51
52impl core::ops::Index<usize> for fiat_poly1305_tight_field_element {
53 type Output = u32;
54 #[inline]
55 fn index(&self, index: usize) -> &Self::Output {
56 &self.0[index]
57 }
58}
59
60impl core::ops::IndexMut<usize> for fiat_poly1305_tight_field_element {
61 #[inline]
62 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
63 &mut self.0[index]
64 }
65}
66
67
68#[inline]
82pub fn fiat_poly1305_addcarryx_u26(out1: &mut u32, out2: &mut fiat_poly1305_u1, arg1: fiat_poly1305_u1, arg2: u32, arg3: u32) {
83 let x1: u32 = (((arg1 as u32) + arg2) + arg3);
84 let x2: u32 = (x1 & 0x3ffffff);
85 let x3: fiat_poly1305_u1 = ((x1 >> 26) as fiat_poly1305_u1);
86 *out1 = x2;
87 *out2 = x3;
88}
89
90#[inline]
104pub fn fiat_poly1305_subborrowx_u26(out1: &mut u32, out2: &mut fiat_poly1305_u1, arg1: fiat_poly1305_u1, arg2: u32, arg3: u32) {
105 let x1: i32 = ((((((arg2 as i64) - (arg1 as i64)) as i32) as i64) - (arg3 as i64)) as i32);
106 let x2: fiat_poly1305_i1 = ((x1 >> 26) as fiat_poly1305_i1);
107 let x3: u32 = (((x1 as i64) & (0x3ffffff as i64)) as u32);
108 *out1 = x3;
109 *out2 = (((0x0 as fiat_poly1305_i2) - (x2 as fiat_poly1305_i2)) as fiat_poly1305_u1);
110}
111
112#[inline]
124pub fn fiat_poly1305_cmovznz_u32(out1: &mut u32, arg1: fiat_poly1305_u1, arg2: u32, arg3: u32) {
125 let x1: fiat_poly1305_u1 = (!(!arg1));
126 let x2: u32 = ((((((0x0 as fiat_poly1305_i2) - (x1 as fiat_poly1305_i2)) as fiat_poly1305_i1) as i64) & (0xffffffff as i64)) as u32);
127 let x3: u32 = ((x2 & arg3) | ((!x2) & arg2));
128 *out1 = x3;
129}
130
131#[inline]
137pub fn fiat_poly1305_carry_mul(out1: &mut fiat_poly1305_tight_field_element, arg1: &fiat_poly1305_loose_field_element, arg2: &fiat_poly1305_loose_field_element) {
138 let x1: u64 = (((arg1[4]) as u64) * (((arg2[4]) * 0x5) as u64));
139 let x2: u64 = (((arg1[4]) as u64) * (((arg2[3]) * 0x5) as u64));
140 let x3: u64 = (((arg1[4]) as u64) * (((arg2[2]) * 0x5) as u64));
141 let x4: u64 = (((arg1[4]) as u64) * (((arg2[1]) * 0x5) as u64));
142 let x5: u64 = (((arg1[3]) as u64) * (((arg2[4]) * 0x5) as u64));
143 let x6: u64 = (((arg1[3]) as u64) * (((arg2[3]) * 0x5) as u64));
144 let x7: u64 = (((arg1[3]) as u64) * (((arg2[2]) * 0x5) as u64));
145 let x8: u64 = (((arg1[2]) as u64) * (((arg2[4]) * 0x5) as u64));
146 let x9: u64 = (((arg1[2]) as u64) * (((arg2[3]) * 0x5) as u64));
147 let x10: u64 = (((arg1[1]) as u64) * (((arg2[4]) * 0x5) as u64));
148 let x11: u64 = (((arg1[4]) as u64) * ((arg2[0]) as u64));
149 let x12: u64 = (((arg1[3]) as u64) * ((arg2[1]) as u64));
150 let x13: u64 = (((arg1[3]) as u64) * ((arg2[0]) as u64));
151 let x14: u64 = (((arg1[2]) as u64) * ((arg2[2]) as u64));
152 let x15: u64 = (((arg1[2]) as u64) * ((arg2[1]) as u64));
153 let x16: u64 = (((arg1[2]) as u64) * ((arg2[0]) as u64));
154 let x17: u64 = (((arg1[1]) as u64) * ((arg2[3]) as u64));
155 let x18: u64 = (((arg1[1]) as u64) * ((arg2[2]) as u64));
156 let x19: u64 = (((arg1[1]) as u64) * ((arg2[1]) as u64));
157 let x20: u64 = (((arg1[1]) as u64) * ((arg2[0]) as u64));
158 let x21: u64 = (((arg1[0]) as u64) * ((arg2[4]) as u64));
159 let x22: u64 = (((arg1[0]) as u64) * ((arg2[3]) as u64));
160 let x23: u64 = (((arg1[0]) as u64) * ((arg2[2]) as u64));
161 let x24: u64 = (((arg1[0]) as u64) * ((arg2[1]) as u64));
162 let x25: u64 = (((arg1[0]) as u64) * ((arg2[0]) as u64));
163 let x26: u64 = (x25 + (x10 + (x9 + (x7 + x4))));
164 let x27: u64 = (x26 >> 26);
165 let x28: u32 = ((x26 & (0x3ffffff as u64)) as u32);
166 let x29: u64 = (x21 + (x17 + (x14 + (x12 + x11))));
167 let x30: u64 = (x22 + (x18 + (x15 + (x13 + x1))));
168 let x31: u64 = (x23 + (x19 + (x16 + (x5 + x2))));
169 let x32: u64 = (x24 + (x20 + (x8 + (x6 + x3))));
170 let x33: u64 = (x27 + x32);
171 let x34: u64 = (x33 >> 26);
172 let x35: u32 = ((x33 & (0x3ffffff as u64)) as u32);
173 let x36: u64 = (x34 + x31);
174 let x37: u64 = (x36 >> 26);
175 let x38: u32 = ((x36 & (0x3ffffff as u64)) as u32);
176 let x39: u64 = (x37 + x30);
177 let x40: u64 = (x39 >> 26);
178 let x41: u32 = ((x39 & (0x3ffffff as u64)) as u32);
179 let x42: u64 = (x40 + x29);
180 let x43: u32 = ((x42 >> 26) as u32);
181 let x44: u32 = ((x42 & (0x3ffffff as u64)) as u32);
182 let x45: u64 = ((x43 as u64) * (0x5 as u64));
183 let x46: u64 = ((x28 as u64) + x45);
184 let x47: u32 = ((x46 >> 26) as u32);
185 let x48: u32 = ((x46 & (0x3ffffff as u64)) as u32);
186 let x49: u32 = (x47 + x35);
187 let x50: fiat_poly1305_u1 = ((x49 >> 26) as fiat_poly1305_u1);
188 let x51: u32 = (x49 & 0x3ffffff);
189 let x52: u32 = ((x50 as u32) + x38);
190 out1[0] = x48;
191 out1[1] = x51;
192 out1[2] = x52;
193 out1[3] = x41;
194 out1[4] = x44;
195}
196
197#[inline]
203pub fn fiat_poly1305_carry_square(out1: &mut fiat_poly1305_tight_field_element, arg1: &fiat_poly1305_loose_field_element) {
204 let x1: u32 = ((arg1[4]) * 0x5);
205 let x2: u32 = (x1 * 0x2);
206 let x3: u32 = ((arg1[4]) * 0x2);
207 let x4: u32 = ((arg1[3]) * 0x5);
208 let x5: u32 = (x4 * 0x2);
209 let x6: u32 = ((arg1[3]) * 0x2);
210 let x7: u32 = ((arg1[2]) * 0x2);
211 let x8: u32 = ((arg1[1]) * 0x2);
212 let x9: u64 = (((arg1[4]) as u64) * (x1 as u64));
213 let x10: u64 = (((arg1[3]) as u64) * (x2 as u64));
214 let x11: u64 = (((arg1[3]) as u64) * (x4 as u64));
215 let x12: u64 = (((arg1[2]) as u64) * (x2 as u64));
216 let x13: u64 = (((arg1[2]) as u64) * (x5 as u64));
217 let x14: u64 = (((arg1[2]) as u64) * ((arg1[2]) as u64));
218 let x15: u64 = (((arg1[1]) as u64) * (x2 as u64));
219 let x16: u64 = (((arg1[1]) as u64) * (x6 as u64));
220 let x17: u64 = (((arg1[1]) as u64) * (x7 as u64));
221 let x18: u64 = (((arg1[1]) as u64) * ((arg1[1]) as u64));
222 let x19: u64 = (((arg1[0]) as u64) * (x3 as u64));
223 let x20: u64 = (((arg1[0]) as u64) * (x6 as u64));
224 let x21: u64 = (((arg1[0]) as u64) * (x7 as u64));
225 let x22: u64 = (((arg1[0]) as u64) * (x8 as u64));
226 let x23: u64 = (((arg1[0]) as u64) * ((arg1[0]) as u64));
227 let x24: u64 = (x23 + (x15 + x13));
228 let x25: u64 = (x24 >> 26);
229 let x26: u32 = ((x24 & (0x3ffffff as u64)) as u32);
230 let x27: u64 = (x19 + (x16 + x14));
231 let x28: u64 = (x20 + (x17 + x9));
232 let x29: u64 = (x21 + (x18 + x10));
233 let x30: u64 = (x22 + (x12 + x11));
234 let x31: u64 = (x25 + x30);
235 let x32: u64 = (x31 >> 26);
236 let x33: u32 = ((x31 & (0x3ffffff as u64)) as u32);
237 let x34: u64 = (x32 + x29);
238 let x35: u64 = (x34 >> 26);
239 let x36: u32 = ((x34 & (0x3ffffff as u64)) as u32);
240 let x37: u64 = (x35 + x28);
241 let x38: u64 = (x37 >> 26);
242 let x39: u32 = ((x37 & (0x3ffffff as u64)) as u32);
243 let x40: u64 = (x38 + x27);
244 let x41: u32 = ((x40 >> 26) as u32);
245 let x42: u32 = ((x40 & (0x3ffffff as u64)) as u32);
246 let x43: u64 = ((x41 as u64) * (0x5 as u64));
247 let x44: u64 = ((x26 as u64) + x43);
248 let x45: u32 = ((x44 >> 26) as u32);
249 let x46: u32 = ((x44 & (0x3ffffff as u64)) as u32);
250 let x47: u32 = (x45 + x33);
251 let x48: fiat_poly1305_u1 = ((x47 >> 26) as fiat_poly1305_u1);
252 let x49: u32 = (x47 & 0x3ffffff);
253 let x50: u32 = ((x48 as u32) + x36);
254 out1[0] = x46;
255 out1[1] = x49;
256 out1[2] = x50;
257 out1[3] = x39;
258 out1[4] = x42;
259}
260
261#[inline]
267pub fn fiat_poly1305_carry(out1: &mut fiat_poly1305_tight_field_element, arg1: &fiat_poly1305_loose_field_element) {
268 let x1: u32 = (arg1[0]);
269 let x2: u32 = ((x1 >> 26) + (arg1[1]));
270 let x3: u32 = ((x2 >> 26) + (arg1[2]));
271 let x4: u32 = ((x3 >> 26) + (arg1[3]));
272 let x5: u32 = ((x4 >> 26) + (arg1[4]));
273 let x6: u32 = ((x1 & 0x3ffffff) + ((x5 >> 26) * 0x5));
274 let x7: u32 = ((((x6 >> 26) as fiat_poly1305_u1) as u32) + (x2 & 0x3ffffff));
275 let x8: u32 = (x6 & 0x3ffffff);
276 let x9: u32 = (x7 & 0x3ffffff);
277 let x10: u32 = ((((x7 >> 26) as fiat_poly1305_u1) as u32) + (x3 & 0x3ffffff));
278 let x11: u32 = (x4 & 0x3ffffff);
279 let x12: u32 = (x5 & 0x3ffffff);
280 out1[0] = x8;
281 out1[1] = x9;
282 out1[2] = x10;
283 out1[3] = x11;
284 out1[4] = x12;
285}
286
287#[inline]
293pub fn fiat_poly1305_add(out1: &mut fiat_poly1305_loose_field_element, arg1: &fiat_poly1305_tight_field_element, arg2: &fiat_poly1305_tight_field_element) {
294 let x1: u32 = ((arg1[0]) + (arg2[0]));
295 let x2: u32 = ((arg1[1]) + (arg2[1]));
296 let x3: u32 = ((arg1[2]) + (arg2[2]));
297 let x4: u32 = ((arg1[3]) + (arg2[3]));
298 let x5: u32 = ((arg1[4]) + (arg2[4]));
299 out1[0] = x1;
300 out1[1] = x2;
301 out1[2] = x3;
302 out1[3] = x4;
303 out1[4] = x5;
304}
305
306#[inline]
312pub fn fiat_poly1305_sub(out1: &mut fiat_poly1305_loose_field_element, arg1: &fiat_poly1305_tight_field_element, arg2: &fiat_poly1305_tight_field_element) {
313 let x1: u32 = ((0x7fffff6 + (arg1[0])) - (arg2[0]));
314 let x2: u32 = ((0x7fffffe + (arg1[1])) - (arg2[1]));
315 let x3: u32 = ((0x7fffffe + (arg1[2])) - (arg2[2]));
316 let x4: u32 = ((0x7fffffe + (arg1[3])) - (arg2[3]));
317 let x5: u32 = ((0x7fffffe + (arg1[4])) - (arg2[4]));
318 out1[0] = x1;
319 out1[1] = x2;
320 out1[2] = x3;
321 out1[3] = x4;
322 out1[4] = x5;
323}
324
325#[inline]
331pub fn fiat_poly1305_opp(out1: &mut fiat_poly1305_loose_field_element, arg1: &fiat_poly1305_tight_field_element) {
332 let x1: u32 = (0x7fffff6 - (arg1[0]));
333 let x2: u32 = (0x7fffffe - (arg1[1]));
334 let x3: u32 = (0x7fffffe - (arg1[2]));
335 let x4: u32 = (0x7fffffe - (arg1[3]));
336 let x5: u32 = (0x7fffffe - (arg1[4]));
337 out1[0] = x1;
338 out1[1] = x2;
339 out1[2] = x3;
340 out1[3] = x4;
341 out1[4] = x5;
342}
343
344#[inline]
356pub fn fiat_poly1305_selectznz(out1: &mut [u32; 5], arg1: fiat_poly1305_u1, arg2: &[u32; 5], arg3: &[u32; 5]) {
357 let mut x1: u32 = 0;
358 fiat_poly1305_cmovznz_u32(&mut x1, arg1, (arg2[0]), (arg3[0]));
359 let mut x2: u32 = 0;
360 fiat_poly1305_cmovznz_u32(&mut x2, arg1, (arg2[1]), (arg3[1]));
361 let mut x3: u32 = 0;
362 fiat_poly1305_cmovznz_u32(&mut x3, arg1, (arg2[2]), (arg3[2]));
363 let mut x4: u32 = 0;
364 fiat_poly1305_cmovznz_u32(&mut x4, arg1, (arg2[3]), (arg3[3]));
365 let mut x5: u32 = 0;
366 fiat_poly1305_cmovznz_u32(&mut x5, arg1, (arg2[4]), (arg3[4]));
367 out1[0] = x1;
368 out1[1] = x2;
369 out1[2] = x3;
370 out1[3] = x4;
371 out1[4] = x5;
372}
373
374#[inline]
382pub fn fiat_poly1305_to_bytes(out1: &mut [u8; 17], arg1: &fiat_poly1305_tight_field_element) {
383 let mut x1: u32 = 0;
384 let mut x2: fiat_poly1305_u1 = 0;
385 fiat_poly1305_subborrowx_u26(&mut x1, &mut x2, 0x0, (arg1[0]), 0x3fffffb);
386 let mut x3: u32 = 0;
387 let mut x4: fiat_poly1305_u1 = 0;
388 fiat_poly1305_subborrowx_u26(&mut x3, &mut x4, x2, (arg1[1]), 0x3ffffff);
389 let mut x5: u32 = 0;
390 let mut x6: fiat_poly1305_u1 = 0;
391 fiat_poly1305_subborrowx_u26(&mut x5, &mut x6, x4, (arg1[2]), 0x3ffffff);
392 let mut x7: u32 = 0;
393 let mut x8: fiat_poly1305_u1 = 0;
394 fiat_poly1305_subborrowx_u26(&mut x7, &mut x8, x6, (arg1[3]), 0x3ffffff);
395 let mut x9: u32 = 0;
396 let mut x10: fiat_poly1305_u1 = 0;
397 fiat_poly1305_subborrowx_u26(&mut x9, &mut x10, x8, (arg1[4]), 0x3ffffff);
398 let mut x11: u32 = 0;
399 fiat_poly1305_cmovznz_u32(&mut x11, x10, (0x0 as u32), 0xffffffff);
400 let mut x12: u32 = 0;
401 let mut x13: fiat_poly1305_u1 = 0;
402 fiat_poly1305_addcarryx_u26(&mut x12, &mut x13, 0x0, x1, (x11 & 0x3fffffb));
403 let mut x14: u32 = 0;
404 let mut x15: fiat_poly1305_u1 = 0;
405 fiat_poly1305_addcarryx_u26(&mut x14, &mut x15, x13, x3, (x11 & 0x3ffffff));
406 let mut x16: u32 = 0;
407 let mut x17: fiat_poly1305_u1 = 0;
408 fiat_poly1305_addcarryx_u26(&mut x16, &mut x17, x15, x5, (x11 & 0x3ffffff));
409 let mut x18: u32 = 0;
410 let mut x19: fiat_poly1305_u1 = 0;
411 fiat_poly1305_addcarryx_u26(&mut x18, &mut x19, x17, x7, (x11 & 0x3ffffff));
412 let mut x20: u32 = 0;
413 let mut x21: fiat_poly1305_u1 = 0;
414 fiat_poly1305_addcarryx_u26(&mut x20, &mut x21, x19, x9, (x11 & 0x3ffffff));
415 let x22: u32 = (x18 << 6);
416 let x23: u32 = (x16 << 4);
417 let x24: u32 = (x14 << 2);
418 let x25: u8 = ((x12 & (0xff as u32)) as u8);
419 let x26: u32 = (x12 >> 8);
420 let x27: u8 = ((x26 & (0xff as u32)) as u8);
421 let x28: u32 = (x26 >> 8);
422 let x29: u8 = ((x28 & (0xff as u32)) as u8);
423 let x30: u8 = ((x28 >> 8) as u8);
424 let x31: u32 = (x24 + (x30 as u32));
425 let x32: u8 = ((x31 & (0xff as u32)) as u8);
426 let x33: u32 = (x31 >> 8);
427 let x34: u8 = ((x33 & (0xff as u32)) as u8);
428 let x35: u32 = (x33 >> 8);
429 let x36: u8 = ((x35 & (0xff as u32)) as u8);
430 let x37: u8 = ((x35 >> 8) as u8);
431 let x38: u32 = (x23 + (x37 as u32));
432 let x39: u8 = ((x38 & (0xff as u32)) as u8);
433 let x40: u32 = (x38 >> 8);
434 let x41: u8 = ((x40 & (0xff as u32)) as u8);
435 let x42: u32 = (x40 >> 8);
436 let x43: u8 = ((x42 & (0xff as u32)) as u8);
437 let x44: u8 = ((x42 >> 8) as u8);
438 let x45: u32 = (x22 + (x44 as u32));
439 let x46: u8 = ((x45 & (0xff as u32)) as u8);
440 let x47: u32 = (x45 >> 8);
441 let x48: u8 = ((x47 & (0xff as u32)) as u8);
442 let x49: u32 = (x47 >> 8);
443 let x50: u8 = ((x49 & (0xff as u32)) as u8);
444 let x51: u8 = ((x49 >> 8) as u8);
445 let x52: u8 = ((x20 & (0xff as u32)) as u8);
446 let x53: u32 = (x20 >> 8);
447 let x54: u8 = ((x53 & (0xff as u32)) as u8);
448 let x55: u32 = (x53 >> 8);
449 let x56: u8 = ((x55 & (0xff as u32)) as u8);
450 let x57: u8 = ((x55 >> 8) as u8);
451 out1[0] = x25;
452 out1[1] = x27;
453 out1[2] = x29;
454 out1[3] = x32;
455 out1[4] = x34;
456 out1[5] = x36;
457 out1[6] = x39;
458 out1[7] = x41;
459 out1[8] = x43;
460 out1[9] = x46;
461 out1[10] = x48;
462 out1[11] = x50;
463 out1[12] = x51;
464 out1[13] = x52;
465 out1[14] = x54;
466 out1[15] = x56;
467 out1[16] = x57;
468}
469
470#[inline]
478pub fn fiat_poly1305_from_bytes(out1: &mut fiat_poly1305_tight_field_element, arg1: &[u8; 17]) {
479 let x1: u32 = (((arg1[16]) as u32) << 24);
480 let x2: u32 = (((arg1[15]) as u32) << 16);
481 let x3: u32 = (((arg1[14]) as u32) << 8);
482 let x4: u8 = (arg1[13]);
483 let x5: u32 = (((arg1[12]) as u32) << 18);
484 let x6: u32 = (((arg1[11]) as u32) << 10);
485 let x7: u32 = (((arg1[10]) as u32) << 2);
486 let x8: u32 = (((arg1[9]) as u32) << 20);
487 let x9: u32 = (((arg1[8]) as u32) << 12);
488 let x10: u32 = (((arg1[7]) as u32) << 4);
489 let x11: u32 = (((arg1[6]) as u32) << 22);
490 let x12: u32 = (((arg1[5]) as u32) << 14);
491 let x13: u32 = (((arg1[4]) as u32) << 6);
492 let x14: u32 = (((arg1[3]) as u32) << 24);
493 let x15: u32 = (((arg1[2]) as u32) << 16);
494 let x16: u32 = (((arg1[1]) as u32) << 8);
495 let x17: u8 = (arg1[0]);
496 let x18: u32 = (x16 + (x17 as u32));
497 let x19: u32 = (x15 + x18);
498 let x20: u32 = (x14 + x19);
499 let x21: u32 = (x20 & 0x3ffffff);
500 let x22: u8 = ((x20 >> 26) as u8);
501 let x23: u32 = (x13 + (x22 as u32));
502 let x24: u32 = (x12 + x23);
503 let x25: u32 = (x11 + x24);
504 let x26: u32 = (x25 & 0x3ffffff);
505 let x27: u8 = ((x25 >> 26) as u8);
506 let x28: u32 = (x10 + (x27 as u32));
507 let x29: u32 = (x9 + x28);
508 let x30: u32 = (x8 + x29);
509 let x31: u32 = (x30 & 0x3ffffff);
510 let x32: u8 = ((x30 >> 26) as u8);
511 let x33: u32 = (x7 + (x32 as u32));
512 let x34: u32 = (x6 + x33);
513 let x35: u32 = (x5 + x34);
514 let x36: u32 = (x3 + (x4 as u32));
515 let x37: u32 = (x2 + x36);
516 let x38: u32 = (x1 + x37);
517 out1[0] = x21;
518 out1[1] = x26;
519 out1[2] = x31;
520 out1[3] = x35;
521 out1[4] = x38;
522}
523
524#[inline]
530pub fn fiat_poly1305_relax(out1: &mut fiat_poly1305_loose_field_element, arg1: &fiat_poly1305_tight_field_element) {
531 let x1: u32 = (arg1[0]);
532 let x2: u32 = (arg1[1]);
533 let x3: u32 = (arg1[2]);
534 let x4: u32 = (arg1[3]);
535 let x5: u32 = (arg1[4]);
536 out1[0] = x1;
537 out1[1] = x2;
538 out1[2] = x3;
539 out1[3] = x4;
540 out1[4] = x5;
541}