Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: remoting/protocol/secure_p2p_socket.h

Issue 7038053: Implementation of SecureP2PSocket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test for retry Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 // Construct a secured P2P socket using |socket| as the underlying
40 // socket. Ownership of |socket| is transfered to this object.
41 SecureP2PSocket(net::Socket* socket, const std::string& ice_key);
42
43 // Socket implementation.
44 virtual int Read(net::IOBuffer* buf, int buf_len,
45 net::CompletionCallback* callback);
46 virtual int Write(net::IOBuffer* buf, int buf_len,
47 net::CompletionCallback* callback);
48 virtual bool SetReceiveBufferSize(int32 size);
49 virtual bool SetSendBufferSize(int32 size);
50
51 private:
52 int ReadInternal();
53 void ReadDone(int err);
54 void WriteDone(int err);
55 int DecryptBuffer(int size);
56
57 scoped_ptr<net::Socket> socket_;
58
59 uint64 write_seq_;
60 uint64 read_seq_;
61
62 net::CompletionCallback* user_read_callback_;
63 scoped_refptr<net::IOBuffer> user_read_buf_;
64 int user_read_buf_len_;
65
66 net::CompletionCallback* user_write_callback_;
67 int user_write_buf_len_;
68
69 scoped_ptr<net::CompletionCallback> read_callback_;
70 scoped_refptr<net::IOBufferWithSize> read_buf_;
71
72 scoped_ptr<net::CompletionCallback> write_callback_;
73
74 scoped_ptr<crypto::SymmetricKey> mask_key_;
75 crypto::HMAC msg_hasher_;
76 crypto::Encryptor encryptor_;
77
78 DISALLOW_COPY_AND_ASSIGN(SecureP2PSocket);
79 };
80
81 } // namespace protocol
82 } // namespace remoting
83
84 #endif // REMOTING_PROTOCOL_SOCKET_P2P_SOCKET_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/protocol/secure_p2p_socket.cc » ('j') | remoting/protocol/secure_p2p_socket.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698