Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* |
michael@0 | 2 | Copyright (c) 2007, Adobe Systems, Incorporated |
michael@0 | 3 | All rights reserved. |
michael@0 | 4 | |
michael@0 | 5 | Redistribution and use in source and binary forms, with or without |
michael@0 | 6 | modification, are permitted provided that the following conditions are |
michael@0 | 7 | met: |
michael@0 | 8 | |
michael@0 | 9 | * Redistributions of source code must retain the above copyright |
michael@0 | 10 | notice, this list of conditions and the following disclaimer. |
michael@0 | 11 | |
michael@0 | 12 | * Redistributions in binary form must reproduce the above copyright |
michael@0 | 13 | notice, this list of conditions and the following disclaimer in the |
michael@0 | 14 | documentation and/or other materials provided with the distribution. |
michael@0 | 15 | |
michael@0 | 16 | * Neither the name of Adobe Systems, Network Resonance nor the names of its |
michael@0 | 17 | contributors may be used to endorse or promote products derived from |
michael@0 | 18 | this software without specific prior written permission. |
michael@0 | 19 | |
michael@0 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
michael@0 | 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@0 | 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@0 | 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
michael@0 | 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
michael@0 | 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 31 | */ |
michael@0 | 32 | |
michael@0 | 33 | |
michael@0 | 34 | #ifndef _stun_build_h |
michael@0 | 35 | #define _stun_build_h |
michael@0 | 36 | |
michael@0 | 37 | #include "stun.h" |
michael@0 | 38 | |
michael@0 | 39 | #define NR_STUN_MODE_STUN 1 |
michael@0 | 40 | #ifdef USE_STUND_0_96 |
michael@0 | 41 | #define NR_STUN_MODE_STUND_0_96 2 /* backwards compatibility mode */ |
michael@0 | 42 | #endif /* USE_STUND_0_96 */ |
michael@0 | 43 | int nr_stun_form_request_or_indication(int mode, int msg_type, nr_stun_message **msg); |
michael@0 | 44 | |
michael@0 | 45 | typedef struct nr_stun_client_stun_binding_request_params_ { |
michael@0 | 46 | char *username; |
michael@0 | 47 | Data *password; |
michael@0 | 48 | char *nonce; |
michael@0 | 49 | char *realm; |
michael@0 | 50 | } nr_stun_client_stun_binding_request_params; |
michael@0 | 51 | |
michael@0 | 52 | int nr_stun_build_req_lt_auth(nr_stun_client_stun_binding_request_params *params, nr_stun_message **msg); |
michael@0 | 53 | int nr_stun_build_req_st_auth(nr_stun_client_stun_binding_request_params *params, nr_stun_message **msg); |
michael@0 | 54 | int nr_stun_build_req_no_auth(nr_stun_client_stun_binding_request_params *params, nr_stun_message **msg); |
michael@0 | 55 | |
michael@0 | 56 | |
michael@0 | 57 | typedef struct nr_stun_client_stun_keepalive_params_ { |
michael@0 | 58 | #if defined(WIN32) || defined(__clang__) |
michael@0 | 59 | // VC++ and clang give error and warning respectively if no members |
michael@0 | 60 | int dummy; |
michael@0 | 61 | #endif |
michael@0 | 62 | } nr_stun_client_stun_keepalive_params; |
michael@0 | 63 | |
michael@0 | 64 | int nr_stun_build_keepalive(nr_stun_client_stun_keepalive_params *params, nr_stun_message **msg); |
michael@0 | 65 | |
michael@0 | 66 | |
michael@0 | 67 | #ifdef USE_STUND_0_96 |
michael@0 | 68 | typedef struct nr_stun_client_stun_binding_request_stund_0_96_params_ { |
michael@0 | 69 | #ifdef WIN32 // silly VC++ gives error if no members |
michael@0 | 70 | int dummy; |
michael@0 | 71 | #endif |
michael@0 | 72 | } nr_stun_client_stun_binding_request_stund_0_96_params; |
michael@0 | 73 | |
michael@0 | 74 | int nr_stun_build_req_stund_0_96(nr_stun_client_stun_binding_request_stund_0_96_params *params, nr_stun_message **msg); |
michael@0 | 75 | #endif /* USE_STUND_0_96 */ |
michael@0 | 76 | |
michael@0 | 77 | |
michael@0 | 78 | #ifdef USE_ICE |
michael@0 | 79 | typedef struct nr_stun_client_ice_use_candidate_params_ { |
michael@0 | 80 | char *username; |
michael@0 | 81 | Data password; |
michael@0 | 82 | UINT4 priority; |
michael@0 | 83 | UINT8 tiebreaker; |
michael@0 | 84 | } nr_stun_client_ice_use_candidate_params; |
michael@0 | 85 | |
michael@0 | 86 | int nr_stun_build_use_candidate(nr_stun_client_ice_use_candidate_params *params, nr_stun_message **msg); |
michael@0 | 87 | |
michael@0 | 88 | |
michael@0 | 89 | typedef struct nr_stun_client_ice_binding_request_params_ { |
michael@0 | 90 | char *username; |
michael@0 | 91 | Data password; |
michael@0 | 92 | UINT4 priority; |
michael@0 | 93 | int control; |
michael@0 | 94 | #define NR_ICE_CONTROLLING 1 |
michael@0 | 95 | #define NR_ICE_CONTROLLED 2 |
michael@0 | 96 | UINT8 tiebreaker; |
michael@0 | 97 | } nr_stun_client_ice_binding_request_params; |
michael@0 | 98 | |
michael@0 | 99 | int nr_stun_build_req_ice(nr_stun_client_ice_binding_request_params *params, nr_stun_message **msg); |
michael@0 | 100 | #endif /* USE_ICE */ |
michael@0 | 101 | |
michael@0 | 102 | |
michael@0 | 103 | typedef struct nr_stun_client_auth_params_ { |
michael@0 | 104 | char authenticate; |
michael@0 | 105 | char *username; |
michael@0 | 106 | char *realm; |
michael@0 | 107 | char *nonce; |
michael@0 | 108 | Data password; |
michael@0 | 109 | } nr_stun_client_auth_params; |
michael@0 | 110 | |
michael@0 | 111 | #ifdef USE_TURN |
michael@0 | 112 | typedef struct nr_stun_client_allocate_request_params_ { |
michael@0 | 113 | UINT4 lifetime_secs; |
michael@0 | 114 | } nr_stun_client_allocate_request_params; |
michael@0 | 115 | |
michael@0 | 116 | int nr_stun_build_allocate_request(nr_stun_client_auth_params *auth, nr_stun_client_allocate_request_params *params, nr_stun_message **msg); |
michael@0 | 117 | |
michael@0 | 118 | |
michael@0 | 119 | typedef struct nr_stun_client_refresh_request_params_ { |
michael@0 | 120 | UINT4 lifetime_secs; |
michael@0 | 121 | } nr_stun_client_refresh_request_params; |
michael@0 | 122 | |
michael@0 | 123 | int nr_stun_build_refresh_request(nr_stun_client_auth_params *auth, nr_stun_client_refresh_request_params *params, nr_stun_message **msg); |
michael@0 | 124 | |
michael@0 | 125 | |
michael@0 | 126 | |
michael@0 | 127 | typedef struct nr_stun_client_permission_request_params_ { |
michael@0 | 128 | nr_transport_addr remote_addr; |
michael@0 | 129 | } nr_stun_client_permission_request_params; |
michael@0 | 130 | |
michael@0 | 131 | int nr_stun_build_permission_request(nr_stun_client_auth_params *auth, nr_stun_client_permission_request_params *params, nr_stun_message **msg); |
michael@0 | 132 | |
michael@0 | 133 | |
michael@0 | 134 | typedef struct nr_stun_client_send_indication_params_ { |
michael@0 | 135 | nr_transport_addr remote_addr; |
michael@0 | 136 | Data data; |
michael@0 | 137 | } nr_stun_client_send_indication_params; |
michael@0 | 138 | |
michael@0 | 139 | int nr_stun_build_send_indication(nr_stun_client_send_indication_params *params, nr_stun_message **msg); |
michael@0 | 140 | |
michael@0 | 141 | typedef struct nr_stun_client_data_indication_params_ { |
michael@0 | 142 | nr_transport_addr remote_addr; |
michael@0 | 143 | Data data; |
michael@0 | 144 | } nr_stun_client_data_indication_params; |
michael@0 | 145 | |
michael@0 | 146 | int nr_stun_build_data_indication(nr_stun_client_data_indication_params *params, nr_stun_message **msg); |
michael@0 | 147 | #endif /* USE_TURN */ |
michael@0 | 148 | |
michael@0 | 149 | int nr_stun_form_success_response(nr_stun_message *req, nr_transport_addr *from, Data *password, nr_stun_message *res); |
michael@0 | 150 | void nr_stun_form_error_response(nr_stun_message *request, nr_stun_message* response, int number, char* msg); |
michael@0 | 151 | int nr_stun_compute_lt_message_integrity_password(const char *username, const char *realm, |
michael@0 | 152 | Data *password, Data *hmac_key); |
michael@0 | 153 | |
michael@0 | 154 | #endif |