| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 static String generateSecWebSocketKey() | 115 static String generateSecWebSocketKey() |
| 116 { | 116 { |
| 117 static const size_t nonceSize = 16; | 117 static const size_t nonceSize = 16; |
| 118 unsigned char key[nonceSize]; | 118 unsigned char key[nonceSize]; |
| 119 cryptographicallyRandomValues(key, nonceSize); | 119 cryptographicallyRandomValues(key, nonceSize); |
| 120 return base64Encode(reinterpret_cast<char*>(key), nonceSize); | 120 return base64Encode(reinterpret_cast<char*>(key), nonceSize); |
| 121 } | 121 } |
| 122 | 122 |
| 123 String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocket
Key) | 123 String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocket
Key) |
| 124 { | 124 { |
| 125 static const char* const webSocketKeyGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC
85B11"; | 125 static const char webSocketKeyGUID[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11
"; |
| 126 static const size_t sha1HashSize = 20; // FIXME: This should be defined in S
HA1.h. | 126 static const size_t sha1HashSize = 20; // FIXME: This should be defined in S
HA1.h. |
| 127 SHA1 sha1; | 127 SHA1 sha1; |
| 128 CString keyData = secWebSocketKey.ascii(); | 128 CString keyData = secWebSocketKey.ascii(); |
| 129 sha1.addBytes(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.leng
th()); | 129 sha1.addBytes(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.leng
th()); |
| 130 sha1.addBytes(reinterpret_cast<const uint8_t*>(webSocketKeyGUID), strlen(web
SocketKeyGUID)); | 130 sha1.addBytes(reinterpret_cast<const uint8_t*>(webSocketKeyGUID), strlen(web
SocketKeyGUID)); |
| 131 Vector<uint8_t, sha1HashSize> hash; | 131 Vector<uint8_t, sha1HashSize> hash; |
| 132 sha1.computeHash(hash); | 132 sha1.computeHash(hash); |
| 133 return base64Encode(reinterpret_cast<const char*>(hash.data()), sha1HashSize
); | 133 return base64Encode(reinterpret_cast<const char*>(hash.data()), sha1HashSize
); |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 } | 583 } |
| 584 if (!match) { | 584 if (!match) { |
| 585 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-
WebSocket-Protocol' header but no response is received"); | 585 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-
WebSocket-Protocol' header but no response is received"); |
| 586 return false; | 586 return false; |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 return true; | 589 return true; |
| 590 } | 590 } |
| 591 | 591 |
| 592 } // namespace WebCore | 592 } // namespace WebCore |
| OLD | NEW |