Changeset 94082 in vbox for trunk/src/libs/openssl-3.0.1/apps/pkcs8.c
- 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:
-
- 2 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/apps/pkcs8.c
r91772 r94082 1 1 /* 2 * Copyright 1999-20 18The OpenSSL Project Authors. All Rights Reserved.2 * Copyright 1999-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 … … 19 19 20 20 typedef enum OPTION_choice { 21 OPT_ ERR = -1, OPT_EOF = 0, OPT_HELP,21 OPT_COMMON, 22 22 OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_IN, OPT_OUT, 23 23 OPT_TOPK8, OPT_NOITER, OPT_NOCRYPT, … … 27 27 OPT_V2, OPT_V1, OPT_V2PRF, OPT_ITER, OPT_PASSIN, OPT_PASSOUT, 28 28 OPT_TRADITIONAL, 29 OPT_R_ENUM 29 OPT_R_ENUM, OPT_PROV_ENUM 30 30 } OPTION_CHOICE; 31 31 32 32 const OPTIONS pkcs8_options[] = { 33 OPT_SECTION("General"), 33 34 {"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"}, 34 44 {"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"}, 35 50 {"outform", OPT_OUTFORM, 'F', "Output format (DER or PEM)"}, 36 {"in", OPT_IN, '<', "Input file"},37 {"out", OPT_OUT, '>', "Output file"},38 51 {"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"},47 52 {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, 48 53 {"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"), 53 59 {"scrypt", OPT_SCRYPT, '-', "Use scrypt algorithm"}, 54 60 {"scrypt_N", OPT_SCRYPT_N, 's', "Set scrypt N parameter"}, … … 56 62 {"scrypt_p", OPT_SCRYPT_P, 's', "Set scrypt p parameter"}, 57 63 #endif 64 65 OPT_R_OPTIONS, 66 OPT_PROV_OPTIONS, 58 67 {NULL} 59 68 }; … … 66 75 PKCS8_PRIV_KEY_INFO *p8inf = NULL; 67 76 X509_SIG *p8 = NULL; 68 constEVP_CIPHER *cipher = NULL;69 char *infile = NULL, *outfile = NULL ;77 EVP_CIPHER *cipher = NULL; 78 char *infile = NULL, *outfile = NULL, *ciphername = NULL; 70 79 char *passinarg = NULL, *passoutarg = NULL, *prog; 71 80 #ifndef OPENSSL_NO_UI_CONSOLE … … 75 84 OPTION_CHOICE o; 76 85 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; 78 87 int private = 0, traditional = 0; 79 88 #ifndef OPENSSL_NO_SCRYPT … … 120 129 goto end; 121 130 break; 131 case OPT_PROV_CASES: 132 if (!opt_provider(o)) 133 goto end; 134 break; 122 135 case OPT_TRADITIONAL: 123 136 traditional = 1; 124 137 break; 125 138 case OPT_V2: 126 if (!opt_cipher(opt_arg(), &cipher)) 127 goto opthelp; 139 ciphername = opt_arg(); 128 140 break; 129 141 case OPT_V1: … … 143 155 } 144 156 if (cipher == NULL) 145 cipher = EVP_aes_256_cbc();157 cipher = (EVP_CIPHER *)EVP_aes_256_cbc(); 146 158 break; 147 159 case OPT_ITER: 148 if (!opt_int(opt_arg(), &iter)) 149 goto opthelp; 160 iter = opt_int_arg(); 150 161 break; 151 162 case OPT_PASSIN: … … 164 175 scrypt_p = 1; 165 176 if (cipher == NULL) 166 cipher = EVP_aes_256_cbc();177 cipher = (EVP_CIPHER *)EVP_aes_256_cbc(); 167 178 break; 168 179 case OPT_SCRYPT_N: … … 181 192 } 182 193 } 194 195 /* No extra arguments. */ 183 196 argc = opt_num_rest(); 184 197 if (argc != 0) … … 186 199 187 200 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 } 188 208 189 209 if (!app_passwd(passinarg, passoutarg, &passin, &passout)) { … … 193 213 194 214 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); 198 219 if (in == NULL) 199 220 goto end; … … 279 300 280 301 if (nocrypt) { 281 if (informat == FORMAT_PEM ) {302 if (informat == FORMAT_PEM || informat == FORMAT_UNDEF) { 282 303 p8inf = PEM_read_bio_PKCS8_PRIV_KEY_INFO(in, NULL, NULL, NULL); 283 304 } else if (informat == FORMAT_ASN1) { … … 288 309 } 289 310 } else { 290 if (informat == FORMAT_PEM ) {311 if (informat == FORMAT_PEM || informat == FORMAT_UNDEF) { 291 312 p8 = PEM_read_bio_PKCS8(in, NULL, NULL, NULL); 292 313 } else if (informat == FORMAT_ASN1) { … … 350 371 PKCS8_PRIV_KEY_INFO_free(p8inf); 351 372 EVP_PKEY_free(pkey); 373 EVP_CIPHER_free(cipher); 352 374 release_engine(e); 353 375 BIO_free_all(out);
Note:
See TracChangeset
for help on using the changeset viewer.