MCPcopy Create free account
hub / github.com/apache/httpd / ap_siphash24

Function ap_siphash24

modules/session/mod_session_crypto.c:109–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107} while(0)
108
109static apr_uint64_t ap_siphash24(const void *src, apr_size_t len,
110 const unsigned char key[AP_SIPHASH_KSIZE])
111{
112 const unsigned char *ptr, *end;
113 apr_uint64_t v0, v1, v2, v3, m;
114 apr_uint64_t k0, k1;
115 unsigned int rem;
116
117 k0 = U8TO64_LE(key + 0);
118 k1 = U8TO64_LE(key + 8);
119 v3 = k1 ^ (apr_uint64_t)0x7465646279746573ULL;
120 v2 = k0 ^ (apr_uint64_t)0x6c7967656e657261ULL;
121 v1 = k1 ^ (apr_uint64_t)0x646f72616e646f6dULL;
122 v0 = k0 ^ (apr_uint64_t)0x736f6d6570736575ULL;
123
124 rem = (unsigned int)(len & 0x7);
125 for (ptr = src, end = ptr + len - rem; ptr < end; ptr += 8) {
126 m = U8TO64_LE(ptr);
127 v3 ^= m;
128 SIPROUND();
129 SIPROUND();
130 v0 ^= m;
131 }
132 m = (apr_uint64_t)(len & 0xff) << 56;
133 switch (rem) {
134 case 7: m |= (apr_uint64_t)ptr[6] << 48;
135 case 6: m |= (apr_uint64_t)ptr[5] << 40;
136 case 5: m |= (apr_uint64_t)ptr[4] << 32;
137 case 4: m |= (apr_uint64_t)ptr[3] << 24;
138 case 3: m |= (apr_uint64_t)ptr[2] << 16;
139 case 2: m |= (apr_uint64_t)ptr[1] << 8;
140 case 1: m |= (apr_uint64_t)ptr[0];
141 case 0: break;
142 }
143 v3 ^= m;
144 SIPROUND();
145 SIPROUND();
146 v0 ^= m;
147
148 v2 ^= 0xff;
149 SIPROUND();
150 SIPROUND();
151 SIPROUND();
152 SIPROUND();
153
154 return v0 ^ v1 ^ v2 ^ v3;
155}
156
157static void ap_siphash24_auth(unsigned char out[AP_SIPHASH_DSIZE],
158 const void *src, apr_size_t len,

Callers 1

ap_siphash24_authFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected