media/webrtc/signaling/src/mediapipeline/SrtpFlow.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 // Original author: ekr@rtfm.com
     7 #ifndef srtpflow_h__
     8 #define srtpflow_h__
    10 #include "ssl.h"
    11 #include "sslproto.h"
    12 #include "mozilla/RefPtr.h"
    13 #include "nsISupportsImpl.h"
    15 typedef struct srtp_policy_t srtp_policy_t;
    16 typedef struct srtp_ctx_t *srtp_t;
    17 typedef struct srtp_event_data_t srtp_event_data_t;
    19 namespace mozilla {
    21 #define SRTP_MASTER_KEY_LENGTH 16
    22 #define SRTP_MASTER_SALT_LENGTH 14
    23 #define SRTP_TOTAL_KEY_LENGTH (SRTP_MASTER_KEY_LENGTH + SRTP_MASTER_SALT_LENGTH)
    25 // For some reason libsrtp increases packet size by > 12 for RTCP even though
    26 // the doc claims otherwise.
    27 #define SRTP_MAX_EXPANSION 20
    30 class SrtpFlow {
    31  public:
    32   ~SrtpFlow();
    35   static mozilla::RefPtr<SrtpFlow> Create(int cipher_suite,
    36                                           bool inbound,
    37                                           const void *key,
    38                                           size_t key_len);
    40   nsresult ProtectRtp(void *in, int in_len,
    41                       int max_len, int *out_len);
    42   nsresult UnprotectRtp(void *in, int in_len,
    43                         int max_len, int *out_len);
    44   nsresult ProtectRtcp(void *in, int in_len,
    45                        int max_len, int *out_len);
    46   nsresult UnprotectRtcp(void *in, int in_len,
    47                          int max_len, int *out_len);
    49   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SrtpFlow)
    51   static void srtp_event_handler(srtp_event_data_t *data);
    54  private:
    55   SrtpFlow() : session_(nullptr) {}
    57   nsresult CheckInputs(bool protect, void *in, int in_len,
    58                        int max_len, int *out_len);
    60   static nsresult Init();
    61   static bool initialized;  // Was libsrtp initialized? Only happens once.
    63   srtp_t session_;
    64 };
    66 }  // End of namespace
    67 #endif

mercurial