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

Side by Side Diff: runtime/bin/secure_socket_boringssl.cc

Issue 1852783003: Implements remaining SecurityContext calls for iOS (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 8 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
« no previous file with comments | « runtime/bin/secure_socket_boringssl.h ('k') | runtime/bin/secure_socket_ios.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED) 5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(TARGET_OS_ANDROID) || \ 8 #if defined(TARGET_OS_ANDROID) || \
9 defined(TARGET_OS_LINUX) || \ 9 defined(TARGET_OS_LINUX) || \
10 defined(TARGET_OS_WINDOWS) 10 defined(TARGET_OS_WINDOWS)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 reinterpret_cast<intptr_t*>(&filter))); 114 reinterpret_cast<intptr_t*>(&filter)));
115 return filter; 115 return filter;
116 } 116 }
117 117
118 118
119 static void DeleteFilter( 119 static void DeleteFilter(
120 void* isolate_data, 120 void* isolate_data,
121 Dart_WeakPersistentHandle handle, 121 Dart_WeakPersistentHandle handle,
122 void* context_pointer) { 122 void* context_pointer) {
123 SSLFilter* filter = reinterpret_cast<SSLFilter*>(context_pointer); 123 SSLFilter* filter = reinterpret_cast<SSLFilter*>(context_pointer);
124 delete filter; 124 filter->Release();
125 } 125 }
126 126
127 127
128 static Dart_Handle SetFilter(Dart_NativeArguments args, SSLFilter* filter) { 128 static Dart_Handle SetFilter(Dart_NativeArguments args, SSLFilter* filter) {
129 ASSERT(filter != NULL); 129 ASSERT(filter != NULL);
130 Dart_Handle dart_this = Dart_GetNativeArgument(args, 0); 130 Dart_Handle dart_this = Dart_GetNativeArgument(args, 0);
131 RETURN_IF_ERROR(dart_this); 131 RETURN_IF_ERROR(dart_this);
132 ASSERT(Dart_IsInstance(dart_this)); 132 ASSERT(Dart_IsInstance(dart_this));
133 Dart_Handle err = Dart_SetNativeInstanceField( 133 Dart_Handle err = Dart_SetNativeInstanceField(
134 dart_this, 134 dart_this,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 SSL* ssl, 200 SSL* ssl,
201 SSL_CTX* context, 201 SSL_CTX* context,
202 bool is_server); 202 bool is_server);
203 203
204 204
205 void FUNCTION_NAME(SecureSocket_Init)(Dart_NativeArguments args) { 205 void FUNCTION_NAME(SecureSocket_Init)(Dart_NativeArguments args) {
206 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0)); 206 Dart_Handle dart_this = ThrowIfError(Dart_GetNativeArgument(args, 0));
207 SSLFilter* filter = new SSLFilter(); 207 SSLFilter* filter = new SSLFilter();
208 Dart_Handle err = SetFilter(args, filter); 208 Dart_Handle err = SetFilter(args, filter);
209 if (Dart_IsError(err)) { 209 if (Dart_IsError(err)) {
210 delete filter; 210 filter->Release();
211 Dart_PropagateError(err); 211 Dart_PropagateError(err);
212 } 212 }
213 err = filter->Init(dart_this); 213 err = filter->Init(dart_this);
214 if (Dart_IsError(err)) { 214 if (Dart_IsError(err)) {
215 // The finalizer was set up by SetFilter. It will delete `filter` if there 215 // The finalizer was set up by SetFilter. It will delete `filter` if there
216 // is an error. 216 // is an error.
217 filter->Destroy(); 217 filter->Destroy();
218 Dart_PropagateError(err); 218 Dart_PropagateError(err);
219 } 219 }
220 } 220 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 317
318 318
319 void FUNCTION_NAME(SecureSocket_PeerCertificate) 319 void FUNCTION_NAME(SecureSocket_PeerCertificate)
320 (Dart_NativeArguments args) { 320 (Dart_NativeArguments args) {
321 Dart_Handle cert = ThrowIfError(GetFilter(args)->PeerCertificate()); 321 Dart_Handle cert = ThrowIfError(GetFilter(args)->PeerCertificate());
322 Dart_SetReturnValue(args, cert); 322 Dart_SetReturnValue(args, cert);
323 } 323 }
324 324
325 325
326 void FUNCTION_NAME(SecureSocket_FilterPointer)(Dart_NativeArguments args) { 326 void FUNCTION_NAME(SecureSocket_FilterPointer)(Dart_NativeArguments args) {
327 intptr_t filter_pointer = reinterpret_cast<intptr_t>(GetFilter(args)); 327 SSLFilter* filter = GetFilter(args);
328 // This filter pointer is passed to the IO Service thread. The IO Service
329 // thread must Release() the pointer when it is done with it.
330 filter->Retain();
331 intptr_t filter_pointer = reinterpret_cast<intptr_t>(filter);
328 Dart_SetReturnValue(args, Dart_NewInteger(filter_pointer)); 332 Dart_SetReturnValue(args, Dart_NewInteger(filter_pointer));
329 } 333 }
330 334
331 335
332 static void ReleaseCertificate( 336 static void ReleaseCertificate(
333 void* isolate_data, 337 void* isolate_data,
334 Dart_WeakPersistentHandle handle, 338 Dart_WeakPersistentHandle handle,
335 void* context_pointer) { 339 void* context_pointer) {
336 X509* cert = reinterpret_cast<X509*>(context_pointer); 340 X509* cert = reinterpret_cast<X509*>(context_pointer);
337 X509_free(cert); 341 X509_free(cert);
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 * write to the free space and end pointer of input buffers, and read from 1083 * write to the free space and end pointer of input buffers, and read from
1080 * the data space of output buffers, and modify the start pointer. 1084 * the data space of output buffers, and modify the start pointer.
1081 * 1085 *
1082 * When ProcessFilter returns, the Dart thread is responsible for combining 1086 * When ProcessFilter returns, the Dart thread is responsible for combining
1083 * the updated pointers from Dart and C++, to make the new valid state of 1087 * the updated pointers from Dart and C++, to make the new valid state of
1084 * the circular buffer. 1088 * the circular buffer.
1085 */ 1089 */
1086 CObject* SSLFilter::ProcessFilterRequest(const CObjectArray& request) { 1090 CObject* SSLFilter::ProcessFilterRequest(const CObjectArray& request) {
1087 CObjectIntptr filter_object(request[0]); 1091 CObjectIntptr filter_object(request[0]);
1088 SSLFilter* filter = reinterpret_cast<SSLFilter*>(filter_object.Value()); 1092 SSLFilter* filter = reinterpret_cast<SSLFilter*>(filter_object.Value());
1093 RefCntReleaseScope<SSLFilter> rs(filter);
1094
1089 bool in_handshake = CObjectBool(request[1]).Value(); 1095 bool in_handshake = CObjectBool(request[1]).Value();
1090 int starts[SSLFilter::kNumBuffers]; 1096 int starts[SSLFilter::kNumBuffers];
1091 int ends[SSLFilter::kNumBuffers]; 1097 int ends[SSLFilter::kNumBuffers];
1092 for (int i = 0; i < SSLFilter::kNumBuffers; ++i) { 1098 for (int i = 0; i < SSLFilter::kNumBuffers; ++i) {
1093 starts[i] = CObjectInt32(request[2 * i + 2]).Value(); 1099 starts[i] = CObjectInt32(request[2 * i + 2]).Value();
1094 ends[i] = CObjectInt32(request[2 * i + 3]).Value(); 1100 ends[i] = CObjectInt32(request[2 * i + 3]).Value();
1095 } 1101 }
1096 1102
1097 if (filter->ProcessAllBuffers(starts, ends, in_handshake)) { 1103 if (filter->ProcessAllBuffers(starts, ends, in_handshake)) {
1098 CObjectArray* result = new CObjectArray( 1104 CObjectArray* result = new CObjectArray(
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 return bytes_processed; 1684 return bytes_processed;
1679 } 1685 }
1680 1686
1681 } // namespace bin 1687 } // namespace bin
1682 } // namespace dart 1688 } // namespace dart
1683 1689
1684 #endif // defined(TARGET_OS_LINUX) 1690 #endif // defined(TARGET_OS_LINUX)
1685 1691
1686 #endif // !defined(DART_IO_DISABLED) && 1692 #endif // !defined(DART_IO_DISABLED) &&
1687 // !defined(DART_IO_SECURE_SOCKET_DISABLED) 1693 // !defined(DART_IO_SECURE_SOCKET_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/secure_socket_boringssl.h ('k') | runtime/bin/secure_socket_ios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698