Changeset 94082 in vbox for trunk/src/libs/openssl-3.0.1/crypto/async
- Timestamp:
- Mar 3, 2022 7:17:34 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 150325
- Location:
- trunk/src/libs/openssl-3.0.1
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/openssl-3.0.1
- Property svn:mergeinfo
-
old new 12 12 /vendor/openssl/1.1.1c:131722-131725 13 13 /vendor/openssl/1.1.1k:145841-145843 14 /vendor/openssl/3.0.1:150323-150324 15 /vendor/openssl/current:147554-150322
-
- Property svn:mergeinfo
-
trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_null.c
r91772 r94082 2 2 * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at -
trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_null.h
r91772 r94082 2 2 * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at -
trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_posix.c
r91772 r94082 1 1 /* 2 * Copyright 2015-20 16The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 35 35 int async_fibre_makecontext(async_fibre *fibre) 36 36 { 37 #ifndef USE_SWAPCONTEXT 37 38 fibre->env_init = 0; 39 #endif 38 40 if (getcontext(&fibre->fibre) == 0) { 39 41 fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE); -
trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_posix.h
r91772 r94082 1 1 /* 2 * Copyright 2015-20 18The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 26 26 # define ASYNC_ARCH 27 27 28 # ifdef __CET__ 29 /* 30 * When Intel CET is enabled, makecontext will create a different 31 * shadow stack for each context. async_fibre_swapcontext cannot 32 * use _longjmp. It must call swapcontext to swap shadow stack as 33 * well as normal stack. 34 */ 35 # define USE_SWAPCONTEXT 36 # endif 28 37 # include <ucontext.h> 29 # include <setjmp.h> 38 # ifndef USE_SWAPCONTEXT 39 # include <setjmp.h> 40 # endif 30 41 31 42 typedef struct async_fibre_st { 32 43 ucontext_t fibre; 44 # ifndef USE_SWAPCONTEXT 33 45 jmp_buf env; 34 46 int env_init; 47 # endif 35 48 } async_fibre; 36 49 37 50 static ossl_inline int async_fibre_swapcontext(async_fibre *o, async_fibre *n, int r) 38 51 { 52 # ifdef USE_SWAPCONTEXT 53 swapcontext(&o->fibre, &n->fibre); 54 # else 39 55 o->env_init = 1; 40 56 … … 45 61 setcontext(&n->fibre); 46 62 } 63 # endif 47 64 48 65 return 1; -
trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_win.c
r91772 r94082 1 1 /* 2 * Copyright 2015-20 16The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 35 35 int async_fibre_init_dispatcher(async_fibre *fibre) 36 36 { 37 # if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 38 fibre->fibre = ConvertThreadToFiberEx(NULL, FIBER_FLAG_FLOAT_SWITCH); 39 # else 37 40 fibre->fibre = ConvertThreadToFiber(NULL); 41 # endif 38 42 if (fibre->fibre == NULL) { 39 43 fibre->converted = 0; -
trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_win.h
r91772 r94082 1 1 /* 2 * Copyright 2015-20 16The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 27 27 # define async_fibre_swapcontext(o,n,r) \ 28 28 (SwitchToFiber((n)->fibre), 1) 29 # define async_fibre_makecontext(c) \ 29 30 # if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 31 # define async_fibre_makecontext(c) \ 32 ((c)->fibre = CreateFiberEx(0, 0, FIBER_FLAG_FLOAT_SWITCH, \ 33 async_start_func_win, 0)) 34 # else 35 # define async_fibre_makecontext(c) \ 30 36 ((c)->fibre = CreateFiber(0, async_start_func_win, 0)) 37 # endif 38 31 39 # define async_fibre_free(f) (DeleteFiber((f)->fibre)) 32 40 -
trunk/src/libs/openssl-3.0.1/crypto/async/async.c
r91772 r94082 1 1 /* 2 * Copyright 2015-20 18The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 31 31 static CRYPTO_THREAD_LOCAL poolkey; 32 32 33 static void async_delete_thread_state(void *arg); 34 33 35 static async_ctx *async_ctx_new(void) 34 36 { 35 37 async_ctx *nctx; 36 38 37 if (!ossl_init_thread_start( OPENSSL_INIT_THREAD_ASYNC))39 if (!ossl_init_thread_start(NULL, NULL, async_delete_thread_state)) 38 40 return NULL; 39 41 40 42 nctx = OPENSSL_malloc(sizeof(*nctx)); 41 43 if (nctx == NULL) { 42 ASYNCerr(ASYNC_F_ASYNC_CTX_NEW, ERR_R_MALLOC_FAILURE);44 ERR_raise(ERR_LIB_ASYNC, ERR_R_MALLOC_FAILURE); 43 45 goto err; 44 46 } … … 82 84 job = OPENSSL_zalloc(sizeof(*job)); 83 85 if (job == NULL) { 84 ASYNCerr(ASYNC_F_ASYNC_JOB_NEW, ERR_R_MALLOC_FAILURE);86 ERR_raise(ERR_LIB_ASYNC, ERR_R_MALLOC_FAILURE); 85 87 return NULL; 86 88 } … … 137 139 138 140 pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey); 141 if (pool == NULL) { 142 ERR_raise(ERR_LIB_ASYNC, ERR_R_INTERNAL_ERROR); 143 return; 144 } 139 145 OPENSSL_free(job->funcargs); 140 146 job->funcargs = NULL; … … 147 153 async_ctx *ctx = async_get_ctx(); 148 154 155 if (ctx == NULL) { 156 ERR_raise(ERR_LIB_ASYNC, ERR_R_INTERNAL_ERROR); 157 return; 158 } 149 159 while (1) { 150 160 /* Run the job */ … … 160 170 * much about it 161 171 */ 162 ASYNCerr(ASYNC_F_ASYNC_START_FUNC, ASYNC_R_FAILED_TO_SWAP_CONTEXT);172 ERR_raise(ERR_LIB_ASYNC, ASYNC_R_FAILED_TO_SWAP_CONTEXT); 163 173 } 164 174 } … … 169 179 { 170 180 async_ctx *ctx; 181 OSSL_LIB_CTX *libctx; 171 182 172 183 if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) … … 179 190 return ASYNC_ERR; 180 191 181 if (*job )192 if (*job != NULL) 182 193 ctx->currjob = *job; 183 194 … … 201 212 202 213 if (ctx->currjob->status == ASYNC_JOB_PAUSED) { 214 if (*job == NULL) 215 return ASYNC_ERR; 203 216 ctx->currjob = *job; 217 218 /* 219 * Restore the default libctx to what it was the last time the 220 * fibre ran 221 */ 222 libctx = OSSL_LIB_CTX_set0_default(ctx->currjob->libctx); 223 if (libctx == NULL) { 224 /* Failed to set the default context */ 225 ERR_raise(ERR_LIB_ASYNC, ERR_R_INTERNAL_ERROR); 226 goto err; 227 } 204 228 /* Resume previous job */ 205 229 if (!async_fibre_swapcontext(&ctx->dispatcher, 206 230 &ctx->currjob->fibrectx, 1)) { 207 ASYNCerr(ASYNC_F_ASYNC_START_JOB,208 231 ctx->currjob->libctx = OSSL_LIB_CTX_set0_default(libctx); 232 ERR_raise(ERR_LIB_ASYNC, ASYNC_R_FAILED_TO_SWAP_CONTEXT); 209 233 goto err; 210 234 } 235 /* 236 * In case the fibre changed the default libctx we set it back 237 * again to what it was originally, and remember what it had 238 * been changed to. 239 */ 240 ctx->currjob->libctx = OSSL_LIB_CTX_set0_default(libctx); 211 241 continue; 212 242 } 213 243 214 244 /* Should not happen */ 215 ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_INTERNAL_ERROR);245 ERR_raise(ERR_LIB_ASYNC, ERR_R_INTERNAL_ERROR); 216 246 async_release_job(ctx->currjob); 217 247 ctx->currjob = NULL; … … 227 257 ctx->currjob->funcargs = OPENSSL_malloc(size); 228 258 if (ctx->currjob->funcargs == NULL) { 229 ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);259 ERR_raise(ERR_LIB_ASYNC, ERR_R_MALLOC_FAILURE); 230 260 async_release_job(ctx->currjob); 231 261 ctx->currjob = NULL; … … 239 269 ctx->currjob->func = func; 240 270 ctx->currjob->waitctx = wctx; 271 libctx = ossl_lib_ctx_get_concrete(NULL); 241 272 if (!async_fibre_swapcontext(&ctx->dispatcher, 242 273 &ctx->currjob->fibrectx, 1)) { 243 ASYNCerr(ASYNC_F_ASYNC_START_JOB, ASYNC_R_FAILED_TO_SWAP_CONTEXT);274 ERR_raise(ERR_LIB_ASYNC, ASYNC_R_FAILED_TO_SWAP_CONTEXT); 244 275 goto err; 245 276 } 277 /* 278 * In case the fibre changed the default libctx we set it back again 279 * to what it was, and remember what it had been changed to. 280 */ 281 ctx->currjob->libctx = OSSL_LIB_CTX_set0_default(libctx); 246 282 } 247 283 … … 273 309 if (!async_fibre_swapcontext(&job->fibrectx, 274 310 &ctx->dispatcher, 1)) { 275 ASYNCerr(ASYNC_F_ASYNC_PAUSE_JOB, ASYNC_R_FAILED_TO_SWAP_CONTEXT);311 ERR_raise(ERR_LIB_ASYNC, ASYNC_R_FAILED_TO_SWAP_CONTEXT); 276 312 return 0; 277 313 } … … 286 322 ASYNC_JOB *job; 287 323 288 if ( !pool || !pool->jobs)324 if (pool == NULL || pool->jobs == NULL) 289 325 return; 290 326 … … 320 356 321 357 if (init_size > max_size) { 322 ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);323 return 0; 324 } 325 326 if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) 327 return 0; 328 329 if (!ossl_init_thread_start( OPENSSL_INIT_THREAD_ASYNC))358 ERR_raise(ERR_LIB_ASYNC, ASYNC_R_INVALID_POOL_SIZE); 359 return 0; 360 } 361 362 if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) 363 return 0; 364 365 if (!ossl_init_thread_start(NULL, NULL, async_delete_thread_state)) 330 366 return 0; 331 367 332 368 pool = OPENSSL_zalloc(sizeof(*pool)); 333 369 if (pool == NULL) { 334 ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);370 ERR_raise(ERR_LIB_ASYNC, ERR_R_MALLOC_FAILURE); 335 371 return 0; 336 372 } … … 338 374 pool->jobs = sk_ASYNC_JOB_new_reserve(NULL, init_size); 339 375 if (pool->jobs == NULL) { 340 ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);376 ERR_raise(ERR_LIB_ASYNC, ERR_R_MALLOC_FAILURE); 341 377 OPENSSL_free(pool); 342 378 return 0; … … 363 399 pool->curr_size = curr_size; 364 400 if (!CRYPTO_THREAD_set_local(&poolkey, pool)) { 365 ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);401 ERR_raise(ERR_LIB_ASYNC, ASYNC_R_FAILED_TO_SET_POOL); 366 402 goto err; 367 403 } … … 375 411 } 376 412 377 void async_delete_thread_state(void)413 static void async_delete_thread_state(void *arg) 378 414 { 379 415 async_pool *pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey); … … 394 430 return; 395 431 396 async_delete_thread_state( );432 async_delete_thread_state(NULL); 397 433 } 398 434 -
trunk/src/libs/openssl-3.0.1/crypto/async/async_err.c
r91772 r94082 1 1 /* 2 2 * Generated by util/mkerr.pl DO NOT EDIT 3 * Copyright 1995-20 18The OpenSSL Project Authors. All Rights Reserved.3 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. 4 4 * 5 * Licensed under the OpenSSL license(the "License"). You may not use5 * Licensed under the Apache License 2.0 (the "License"). You may not use 6 6 * this file except in compliance with the License. You can obtain a copy 7 7 * in the file LICENSE in the source distribution or at … … 11 11 #include <openssl/err.h> 12 12 #include <openssl/asyncerr.h> 13 #include "crypto/asyncerr.h" 13 14 14 15 #ifndef OPENSSL_NO_ERR 15 16 static const ERR_STRING_DATA ASYNC_str_functs[] = {17 {ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_CTX_NEW, 0), "async_ctx_new"},18 {ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_INIT_THREAD, 0),19 "ASYNC_init_thread"},20 {ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_JOB_NEW, 0), "async_job_new"},21 {ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_PAUSE_JOB, 0), "ASYNC_pause_job"},22 {ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_START_FUNC, 0), "async_start_func"},23 {ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_START_JOB, 0), "ASYNC_start_job"},24 {ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD, 0),25 "ASYNC_WAIT_CTX_set_wait_fd"},26 {0, NULL}27 };28 16 29 17 static const ERR_STRING_DATA ASYNC_str_reasons[] = { … … 40 28 #endif 41 29 42 int ERR_load_ASYNC_strings(void)30 int ossl_err_load_ASYNC_strings(void) 43 31 { 44 32 #ifndef OPENSSL_NO_ERR 45 if (ERR_func_error_string(ASYNC_str_functs[0].error) == NULL) { 46 ERR_load_strings_const(ASYNC_str_functs); 33 if (ERR_reason_error_string(ASYNC_str_reasons[0].error) == NULL) 47 34 ERR_load_strings_const(ASYNC_str_reasons); 48 }49 35 #endif 50 36 return 1; -
trunk/src/libs/openssl-3.0.1/crypto/async/async_local.h
r91772 r94082 1 1 /* 2 * Copyright 2015-20 16The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 48 48 int status; 49 49 ASYNC_WAIT_CTX *waitctx; 50 OSSL_LIB_CTX *libctx; 50 51 }; 51 52 … … 64 65 size_t numadd; 65 66 size_t numdel; 67 ASYNC_callback_fn callback; 68 void *callback_arg; 69 int status; 66 70 }; 67 71 -
trunk/src/libs/openssl-3.0.1/crypto/async/async_wait.c
r91772 r94082 1 1 /* 2 * Copyright 2016-20 18The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. 3 3 * 4 * Licensed under the OpenSSL license(the "License"). You may not use4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 5 * this file except in compliance with the License. You can obtain a copy 6 6 * in the file LICENSE in the source distribution or at … … 49 49 50 50 if ((fdlookup = OPENSSL_zalloc(sizeof(*fdlookup))) == NULL) { 51 ASYNCerr(ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD, ERR_R_MALLOC_FAILURE);51 ERR_raise(ERR_LIB_ASYNC, ERR_R_MALLOC_FAILURE); 52 52 return 0; 53 53 } … … 181 181 } 182 182 return 0; 183 } 184 185 int ASYNC_WAIT_CTX_set_callback(ASYNC_WAIT_CTX *ctx, 186 ASYNC_callback_fn callback, 187 void *callback_arg) 188 { 189 if (ctx == NULL) 190 return 0; 191 192 ctx->callback = callback; 193 ctx->callback_arg = callback_arg; 194 return 1; 195 } 196 197 int ASYNC_WAIT_CTX_get_callback(ASYNC_WAIT_CTX *ctx, 198 ASYNC_callback_fn *callback, 199 void **callback_arg) 200 { 201 if (ctx->callback == NULL) 202 return 0; 203 204 *callback = ctx->callback; 205 *callback_arg = ctx->callback_arg; 206 return 1; 207 } 208 209 int ASYNC_WAIT_CTX_set_status(ASYNC_WAIT_CTX *ctx, int status) 210 { 211 ctx->status = status; 212 return 1; 213 } 214 215 int ASYNC_WAIT_CTX_get_status(ASYNC_WAIT_CTX *ctx) 216 { 217 return ctx->status; 183 218 } 184 219
Note:
See TracChangeset
for help on using the changeset viewer.