MCPcopy Create free account
hub / github.com/ElementsProject/lightning / sync_crypto_read

Function sync_crypto_read

devtools/gossipwith.c:134–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134static u8 *sync_crypto_read(const tal_t *ctx, int peer_fd, struct crypto_state *cs)
135{
136 u8 hdr[18], *enc, *dec;
137 u16 len;
138
139 if (!read_all(peer_fd, hdr, sizeof(hdr))) {
140 status_debug("Failed reading header: %s", strerror(errno));
141 exit(0);
142 }
143
144 if (!cryptomsg_decrypt_header(cs, hdr, &len)) {
145 status_debug("Failed hdr decrypt with rn=%"PRIu64,
146 cs->rn-1);
147 exit(1);
148 }
149
150 enc = tal_arr(ctx, u8, len + 16);
151 if (!read_all(peer_fd, enc, tal_count(enc))) {
152 status_debug("Failed reading body: %s", strerror(errno));
153 exit(1);
154 }
155
156 dec = cryptomsg_decrypt_body(ctx, cs, enc);
157 tal_free(enc);
158 if (!dec)
159 exit(1);
160 else
161 status_peer_io(LOG_IO_IN, NULL, dec);
162
163 return dec;
164}
165
166static struct io_plan *handshake_success(struct io_conn *conn,
167 const struct pubkey *them,

Callers 1

handshake_successFunction · 0.85

Calls 5

read_allFunction · 0.85
cryptomsg_decrypt_headerFunction · 0.85
cryptomsg_decrypt_bodyFunction · 0.85
tal_freeFunction · 0.85
status_peer_ioFunction · 0.70

Tested by

no test coverage detected