| 313 | } |
| 314 | |
| 315 | static void generate_header_padding(void *dst, size_t dstlen, |
| 316 | size_t fixed_size, |
| 317 | const struct sphinx_path *path, |
| 318 | struct hop_params *params) |
| 319 | { |
| 320 | struct secret key; |
| 321 | size_t fillerStart, fillerEnd, fillerSize; |
| 322 | |
| 323 | memset(dst, 0, dstlen); |
| 324 | for (int i = 0; i < tal_count(path->hops) - 1; i++) { |
| 325 | subkey_from_hmac("rho", ¶ms[i].secret, &key); |
| 326 | |
| 327 | /* Sum up how many bytes have been used by previous hops, |
| 328 | * that gives us the start in the stream */ |
| 329 | fillerSize = 0; |
| 330 | for (int j = 0; j < i; j++) |
| 331 | fillerSize += sphinx_hop_size(&path->hops[j]); |
| 332 | fillerStart = fixed_size - fillerSize; |
| 333 | |
| 334 | /* The filler will dangle off of the end by the current |
| 335 | * hop-size, we'll make sure to copy it into the correct |
| 336 | * position in the next step. */ |
| 337 | fillerEnd = fixed_size + sphinx_hop_size(&path->hops[i]); |
| 338 | |
| 339 | /* Apply the cipher-stream to the part of the filler that'll |
| 340 | * be added by this hop */ |
| 341 | xor_cipher_stream_off(&key, fillerStart, |
| 342 | dst, fillerEnd - fillerStart); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | static void generate_prefill(void *dst, size_t dstlen, |
| 347 | size_t fixed_size, |
no test coverage detected