| 285 | } |
| 286 | |
| 287 | static void generate_header_padding(void *dst, size_t dstlen, |
| 288 | size_t fixed_size, |
| 289 | const struct sphinx_path *path, |
| 290 | struct hop_params *params) |
| 291 | { |
| 292 | struct secret key; |
| 293 | size_t fillerStart, fillerEnd, fillerSize; |
| 294 | |
| 295 | memset(dst, 0, dstlen); |
| 296 | for (int i = 0; i < tal_count(path->hops) - 1; i++) { |
| 297 | subkey_from_hmac("rho", ¶ms[i].secret, &key); |
| 298 | |
| 299 | /* Sum up how many bytes have been used by previous hops, |
| 300 | * that gives us the start in the stream */ |
| 301 | fillerSize = 0; |
| 302 | for (int j = 0; j < i; j++) |
| 303 | fillerSize += sphinx_hop_size(&path->hops[j]); |
| 304 | fillerStart = fixed_size - fillerSize; |
| 305 | |
| 306 | /* The filler will dangle off of the end by the current |
| 307 | * hop-size, we'll make sure to copy it into the correct |
| 308 | * position in the next step. */ |
| 309 | fillerEnd = fixed_size + sphinx_hop_size(&path->hops[i]); |
| 310 | |
| 311 | /* Apply the cipher-stream to the part of the filler that'll |
| 312 | * be added by this hop */ |
| 313 | xor_cipher_stream_off(&key, fillerStart, |
| 314 | dst, fillerEnd - fillerStart); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | static void generate_prefill(void *dst, size_t dstlen, |
| 319 | size_t fixed_size, |
no test coverage detected