• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 14230500445

02 Apr 2025 01:53PM UTC coverage: 52.058% (-11.4%) from 63.455%
14230500445

push

github

web-flow
Merge pull request #15385 from rgacogne/ddist-enable-quiche-sni-tests

dnsdist: Enable the DoQ and DoH3 parts of the SNI tests in our CI

21502 of 68138 branches covered (31.56%)

Branch coverage included in aggregate %.

77059 of 121190 relevant lines covered (63.59%)

4345179.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.32
/pdns/burtle.hh
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22

23
#pragma once
24

25
#include <cinttypes>
26

27
inline void burtlemix(uint32_t& a, uint32_t& b, uint32_t& c)
28
{
43,552,414✔
29
  a -= b;
43,552,414✔
30
  a -= c;
43,552,414✔
31
  a ^= (c >> 13);
43,552,414✔
32
  b -= c;
43,552,414✔
33
  b -= a;
43,552,414✔
34
  b ^= (a << 8);
43,552,414✔
35
  c -= a;
43,552,414✔
36
  c -= b;
43,552,414✔
37
  c ^= (b >> 13);
43,552,414✔
38
  a -= b;
43,552,414✔
39
  a -= c;
43,552,414✔
40
  a ^= (c >> 12);
43,552,414✔
41
  b -= c;
43,552,414✔
42
  b -= a;
43,552,414✔
43
  b ^= (a << 16);
43,552,414✔
44
  c -= a;
43,552,414✔
45
  c -= b;
43,552,414✔
46
  c ^= (b >> 5);
43,552,414✔
47
  a -= b;
43,552,414✔
48
  a -= c;
43,552,414✔
49
  a ^= (c >> 3);
43,552,414✔
50
  b -= c;
43,552,414✔
51
  b -= a;
43,552,414✔
52
  b ^= (a << 10);
43,552,414✔
53
  c -= a;
43,552,414✔
54
  c -= b;
43,552,414✔
55
  c ^= (b >> 15);
43,552,414✔
56
}
43,552,414✔
57

58
inline uint32_t burtle(const unsigned char* k, uint32_t length, uint32_t initval)
59
{
10,369,304✔
60
  uint32_t a, b, c, len;
10,369,304✔
61

62
  /* Set up the internal state */
63
  len = length;
10,369,304✔
64
  a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
10,369,304✔
65
  c = initval; /* the previous hash value */
10,369,304✔
66

67
  /*---------------------------------------- handle most of the key */
68
  while (len >= 12) {
10,379,711✔
69
    a += (k[0] + ((uint32_t)k[1] << 8) + ((uint32_t)k[2] << 16) + ((uint32_t)k[3] << 24));
10,407✔
70
    b += (k[4] + ((uint32_t)k[5] << 8) + ((uint32_t)k[6] << 16) + ((uint32_t)k[7] << 24));
10,407✔
71
    c += (k[8] + ((uint32_t)k[9] << 8) + ((uint32_t)k[10] << 16) + ((uint32_t)k[11] << 24));
10,407✔
72
    burtlemix(a, b, c);
10,407✔
73
    k += 12;
10,407✔
74
    len -= 12;
10,407✔
75
  }
10,407✔
76

77
  /*------------------------------------- handle the last 11 bytes */
78
  c += length;
10,369,304✔
79
  switch (len) { /* all the case statements fall through */
10,369,304✔
80
  case 11:
×
81
    c += ((uint32_t)k[10] << 24);
×
82
    /* fall-through */
83
  case 10:
3,544,577✔
84
    c += ((uint32_t)k[9] << 16);
3,544,577✔
85
    /* fall-through */
86
  case 9:
3,544,580✔
87
    c += ((uint32_t)k[8] << 8);
3,544,580✔
88
    /* the first byte of c is reserved for the length */
89
    /* fall-through */
90
  case 8:
3,544,611✔
91
    b += ((uint32_t)k[7] << 24);
3,544,611✔
92
    /* fall-through */
93
  case 7:
3,544,611!
94
    b += ((uint32_t)k[6] << 16);
3,544,611✔
95
    /* fall-through */
96
  case 6:
3,544,611!
97
    b += ((uint32_t)k[5] << 8);
3,544,611✔
98
    /* fall-through */
99
  case 5:
3,544,611!
100
    b += k[4];
3,544,611✔
101
    /* fall-through */
102
  case 4:
7,680,413✔
103
    a += ((uint32_t)k[3] << 24);
7,680,413✔
104
    /* fall-through */
105
  case 3:
7,680,465✔
106
    a += ((uint32_t)k[2] << 16);
7,680,465✔
107
    /* fall-through */
108
  case 2:
7,695,402✔
109
    a += ((uint32_t)k[1] << 8);
7,695,402✔
110
    /* fall-through */
111
  case 1:
10,440,602✔
112
    a += k[0];
10,440,602✔
113
    /* case 0: nothing left to add */
114
  }
10,369,304✔
115
  burtlemix(a, b, c);
10,388,959✔
116
  /*-------------------------------------------- report the result */
117
  return c;
10,357,658✔
118
}
10,369,304✔
119

