Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Implement a secure P2P socket according to the W3C spec | |
| 6 // | |
| 7 // "Video conferencing and peer-to-peer communication" | |
| 8 // http://www.whatwg.org/specs/web-apps/current-work/complete/video-conferencing -and-peer-to-peer-communication.html#peer-to-peer-connections | |
| 9 // | |
| 10 // This class operates on an establish socket to perform encryption for P2P | |
| 11 // connection. This class does not perform chunking for outgoing buffers, all | |
| 12 // outgoing buffers have to be 44 bytes smaller than MTU to allow space for | |
| 13 // header to support encryption. | |
| 14 | |
| 15 #ifndef REMOTING_PROTOCOL_SECURE_P2P_SOCKET_H_ | |
| 16 #define REMOTING_PROTOCOL_SOCKET_P2P_SOCKET_H_ | |
| 17 | |
| 18 #include <string> | |
| 19 | |
| 20 #include "base/memory/ref_counted.h" | |
| 21 #include "base/memory/scoped_ptr.h" | |
| 22 #include "crypto/encryptor.h" | |
| 23 #include "crypto/hmac.h" | |
| 24 #include "net/socket/socket.h" | |
| 25 | |
| 26 namespace crypto { | |
| 27 class SymmetricKey; | |
| 28 } // namespace crypto | |
| 29 | |
| 30 namespace net { | |
| 31 class IOBufferWithSize; | |
| 32 } // namespace net | |
| 33 | |
| 34 namespace remoting { | |
| 35 namespace protocol { | |
| 36 | |
| 37 class SecureP2PSocket : public net::Socket { | |
| 38 public: | |
| 39 SecureP2PSocket(net::Socket* socket, const std::string& ice_key); | |
| 40 | |
| 41 // Socket implementation. | |
| 42 virtual int Read(net::IOBuffer* buf, int buf_len, | |
| 43 net::CompletionCallback* callback); | |
| 44 virtual int Write(net::IOBuffer* buf, int buf_len, | |
| 45 net::CompletionCallback* callback); | |
| 46 virtual bool SetReceiveBufferSize(int32 size); | |
| 47 virtual bool SetSendBufferSize(int32 size); | |
| 48 | |
| 49 private: | |
| 50 int ReadInternal(); | |
| 51 void ReadDone(int err); | |
| 52 void WriteDone(int err); | |
| 53 int DecryptBuffer(int size); | |
| 54 | |
| 55 net::Socket* socket_; | |
|
Sergey Ulanov
2011/06/22 23:51:35
SSL socket objects own underlying physical sockets
Alpha Left Google
2011/06/23 21:53:01
Done.
| |
| 56 | |
| 57 uint64 write_seq_; | |
| 58 uint64 read_seq_; | |
| 59 | |
| 60 net::CompletionCallback* user_read_callback_; | |
| 61 scoped_refptr<net::IOBuffer> user_read_buf_; | |
| 62 int user_read_buf_len_; | |
| 63 | |
| 64 net::CompletionCallback* user_write_callback_; | |
| 65 int user_write_buf_len_; | |
| 66 | |
| 67 scoped_ptr<net::CompletionCallback> read_callback_; | |
| 68 scoped_refptr<net::IOBufferWithSize> read_buf_; | |
| 69 | |
| 70 scoped_ptr<net::CompletionCallback> write_callback_; | |
| 71 | |
| 72 scoped_ptr<crypto::SymmetricKey> mask_key_; | |
| 73 crypto::HMAC msg_hasher_; | |
| 74 crypto::Encryptor encryptor_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(SecureP2PSocket); | |
| 77 }; | |
| 78 | |
| 79 } // namespace protocol | |
| 80 } // namespace remoting | |
| 81 | |
| 82 #endif // REMOTING_PROTOCOL_SOCKET_P2P_SOCKET_H_ | |
| OLD | NEW |