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
| 57 | |Sec-WebSocket-Accept| header field. |
| 58 | */ |
| 59 | static 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 | |
| 74 | static void NORETURN PRINTF_FMT(2,3) |
| 75 | bad_http(int fd, const char *fmt, ...) |
no test coverage detected