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

Function websocket_accept_str

connectd/websocketd.c:59–72  ·  view source on GitHub ↗

RFC-6455: A |Sec-WebSocket-Accept| header field. The value of this header field is constructed by concatenating /key/, defined above in step 4 in Section 4.2.2, with the string "258EAFA5- E914-47DA-95CA-C5AB0DC85B11", taking the SHA-1 hash of this concatenated value to obtain a 20-byte value and base64- encoding (see Section 4 of [RFC4648]) this 20-byte hash. ... NOTE: As an exa

Source from the content-addressed store, hash-verified

57 |Sec-WebSocket-Accept| header field.
58*/
59static const char *websocket_accept_str(const tal_t *ctx, const char *key)
60{
61 u8 sha1[20];
62 const char *concat;
63 char base64[100];
64
65 concat = tal_fmt(tmpctx, "%s258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
66 key);
67 sha1digest(sha1, (const u8 *)concat, strlen(concat));
68 if (base64_encode(base64, sizeof(base64), (const char *)sha1, sizeof(sha1)) == -1)
69 abort();
70
71 return tal_strdup(ctx, base64);
72}
73
74static void NORETURN PRINTF_FMT(2,3)
75bad_http(int fd, const char *fmt, ...)

Callers 1

http_respondFunction · 0.85

Calls 3

sha1digestFunction · 0.85
base64_encodeFunction · 0.85
abortFunction · 0.85

Tested by

no test coverage detected