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

Function websocket_accept_str

connectd/websocketd.c:64–77  ·  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

62 |Sec-WebSocket-Accept| header field.
63*/
64static const char *websocket_accept_str(const tal_t *ctx, const char *key)
65{
66 u8 sha1[20];
67 const char *concat;
68 char base64[100];
69
70 concat = tal_fmt(tmpctx, "%s258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
71 key);
72 sha1digest(sha1, (const u8 *)concat, strlen(concat));
73 if (base64_encode(base64, sizeof(base64), (const char *)sha1, sizeof(sha1)) == -1)
74 abort();
75
76 return tal_strdup(ctx, base64);
77}
78
79static void NORETURN PRINTF_FMT(2,3)
80bad_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