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:
2 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/apps/pkcs8.c

    r91772 r94082  
    11/*
    2  * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
     2 * Copyright 1999-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
     
    1919
    2020typedef enum OPTION_choice {
    21     OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
     21    OPT_COMMON,
    2222    OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_IN, OPT_OUT,
    2323    OPT_TOPK8, OPT_NOITER, OPT_NOCRYPT,
     
    2727    OPT_V2, OPT_V1, OPT_V2PRF, OPT_ITER, OPT_PASSIN, OPT_PASSOUT,
    2828    OPT_TRADITIONAL,
    29     OPT_R_ENUM
     29    OPT_R_ENUM, OPT_PROV_ENUM
    3030} OPTION_CHOICE;
    3131
    3232const OPTIONS pkcs8_options[] = {
     33    OPT_SECTION("General"),
    3334    {"help", OPT_HELP, '-', "Display this summary"},
     35#ifndef OPENSSL_NO_ENGINE
     36    {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
     37#endif
     38    {"v1", OPT_V1, 's', "Use PKCS#5 v1.5 and cipher"},
     39    {"v2", OPT_V2, 's', "Use PKCS#5 v2.0 and cipher"},
     40    {"v2prf", OPT_V2PRF, 's', "Set the PRF algorithm to use with PKCS#5 v2.0"},
     41
     42    OPT_SECTION("Input"),
     43    {"in", OPT_IN, '<', "Input file"},
    3444    {"inform", OPT_INFORM, 'F', "Input format (DER or PEM)"},
     45    {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
     46    {"nocrypt", OPT_NOCRYPT, '-', "Use or expect unencrypted private key"},
     47
     48    OPT_SECTION("Output"),
     49    {"out", OPT_OUT, '>', "Output file"},
    3550    {"outform", OPT_OUTFORM, 'F', "Output format (DER or PEM)"},
    36     {"in", OPT_IN, '<', "Input file"},
    37     {"out", OPT_OUT, '>', "Output file"},
    3851    {"topk8", OPT_TOPK8, '-', "Output PKCS8 file"},
    39     {"noiter", OPT_NOITER, '-', "Use 1 as iteration count"},
    40     {"nocrypt", OPT_NOCRYPT, '-', "Use or expect unencrypted private key"},
    41     OPT_R_OPTIONS,
    42     {"v2", OPT_V2, 's', "Use PKCS#5 v2.0 and cipher"},
    43     {"v1", OPT_V1, 's', "Use PKCS#5 v1.5 and cipher"},
    44     {"v2prf", OPT_V2PRF, 's', "Set the PRF algorithm to use with PKCS#5 v2.0"},
    45     {"iter", OPT_ITER, 'p', "Specify the iteration count"},
    46     {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
    4752    {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
    4853    {"traditional", OPT_TRADITIONAL, '-', "use traditional format private key"},
    49 #ifndef OPENSSL_NO_ENGINE
    50     {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
    51 #endif
    52 #ifndef OPENSSL_NO_SCRYPT
     54    {"iter", OPT_ITER, 'p', "Specify the iteration count"},
     55    {"noiter", OPT_NOITER, '-', "Use 1 as iteration count"},
     56
     57#ifndef OPENSSL_NO_SCRYPT
     58    OPT_SECTION("Scrypt"),
    5359    {"scrypt", OPT_SCRYPT, '-', "Use scrypt algorithm"},
    5460    {"scrypt_N", OPT_SCRYPT_N, 's', "Set scrypt N parameter"},
     
    5662    {"scrypt_p", OPT_SCRYPT_P, 's', "Set scrypt p parameter"},
    5763#endif
     64
     65    OPT_R_OPTIONS,
     66    OPT_PROV_OPTIONS,
    5867    {NULL}
    5968};
     
    6675    PKCS8_PRIV_KEY_INFO *p8inf = NULL;
    6776    X509_SIG *p8 = NULL;
    68     const EVP_CIPHER *cipher = NULL;
    69     char *infile = NULL, *outfile = NULL;
     77    EVP_CIPHER *cipher = NULL;
     78    char *infile = NULL, *outfile = NULL, *ciphername = NULL;
    7079    char *passinarg = NULL, *passoutarg = NULL, *prog;
    7180#ifndef OPENSSL_NO_UI_CONSOLE
     
    7584    OPTION_CHOICE o;
    7685    int nocrypt = 0, ret = 1, iter = PKCS12_DEFAULT_ITER;
    77     int informat = FORMAT_PEM, outformat = FORMAT_PEM, topk8 = 0, pbe_nid = -1;
     86    int informat = FORMAT_UNDEF, outformat = FORMAT_PEM, topk8 = 0, pbe_nid = -1;
    7887    int private = 0, traditional = 0;
    7988#ifndef OPENSSL_NO_SCRYPT
     
    120129                goto end;
    121130            break;
     131        case OPT_PROV_CASES:
     132            if (!opt_provider(o))
     133                goto end;
     134            break;
    122135        case OPT_TRADITIONAL:
    123136            traditional = 1;
    124137            break;
    125138        case OPT_V2:
    126             if (!opt_cipher(opt_arg(), &cipher))
    127                 goto opthelp;
     139            ciphername = opt_arg();
    128140            break;
    129141        case OPT_V1:
     
    143155            }
    144156            if (cipher == NULL)
    145                 cipher = EVP_aes_256_cbc();
     157                cipher = (EVP_CIPHER *)EVP_aes_256_cbc();
    146158            break;
    147159        case OPT_ITER:
    148             if (!opt_int(opt_arg(), &iter))
    149                 goto opthelp;
     160            iter =  opt_int_arg();
    150161            break;
    151162        case OPT_PASSIN:
     
    164175            scrypt_p = 1;
    165176            if (cipher == NULL)
    166                 cipher = EVP_aes_256_cbc();
     177                cipher = (EVP_CIPHER *)EVP_aes_256_cbc();
    167178            break;
    168179        case OPT_SCRYPT_N:
     
    181192        }
    182193    }
     194
     195    /* No extra arguments. */
    183196    argc = opt_num_rest();
    184197    if (argc != 0)
     
    186199
    187200    private = 1;
     201    if (!app_RAND_load())
     202        goto end;
     203
     204    if (ciphername != NULL) {
     205        if (!opt_cipher(ciphername, &cipher))
     206            goto opthelp;
     207    }
    188208
    189209    if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
     
    193213
    194214    if ((pbe_nid == -1) && cipher == NULL)
    195         cipher = EVP_aes_256_cbc();
    196 
    197     in = bio_open_default(infile, 'r', informat);
     215        cipher = (EVP_CIPHER *)EVP_aes_256_cbc();
     216
     217    in = bio_open_default(infile, 'r',
     218                          informat == FORMAT_UNDEF ? FORMAT_PEM : informat);
    198219    if (in == NULL)
    199220        goto end;
     
    279300
    280301    if (nocrypt) {
    281         if (informat == FORMAT_PEM) {
     302        if (informat == FORMAT_PEM || informat == FORMAT_UNDEF) {
    282303            p8inf = PEM_read_bio_PKCS8_PRIV_KEY_INFO(in, NULL, NULL, NULL);
    283304        } else if (informat == FORMAT_ASN1) {
     
    288309        }
    289310    } else {
    290         if (informat == FORMAT_PEM) {
     311        if (informat == FORMAT_PEM || informat == FORMAT_UNDEF) {
    291312            p8 = PEM_read_bio_PKCS8(in, NULL, NULL, NULL);
    292313        } else if (informat == FORMAT_ASN1) {
     
    350371    PKCS8_PRIV_KEY_INFO_free(p8inf);
    351372    EVP_PKEY_free(pkey);
     373    EVP_CIPHER_free(cipher);
    352374    release_engine(e);
    353375    BIO_free_all(out);
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