|
| 1 | +/* |
| 2 | + * Copyright (c) 2016-2017, Arm Limited and affiliates. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
1 | 17 | #include "nsconfig.h"
|
2 | 18 |
|
| 19 | +#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) |
| 20 | + |
| 21 | +#define final(a,b,c) \ |
| 22 | +{ \ |
| 23 | + c ^= b; c -= rot(b, 14); \ |
| 24 | + a ^= c; a -= rot(c, 11); \ |
| 25 | + b ^= a; b -= rot(a, 25); \ |
| 26 | + c ^= b; c -= rot(b, 16); \ |
| 27 | + a ^= c; a -= rot(c, 4); \ |
| 28 | + b ^= a; b -= rot(a, 14); \ |
| 29 | + c ^= b; c -= rot(b, 24); \ |
| 30 | +} |
| 31 | + |
| 32 | +#define mix(a,b,c) \ |
| 33 | +{ \ |
| 34 | + a -= c; a ^= rot(c, 4); c += b; \ |
| 35 | + b -= a; b ^= rot(a, 6); a += c; \ |
| 36 | + c -= b; c ^= rot(b, 8); b += a; \ |
| 37 | + a -= c; a ^= rot(c, 16); c += b; \ |
| 38 | + b -= a; b ^= rot(a, 19); a += c; \ |
| 39 | + c -= b; c ^= rot(b, 4); b += a; \ |
| 40 | +} |
| 41 | + |
3 | 42 | static uint32_t global_seed = 1;
|
4 | 43 |
|
5 | 44 | void tr51_seed_rand(uint32_t seed)
|
@@ -45,7 +84,7 @@ void tr51_compute_cfd(uint8_t *mac, uint8_t *first_element, uint8_t *step_size,
|
45 | 84 | *step_size = (mac[7] % (channel_table_length - 1)) + 1;
|
46 | 85 | }
|
47 | 86 |
|
48 |
| -uint8_t tr51_find_excluded(int32_t channel, uint16_t *excluded_channels, uint16_t number_of_excluded_channels) |
| 87 | +static uint8_t tr51_find_excluded(int32_t channel, uint16_t *excluded_channels, uint16_t number_of_excluded_channels) |
49 | 88 | {
|
50 | 89 | uint8_t count = 0;
|
51 | 90 | if (excluded_channels != NULL) {
|
@@ -78,29 +117,6 @@ uint16_t tr51_calculate_hopping_sequence(int32_t *channel_table, uint16_t channe
|
78 | 117 | return slot;
|
79 | 118 | }
|
80 | 119 |
|
81 |
| -#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k)))) |
82 |
| - |
83 |
| -#define final(a,b,c) \ |
84 |
| -{ \ |
85 |
| - c ^= b; c -= rot(b, 14); \ |
86 |
| - a ^= c; a -= rot(c, 11); \ |
87 |
| - b ^= a; b -= rot(a, 25); \ |
88 |
| - c ^= b; c -= rot(b, 16); \ |
89 |
| - a ^= c; a -= rot(c, 4); \ |
90 |
| - b ^= a; b -= rot(a, 14); \ |
91 |
| - c ^= b; c -= rot(b, 24); \ |
92 |
| -} |
93 |
| - |
94 |
| -#define mix(a,b,c) \ |
95 |
| -{ \ |
96 |
| - a -= c; a ^= rot(c, 4); c += b; \ |
97 |
| - b -= a; b ^= rot(a, 6); a += c; \ |
98 |
| - c -= b; c ^= rot(b, 8); b += a; \ |
99 |
| - a -= c; a ^= rot(c, 16); c += b; \ |
100 |
| - b -= a; b ^= rot(a, 19); a += c; \ |
101 |
| - c -= b; c ^= rot(b, 4); b += a; \ |
102 |
| -} |
103 |
| - |
104 | 120 | static uint32_t dh1cf_hashword(const uint32_t *key, size_t key_length, uint32_t init_value)
|
105 | 121 | {
|
106 | 122 | uint32_t a,b,c;
|
|
0 commit comments