Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ec/curve448/arch_32/f_impl.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||
2 | * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||
3 | * Copyright 2014 Cryptography Research, Inc. | - | ||||||
4 | * | - | ||||||
5 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||
6 | * this file except in compliance with the License. You can obtain a copy | - | ||||||
7 | * in the file LICENSE in the source distribution or at | - | ||||||
8 | * https://www.openssl.org/source/license.html | - | ||||||
9 | * | - | ||||||
10 | * Originally written by Mike Hamburg | - | ||||||
11 | */ | - | ||||||
12 | - | |||||||
13 | #include "field.h" | - | ||||||
14 | - | |||||||
15 | void gf_mul(gf_s * RESTRICT cs, const gf as, const gf bs) | - | ||||||
16 | { | - | ||||||
17 | const uint32_t *a = as->limb, *b = bs->limb; | - | ||||||
18 | uint32_t *c = cs->limb; | - | ||||||
19 | uint64_t accum0 = 0, accum1 = 0, accum2 = 0; | - | ||||||
20 | uint32_t mask = (1 << 28) - 1; | - | ||||||
21 | uint32_t aa[8], bb[8]; | - | ||||||
22 | int i, j; | - | ||||||
23 | - | |||||||
24 | for (i = 0; i < 8; i++) {
| 4751668-38013344 | ||||||
25 | aa[i] = a[i] + a[i + 8]; | - | ||||||
26 | bb[i] = b[i] + b[i + 8]; | - | ||||||
27 | } executed 38013344 times by 2 tests: end of block Executed by:
| 38013344 | ||||||
28 | - | |||||||
29 | for (j = 0; j < 8; j++) {
| 4751668-38013344 | ||||||
30 | accum2 = 0; | - | ||||||
31 | for (i = 0; i < j + 1; i++) {
| 38013344-171060048 | ||||||
32 | accum2 += widemul(a[j - i], b[i]); | - | ||||||
33 | accum1 += widemul(aa[j - i], bb[i]); | - | ||||||
34 | accum0 += widemul(a[8 + j - i], b[8 + i]); | - | ||||||
35 | } executed 171060048 times by 2 tests: end of block Executed by:
| 171060048 | ||||||
36 | accum1 -= accum2; | - | ||||||
37 | accum0 += accum2; | - | ||||||
38 | accum2 = 0; | - | ||||||
39 | for (i = j + 1; i < 8; i++) {
| 38013344-133046704 | ||||||
40 | accum0 -= widemul(a[8 + j - i], b[i]); | - | ||||||
41 | accum2 += widemul(aa[8 + j - i], bb[i]); | - | ||||||
42 | accum1 += widemul(a[16 + j - i], b[8 + i]); | - | ||||||
43 | } executed 133046704 times by 2 tests: end of block Executed by:
| 133046704 | ||||||
44 | accum1 += accum2; | - | ||||||
45 | accum0 += accum2; | - | ||||||
46 | c[j] = ((uint32_t)(accum0)) & mask; | - | ||||||
47 | c[j + 8] = ((uint32_t)(accum1)) & mask; | - | ||||||
48 | accum0 >>= 28; | - | ||||||
49 | accum1 >>= 28; | - | ||||||
50 | } executed 38013344 times by 2 tests: end of block Executed by:
| 38013344 | ||||||
51 | - | |||||||
52 | accum0 += accum1; | - | ||||||
53 | accum0 += c[8]; | - | ||||||
54 | accum1 += c[0]; | - | ||||||
55 | c[8] = ((uint32_t)(accum0)) & mask; | - | ||||||
56 | c[0] = ((uint32_t)(accum1)) & mask; | - | ||||||
57 | - | |||||||
58 | accum0 >>= 28; | - | ||||||
59 | accum1 >>= 28; | - | ||||||
60 | c[9] += ((uint32_t)(accum0)); | - | ||||||
61 | c[1] += ((uint32_t)(accum1)); | - | ||||||
62 | } executed 4751668 times by 2 tests: end of block Executed by:
| 4751668 | ||||||
63 | - | |||||||
64 | void gf_mulw_unsigned(gf_s * RESTRICT cs, const gf as, uint32_t b) | - | ||||||
65 | { | - | ||||||
66 | const uint32_t *a = as->limb; | - | ||||||
67 | uint32_t *c = cs->limb; | - | ||||||
68 | uint64_t accum0 = 0, accum8 = 0; | - | ||||||
69 | uint32_t mask = (1 << 28) - 1; | - | ||||||
70 | int i; | - | ||||||
71 | - | |||||||
72 | assert(b <= mask); | - | ||||||
73 | - | |||||||
74 | for (i = 0; i < 8; i++) {
| 454371-3634968 | ||||||
75 | accum0 += widemul(b, a[i]); | - | ||||||
76 | accum8 += widemul(b, a[i + 8]); | - | ||||||
77 | c[i] = accum0 & mask; | - | ||||||
78 | accum0 >>= 28; | - | ||||||
79 | c[i + 8] = accum8 & mask; | - | ||||||
80 | accum8 >>= 28; | - | ||||||
81 | } executed 3634968 times by 2 tests: end of block Executed by:
| 3634968 | ||||||
82 | - | |||||||
83 | accum0 += accum8 + c[8]; | - | ||||||
84 | c[8] = ((uint32_t)accum0) & mask; | - | ||||||
85 | c[9] += (uint32_t)(accum0 >> 28); | - | ||||||
86 | - | |||||||
87 | accum8 += c[0]; | - | ||||||
88 | c[0] = ((uint32_t)accum8) & mask; | - | ||||||
89 | c[1] += (uint32_t)(accum8 >> 28); | - | ||||||
90 | } executed 454371 times by 2 tests: end of block Executed by:
| 454371 | ||||||
91 | - | |||||||
92 | void gf_sqr(gf_s * RESTRICT cs, const gf as) | - | ||||||
93 | { | - | ||||||
94 | gf_mul(cs, as, as); /* Performs better with a dedicated square */ | - | ||||||
95 | } executed 2358815 times by 2 tests: end of block Executed by:
| 2358815 | ||||||
Source code | Switch to Preprocessed file |