| 166 | } |
| 167 | |
| 168 | int main(int argc, char *argv[]) |
| 169 | { |
| 170 | struct privkey nodekey[4], path_key[4], override_path_key; |
| 171 | struct pubkey id[4], path_key_pub[4], override_path_key_pub, alias[4]; |
| 172 | struct secret self_id; |
| 173 | struct tlv_encrypted_data_tlv *tlv[4]; |
| 174 | u8 *enctlv[4]; |
| 175 | u8 *onionmsg_tlv[4]; |
| 176 | u8 *omsg; |
| 177 | struct sphinx_path *sphinx_path; |
| 178 | struct secret *path_secrets; |
| 179 | struct onionpacket *op; |
| 180 | const char *names[] = {"Alice", "Bob", "Carol", "Dave"}; |
| 181 | |
| 182 | common_setup(argv[0]); |
| 183 | |
| 184 | for (size_t i = 0; i < 4; i++) { |
| 185 | memset(&nodekey[i], names[i][0], sizeof(nodekey[i])); |
| 186 | pubkey_from_privkey(&nodekey[i], &id[i]); |
| 187 | } |
| 188 | |
| 189 | /* Make enctlvs as per enctlv test vectors */ |
| 190 | memset(&path_key[ALICE], 5, sizeof(path_key[ALICE])); |
| 191 | pubkey_from_privkey(&path_key[ALICE], &path_key_pub[ALICE]); |
| 192 | |
| 193 | tlv[ALICE] = tlv_encrypted_data_tlv_new(tmpctx); |
| 194 | tlv[ALICE]->next_node_id = &id[BOB]; |
| 195 | enctlv[ALICE] = encrypt_tlv_encrypted_data(tmpctx, |
| 196 | &path_key[ALICE], |
| 197 | &id[ALICE], tlv[ALICE], |
| 198 | &path_key[BOB], |
| 199 | &alias[ALICE]); |
| 200 | |
| 201 | pubkey_from_privkey(&path_key[BOB], &path_key_pub[BOB]); |
| 202 | |
| 203 | /* We override path_key for Carol. */ |
| 204 | memset(&override_path_key, 7, sizeof(override_path_key)); |
| 205 | pubkey_from_privkey(&override_path_key, &override_path_key_pub); |
| 206 | |
| 207 | tlv[BOB] = tlv_encrypted_data_tlv_new(tmpctx); |
| 208 | tlv[BOB]->next_node_id = &id[CAROL]; |
| 209 | tlv[BOB]->next_path_key_override = &override_path_key_pub; |
| 210 | enctlv[BOB] = encrypt_tlv_encrypted_data(tmpctx, |
| 211 | &path_key[BOB], |
| 212 | &id[BOB], tlv[BOB], |
| 213 | &path_key[CAROL], |
| 214 | &alias[BOB]); |
| 215 | |
| 216 | /* That replaced the path_key */ |
| 217 | path_key[CAROL] = override_path_key; |
| 218 | path_key_pub[CAROL] = override_path_key_pub; |
| 219 | |
| 220 | tlv[CAROL] = tlv_encrypted_data_tlv_new(tmpctx); |
| 221 | tlv[CAROL]->next_node_id = &id[DAVE]; |
| 222 | tlv[CAROL]->padding = tal_arrz(tlv[CAROL], u8, 35); |
| 223 | enctlv[CAROL] = encrypt_tlv_encrypted_data(tmpctx, |
| 224 | &path_key[CAROL], |
| 225 | &id[CAROL], tlv[CAROL], |
nothing calls this directly
no test coverage detected