summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2011-02-26 11:17:48 +0000
committerAndy Green <andy@warmcat.com>2011-02-26 11:17:48 +0000
commit4eaa86b29192919da65c3614ddcd094905ac14af (patch)
treeeeac051b7557865ced03f0fe0fc455d9538aa509
parent9514bf88391529c6995be71d3b9a2e33a6fa6c93 (diff)
only have nonce requirement and processing for exactly 04release-0.5
Signed-off-by: Andy Green <andy@warmcat.com>
-rw-r--r--lib/libwebsockets.c24
1 files changed, 14 insertions, 10 deletions
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) */