Hi Markus, this is a nice idea, but the websocket handshake takes more than 16 bytes: The client sends to the server a base-64 encoded string. The decoded source string is 16 bytes long, but the encoded string is 24 bytes long.
The server _never_ decodes the 24 byte long string for hashing, it just takes it and append the 36 byte long value “258EAFA5-E914-47DA-95CA-C5AB0DC85B11“. So we are calculating the SHA1 hash of a 24 + 36 = 60 byte long string. If the code without incremental updates can be used to hash a 60 byte long string, then this would be an option. I don’t know what are the limits here. Kind Regards David Gausmann -- [cid:imagece626d.PNG@e202c284.4e8bc0c7] David Gausmann Fachinformatiker Anwendungsentwicklung | Testdatenmanagement und Auswertesysteme Büro: Aachen (Pascalstraße 67, 52076 Aachen-Oberforstbach) Telefon: +49 (0) 2166 9520-170 E-Mail: david.gausm...@measx.com<mailto:david.gausm...@measx.com> | Web: https://www.measx.com measX GmbH & Co. KG | Trompeterallee 110 | 41189 Mönchengladbach | Germany | Telefon: +49 (0) 2166 9520-0 | Fax: +49 (0) 2166 9520-20 Sitz der Gesellschaft: Mönchengladbach | Registergericht: AG Mönchengladbach (HRA 5623) | USt-IdNr: DE 814281560 | Geschäftsführer: Dr. Joachim Hilsmann Persönlich haftende Gesellschafterin: measX Verwaltungsgesellschaft mbH | Registergericht: AG Mönchengladbach (HRB 10947) Bankverbindung: Deutsche Bank IBAN: DE66310700010736334400 | Stadtsparkasse Mönchengladbach IBAN: DE84310500000000276600 Von: libmicrohttpd [mailto:libmicrohttpd-bounces+david.gausmann=measx....@gnu.org] Im Auftrag von Markus Doppelbauer Gesendet: Sonntag, 17. Oktober 2021 23:05 An: libmicrohttpd@gnu.org Betreff: Re: [libmicrohttpd] Update for websocket library Since a websocket handshake hashes only 16 bytes you don't need an implementation that provides incremental updates. The attached SHA1 is slower than the openssl implementation, but quite short. Just in case. -------- Weitergeleitete Nachricht -------- Von: "Gausmann, David" <david.gausm...@measx.com<mailto:%22Gausmann,%20david%22%20%3cdavid.gausm...@measx.com%3e>> Antwort an: libmicrohttpd development and user mailinglist <libmicrohttpd@gnu.org<mailto:libmicrohttpd%20development%20and%20user%20mailinglist%20%3clibmicroht...@gnu.org%3e>> An: libmicrohttpd@gnu.org<mailto:libmicrohttpd@gnu.org> <libmicrohttpd@gnu.org<mailto:%22libmicroht...@gnu.org%22%20%3clibmicroht...@gnu.org%3e>> Betreff: [libmicrohttpd] Update for websocket library Datum: Sun, 17 Oct 2021 18:20:17 +0000 Hi @all, some months ago I wrote an additional library for libmicrohttpd to add support for the websocket protocol. Christian and Evgeny added that library with the configure flag “--with-experimental”. There were still some tasks to do, but now I am finally done with them. In the attachment you find the patch file, which must be applied to get the final version of the API. For short it contains the following changes: - added API documentation to libmicrohttpd.texi - added websocket tutorial chapter to libmicrohttpd-tutorial and an much easier example for the tutorial - added additional helper functions to ease the HTTP websocket handshake - the code can now be compiled on Linux without errors :-) - changed sha1.c and sha1.h to the files provided by Evgeny (I replaced those files in src/microhttpd_ws/ with the files from src/microhttpd/ - maybe there is a smarter way...?) - removed dependency for "htons" and "htonl" (these functions are now implemented in MHD_websocket.c; no need for OS-dependent files anymore) - added an additional test script for testing of the library with any webbrowser (for manual practice test) - several bugfixes - parameters renamed - special things clarified (fragmentation, RNG for client mode) The new version of the API is at some points incompatible with the old version, but since it was in an experimental phase and it didn't compile on Linux, I guess this shouldn't bother anyone. From my point of view, I am now finished with the library and it could go out of experimental. Maybe it would be good if anyone could give it a review. Kind Regards David Gausmann measX GmbH & Co. KG David Gausmann Fachinformatiker Anwendungsentwicklung | Testdatenmanagement und Auswertesysteme Büro: Aachen (Pascalstraße 67, 52076 Aachen-Oberforstbach) Telefon: +49 (0) 2166 9520-170 E-Mail: <mailto:david.gausm...@measx.com> david.gausm...@measx.com<mailto:david.gausm...@measx.com> | Web: <https://www.measx.com> https://www.measx.com measX GmbH & Co. KG | Trompeterallee 110 | 41189 Mönchengladbach | Germany | Telefon: +49 (0) 2166 9520-0 | Fax: +49 (0) 2166 9520-20 Sitz der Gesellschaft: Mönchengladbach | Registergericht: AG Mönchengladbach (HRA 5623) | USt-IdNr: DE 814281560 Geschäftsführer: Dr. Joachim Hilsmann | Stadtsparkasse Mönchengladbach IBAN: DE84310500000000276600 | BIC-Swift: MG LS DE 33 Persönlich haftende Gesellschafterin: measX Verwaltungsgesellschaft mbH | Registergericht: AG Mönchengladbach (HRB 10947) __________________________________________________________________________________________________________________