120
inline uint32_t burtleCI(const unsigned char* k, uint32_t length, uint32_t initval)
121
{
16,663,940✔
122
  uint32_t a, b, c, len;
16,663,940✔
123

124
  /* Set up the internal state */
125
  len = length;
16,663,940✔
126
  a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
16,663,940✔
127
  c = initval; /* the previous hash value */
16,663,940✔
128

129
  /*---------------------------------------- handle most of the key */
130
  while (len >= 12) {
33,149,989✔
131
    a += (dns_tolower(k[0]) + ((uint32_t)dns_tolower(k[1]) << 8) + ((uint32_t)dns_tolower(k[2]) << 16) + ((uint32_t)dns_tolower(k[3]) << 24));
16,486,049✔
132
    b += (dns_tolower(k[4]) + ((uint32_t)dns_tolower(k[5]) << 8) + ((uint32_t)dns_tolower(k[6]) << 16) + ((uint32_t)dns_tolower(k[7]) << 24));
16,486,049✔
133
    c += (dns_tolower(k[8]) + ((uint32_t)dns_tolower(k[9]) << 8) + ((uint32_t)dns_tolower(k[10]) << 16) + ((uint32_t)dns_tolower(k[11]) << 24));
16,486,049✔
134
    burtlemix(a, b, c);
16,486,049✔
135
    k += 12;
16,486,049✔
136
    len -= 12;
16,486,049✔
137
  }
16,486,049✔
138

139
  /*------------------------------------- handle the last 11 bytes */
140
  c += length;
16,663,940✔
141
  switch (len) { /* all the case statements fall through */
16,663,940✔
142
  case 11:
82,229✔
143
    c += ((uint32_t)dns_tolower(k[10]) << 24);
82,229✔
144
    /* fall-through */
145
  case 10:
153,964✔
146
    c += ((uint32_t)dns_tolower(k[9]) << 16);
153,964✔
147
    /* fall-through */
148
  case 9:
642,865✔
149
    c += ((uint32_t)dns_tolower(k[8]) << 8);
642,865✔
150
    /* the first byte of c is reserved for the length */
151
    /* fall-through */
152
  case 8:
1,804,548✔
153
    b += ((uint32_t)dns_tolower(k[7]) << 24);
1,804,548✔
154
    /* fall-through */
155
  case 7:
1,927,496✔
156
    b += ((uint32_t)dns_tolower(k[6]) << 16);
1,927,496✔
157
    /* fall-through */
158
  case 6:
2,053,041✔
159
    b += ((uint32_t)dns_tolower(k[5]) << 8);
2,053,041✔
160
    /* fall-through */
161
  case 5:
2,295,406✔
162
    b += dns_tolower(k[4]);
2,295,406✔
163
    /* fall-through */
164
  case 4:
6,361,110✔
165
    a += ((uint32_t)dns_tolower(k[3]) << 24);
6,361,110✔
166
    /* fall-through */
167
  case 3:
8,475,830✔
168
    a += ((uint32_t)dns_tolower(k[2]) << 16);
8,475,830✔
169
    /* fall-through */
170
  case 2:
15,613,480✔
171
    a += ((uint32_t)dns_tolower(k[1]) << 8);
15,613,480✔
172
    /* fall-through */
173
  case 1:
16,580,300✔
174
    a += dns_tolower(k[0]);
16,580,300✔
175
    /* case 0: nothing left to add */
176
  }
16,663,940✔
177
  burtlemix(a, b, c);
16,714,154✔
178
  /*-------------------------------------------- report the result */
179
  return c;
16,701,949✔
180
}
16,663,940✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc