From: Andy Green Date: Sat, 26 Feb 2011 11:17:48 +0000 (+0000) Subject: only have nonce requirement and processing for exactly 04 X-Git-Tag: 1.2~154 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4eaa86b29192919da65c3614ddcd094905ac14af;p=profile%2Fivi%2Flibwebsockets.git only have nonce requirement and processing for exactly 04 Signed-off-by: Andy Green --- diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 1fc2e7a..b3e6023 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -885,7 +885,8 @@ libwebsocket_service_fd(struct libwebsocket_context *this, !wsi->utf8_token[WSI_TOKEN_UPGRADE].token_len || !wsi->utf8_token[WSI_TOKEN_CONNECTION].token_len || !wsi->utf8_token[WSI_TOKEN_ACCEPT].token_len || - !wsi->utf8_token[WSI_TOKEN_NONCE].token_len || + (!wsi->utf8_token[WSI_TOKEN_NONCE].token_len && + wsi->ietf_spec_revision == 4) || (!wsi->utf8_token[WSI_TOKEN_PROTOCOL].token_len && wsi->c_protocol != NULL)) { fprintf(stderr, "libwebsocket_client_handshake " @@ -1010,16 +1011,19 @@ libwebsocket_service_fd(struct libwebsocket_context *this, goto bail2; } - /* - * Calculate the masking key to use when sending data to server - */ + if (wsi->ietf_spec_revision == 4) { + /* + * Calculate the 04 masking key to use when + * sending data to server + */ - strcpy((char *)buf, wsi->key_b64); - p = (char *)buf + strlen(wsi->key_b64); - strcpy(p, wsi->utf8_token[WSI_TOKEN_NONCE].token); - p += wsi->utf8_token[WSI_TOKEN_NONCE].token_len; - strcpy(p, magic_websocket_04_masking_guid); - SHA1(buf, strlen((char *)buf), wsi->masking_key_04); + strcpy((char *)buf, wsi->key_b64); + p = (char *)buf + strlen(wsi->key_b64); + strcpy(p, wsi->utf8_token[WSI_TOKEN_NONCE].token); + p += wsi->utf8_token[WSI_TOKEN_NONCE].token_len; + strcpy(p, magic_websocket_04_masking_guid); + SHA1(buf, strlen((char *)buf), wsi->masking_key_04); + } /* allocate the per-connection user memory (if any) */