VirtualBox

Ignore:
Timestamp:
Mar 3, 2022 7:17:34 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
150325
Message:

libs/openssl-3.0.1: started applying and adjusting our OpenSSL changes to 3.0.1. bugref:10128

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  
        1212/vendor/openssl/1.1.1c:131722-131725
        1313/vendor/openssl/1.1.1k:145841-145843
         14/vendor/openssl/3.0.1:150323-150324
         15/vendor/openssl/current:147554-150322
  • trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_null.c

    r91772 r94082  
    22 * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    4  * Licensed under the OpenSSL license (the "License").  You may not use
     4 * Licensed under the Apache License 2.0 (the "License").  You may not use
    55 * this file except in compliance with the License.  You can obtain a copy
    66 * 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  
    22 * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    4  * Licensed under the OpenSSL license (the "License").  You may not use
     4 * Licensed under the Apache License 2.0 (the "License").  You may not use
    55 * this file except in compliance with the License.  You can obtain a copy
    66 * 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  
    11/*
    2  * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    4  * Licensed under the OpenSSL license (the "License").  You may not use
     4 * Licensed under the Apache License 2.0 (the "License").  You may not use
    55 * this file except in compliance with the License.  You can obtain a copy
    66 * in the file LICENSE in the source distribution or at
     
    3535int async_fibre_makecontext(async_fibre *fibre)
    3636{
     37#ifndef USE_SWAPCONTEXT
    3738    fibre->env_init = 0;
     39#endif
    3840    if (getcontext(&fibre->fibre) == 0) {
    3941        fibre->fibre.uc_stack.ss_sp = OPENSSL_malloc(STACKSIZE);
  • trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_posix.h

    r91772 r94082  
    11/*
    2  * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    4  * Licensed under the OpenSSL license (the "License").  You may not use
     4 * Licensed under the Apache License 2.0 (the "License").  You may not use
    55 * this file except in compliance with the License.  You can obtain a copy
    66 * in the file LICENSE in the source distribution or at
     
    2626#  define ASYNC_ARCH
    2727
     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
    2837#  include <ucontext.h>
    29 #  include <setjmp.h>
     38#  ifndef USE_SWAPCONTEXT
     39#   include <setjmp.h>
     40#  endif
    3041
    3142typedef struct async_fibre_st {
    3243    ucontext_t fibre;
     44#  ifndef USE_SWAPCONTEXT
    3345    jmp_buf env;
    3446    int env_init;
     47#  endif
    3548} async_fibre;
    3649
    3750static ossl_inline int async_fibre_swapcontext(async_fibre *o, async_fibre *n, int r)
    3851{
     52#  ifdef USE_SWAPCONTEXT
     53    swapcontext(&o->fibre, &n->fibre);
     54#  else
    3955    o->env_init = 1;
    4056
     
    4561            setcontext(&n->fibre);
    4662    }
     63#  endif
    4764
    4865    return 1;
  • trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_win.c

    r91772 r94082  
    11/*
    2  * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    4  * Licensed under the OpenSSL license (the "License").  You may not use
     4 * Licensed under the Apache License 2.0 (the "License").  You may not use
    55 * this file except in compliance with the License.  You can obtain a copy
    66 * in the file LICENSE in the source distribution or at
     
    3535int async_fibre_init_dispatcher(async_fibre *fibre)
    3636{
     37# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600
     38    fibre->fibre = ConvertThreadToFiberEx(NULL, FIBER_FLAG_FLOAT_SWITCH);
     39# else
    3740    fibre->fibre = ConvertThreadToFiber(NULL);
     41# endif
    3842    if (fibre->fibre == NULL) {
    3943        fibre->converted = 0;
  • trunk/src/libs/openssl-3.0.1/crypto/async/arch/async_win.h

    r91772 r94082  
    11/*
    2  * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    4  * Licensed under the OpenSSL license (the "License").  You may not use
     4 * Licensed under the Apache License 2.0 (the "License").  You may not use
    55 * this file except in compliance with the License.  You can obtain a copy
    66 * in the file LICENSE in the source distribution or at
     
    2727# define async_fibre_swapcontext(o,n,r) \
    2828        (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) \
    3036        ((c)->fibre = CreateFiber(0, async_start_func_win, 0))
     37# endif
     38
    3139# define async_fibre_free(f)             (DeleteFiber((f)->fibre))
    3240
  • trunk/src/libs/openssl-3.0.1/crypto/async/async.c

    r91772 r94082  
    11/*
    2  * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    4  * Licensed under the OpenSSL license (the "License").  You may not use
     4 * Licensed under the Apache License 2.0 (the "License").  You may not use
    55 * this file except in compliance with the License.  You can obtain a copy
    66 * in the file LICENSE in the source distribution or at
     
    3131static CRYPTO_THREAD_LOCAL poolkey;
    3232
     33static void async_delete_thread_state(void *arg);
     34
    3335static async_ctx *async_ctx_new(void)
    3436{
    3537    async_ctx *nctx;
    3638
    37     if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC))
     39    if (!ossl_init_thread_start(NULL, NULL, async_delete_thread_state))
    3840        return NULL;
    3941
    4042    nctx = OPENSSL_malloc(sizeof(*nctx));
    4143    if (nctx == NULL) {
    42         ASYNCerr(ASYNC_F_ASYNC_CTX_NEW, ERR_R_MALLOC_FAILURE);
     44        ERR_raise(ERR_LIB_ASYNC, ERR_R_MALLOC_FAILURE);
    4345        goto err;
    4446    }
     
    8284    job = OPENSSL_zalloc(sizeof(*job));
    8385    if (job == NULL) {
    84         ASYNCerr(ASYNC_F_ASYNC_JOB_NEW, ERR_R_MALLOC_FAILURE);
     86        ERR_raise(ERR_LIB_ASYNC, ERR_R_MALLOC_FAILURE);
    8587        return NULL;
    8688    }
     
    137139
    138140    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    }
    139145    OPENSSL_free(job->funcargs);
    140146    job->funcargs = NULL;
     
    147153    async_ctx *ctx = async_get_ctx();
    148154
     155    if (ctx == NULL) {
     156        ERR_raise(ERR_LIB_ASYNC, ERR_R_INTERNAL_ERROR);
     157        return;
     158    }
    149159    while (1) {
    150160        /* Run the job */
     
    160170             * much about it
    161171             */
    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);
    163173        }
    164174    }
     
    169179{
    170180    async_ctx *ctx;
     181    OSSL_LIB_CTX *libctx;
    171182
    172183    if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
     
    179190        return ASYNC_ERR;
    180191
    181     if (*job)
     192    if (*job != NULL)
    182193        ctx->currjob = *job;
    183194
     
    201212
    202213            if (ctx->currjob->status == ASYNC_JOB_PAUSED) {
     214                if (*job == NULL)
     215                    return ASYNC_ERR;
    203216                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                }
    204228                /* Resume previous job */
    205229                if (!async_fibre_swapcontext(&ctx->dispatcher,
    206230                        &ctx->currjob->fibrectx, 1)) {
    207                     ASYNCerr(ASYNC_F_ASYNC_START_JOB,
    208                             ASYNC_R_FAILED_TO_SWAP_CONTEXT);
     231                    ctx->currjob->libctx = OSSL_LIB_CTX_set0_default(libctx);
     232                    ERR_raise(ERR_LIB_ASYNC, ASYNC_R_FAILED_TO_SWAP_CONTEXT);
    209233                    goto err;
    210234                }
     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);
    211241                continue;
    212242            }
    213243
    214244            /* Should not happen */
    215             ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_INTERNAL_ERROR);
     245            ERR_raise(ERR_LIB_ASYNC, ERR_R_INTERNAL_ERROR);
    216246            async_release_job(ctx->currjob);
    217247            ctx->currjob = NULL;
     
    227257            ctx->currjob->funcargs = OPENSSL_malloc(size);
    228258            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);
    230260                async_release_job(ctx->currjob);
    231261                ctx->currjob = NULL;
     
    239269        ctx->currjob->func = func;
    240270        ctx->currjob->waitctx = wctx;
     271        libctx = ossl_lib_ctx_get_concrete(NULL);
    241272        if (!async_fibre_swapcontext(&ctx->dispatcher,
    242273                &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);
    244275            goto err;
    245276        }
     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);
    246282    }
    247283
     
    273309    if (!async_fibre_swapcontext(&job->fibrectx,
    274310                                 &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);
    276312        return 0;
    277313    }
     
    286322    ASYNC_JOB *job;
    287323
    288     if (!pool || !pool->jobs)
     324    if (pool == NULL || pool->jobs == NULL)
    289325        return;
    290326
     
    320356
    321357    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))
    330366        return 0;
    331367
    332368    pool = OPENSSL_zalloc(sizeof(*pool));
    333369    if (pool == NULL) {
    334         ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
     370        ERR_raise(ERR_LIB_ASYNC, ERR_R_MALLOC_FAILURE);
    335371        return 0;
    336372    }
     
    338374    pool->jobs = sk_ASYNC_JOB_new_reserve(NULL, init_size);
    339375    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);
    341377        OPENSSL_free(pool);
    342378        return 0;
     
    363399    pool->curr_size = curr_size;
    364400    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);
    366402        goto err;
    367403    }
     
    375411}
    376412
    377 void async_delete_thread_state(void)
     413static void async_delete_thread_state(void *arg)
    378414{
    379415    async_pool *pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey);
     
    394430        return;
    395431
    396     async_delete_thread_state();
     432    async_delete_thread_state(NULL);
    397433}
    398434
  • trunk/src/libs/openssl-3.0.1/crypto/async/async_err.c

    r91772 r94082  
    11/*
    22 * Generated by util/mkerr.pl DO NOT EDIT
    3  * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
     3 * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
    44 *
    5  * Licensed under the OpenSSL license (the "License").  You may not use
     5 * Licensed under the Apache License 2.0 (the "License").  You may not use
    66 * this file except in compliance with the License.  You can obtain a copy
    77 * in the file LICENSE in the source distribution or at
     
    1111#include <openssl/err.h>
    1212#include <openssl/asyncerr.h>
     13#include "crypto/asyncerr.h"
    1314
    1415#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 };
    2816
    2917static const ERR_STRING_DATA ASYNC_str_reasons[] = {
     
    4028#endif
    4129
    42 int ERR_load_ASYNC_strings(void)
     30int ossl_err_load_ASYNC_strings(void)
    4331{
    4432#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)
    4734        ERR_load_strings_const(ASYNC_str_reasons);
    48     }
    4935#endif
    5036    return 1;
  • trunk/src/libs/openssl-3.0.1/crypto/async/async_local.h

    r91772 r94082  
    11/*
    2  * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    4  * Licensed under the OpenSSL license (the "License").  You may not use
     4 * Licensed under the Apache License 2.0 (the "License").  You may not use
    55 * this file except in compliance with the License.  You can obtain a copy
    66 * in the file LICENSE in the source distribution or at
     
    4848    int status;
    4949    ASYNC_WAIT_CTX *waitctx;
     50    OSSL_LIB_CTX *libctx;
    5051};
    5152
     
    6465    size_t numadd;
    6566    size_t numdel;
     67    ASYNC_callback_fn callback;
     68    void *callback_arg;
     69    int status;
    6670};
    6771
  • trunk/src/libs/openssl-3.0.1/crypto/async/async_wait.c

    r91772 r94082  
    11/*
    2  * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
    33 *
    4  * Licensed under the OpenSSL license (the "License").  You may not use
     4 * Licensed under the Apache License 2.0 (the "License").  You may not use
    55 * this file except in compliance with the License.  You can obtain a copy
    66 * in the file LICENSE in the source distribution or at
     
    4949
    5050    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);
    5252        return 0;
    5353    }
     
    181181    }
    182182    return 0;
     183}
     184
     185int 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
     197int 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
     209int ASYNC_WAIT_CTX_set_status(ASYNC_WAIT_CTX *ctx, int status)
     210{
     211      ctx->status = status;
     212      return 1;
     213}
     214
     215int ASYNC_WAIT_CTX_get_status(ASYNC_WAIT_CTX *ctx)
     216{
     217      return ctx->status;
    183218}
    184219
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette