| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 static String generateSecWebSocketKey() | 117 static String generateSecWebSocketKey() |
| 118 { | 118 { |
| 119 static const size_t nonceSize = 16; | 119 static const size_t nonceSize = 16; |
| 120 unsigned char key[nonceSize]; | 120 unsigned char key[nonceSize]; |
| 121 cryptographicallyRandomValues(key, nonceSize); | 121 cryptographicallyRandomValues(key, nonceSize); |
| 122 return base64Encode(reinterpret_cast<char*>(key), nonceSize); | 122 return base64Encode(reinterpret_cast<char*>(key), nonceSize); |
| 123 } | 123 } |
| 124 | 124 |
| 125 String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocket
Key) | 125 String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocket
Key) |
| 126 { | 126 { |
| 127 static const char* const webSocketKeyGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC
85B11"; | 127 static const char webSocketKeyGUID[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11
"; |
| 128 static const size_t sha1HashSize = 20; // FIXME: This should be defined in S
HA1.h. | 128 static const size_t sha1HashSize = 20; // FIXME: This should be defined in S
HA1.h. |
| 129 SHA1 sha1; | 129 SHA1 sha1; |
| 130 CString keyData = secWebSocketKey.ascii(); | 130 CString keyData = secWebSocketKey.ascii(); |
| 131 sha1.addBytes(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.leng
th()); | 131 sha1.addBytes(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.leng
th()); |
| 132 sha1.addBytes(reinterpret_cast<const uint8_t*>(webSocketKeyGUID), strlen(web
SocketKeyGUID)); | 132 sha1.addBytes(reinterpret_cast<const uint8_t*>(webSocketKeyGUID), strlen(web
SocketKeyGUID)); |
| 133 Vector<uint8_t, sha1HashSize> hash; | 133 Vector<uint8_t, sha1HashSize> hash; |
| 134 sha1.computeHash(hash); | 134 sha1.computeHash(hash); |
| 135 return base64Encode(reinterpret_cast<const char*>(hash.data()), sha1HashSize
); | 135 return base64Encode(reinterpret_cast<const char*>(hash.data()), sha1HashSize
); |
| 136 } | 136 } |
| 137 | 137 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 } | 585 } |
| 586 if (!match) { | 586 if (!match) { |
| 587 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-
WebSocket-Protocol' header but no response is received"); | 587 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-
WebSocket-Protocol' header but no response is received"); |
| 588 return false; | 588 return false; |
| 589 } | 589 } |
| 590 } | 590 } |
| 591 return true; | 591 return true; |
| 592 } | 592 } |
| 593 | 593 |
| 594 } // namespace WebCore | 594 } // namespace WebCore |
| OLD | NEW |