Skip to content

Commit ed576ac

Browse files
committed
Rename all getters to use get/get0 in name
For functions that exist in 1.1.1 provide a simple aliases via #define. Fixes openssl#15236 Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_, EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_, EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_, EVP_MD_, and EVP_CIPHER_ prefixes are renamed. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from openssl#15405)
1 parent 5e2d22d commit ed576ac

261 files changed

Lines changed: 1935 additions & 1800 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ breaking changes, and mappings for the large list of deprecated functions.
641641

642642
*Richard Levitte*
643643

644-
* Enhanced the documentation of EVP_PKEY_size(), EVP_PKEY_bits()
645-
and EVP_PKEY_security_bits(). Especially EVP_PKEY_size() needed
644+
* Enhanced the documentation of EVP_PKEY_get_size(), EVP_PKEY_get_bits()
645+
and EVP_PKEY_get_security_bits(). Especially EVP_PKEY_get_size() needed
646646
a new formulation to include all the things it can be used for,
647647
as well as words of caution.
648648

apps/cms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ int cms_main(int argc, char **argv)
10131013

10141014
res = EVP_PKEY_CTX_ctrl(pctx, -1, -1,
10151015
EVP_PKEY_CTRL_CIPHER,
1016-
EVP_CIPHER_nid(cipher), NULL);
1016+
EVP_CIPHER_get_nid(cipher), NULL);
10171017
if (res <= 0 && res != -2)
10181018
goto end;
10191019

apps/crl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ int crl_main(int argc, char **argv)
347347
BIO_printf(bio_err, "out of memory\n");
348348
goto end;
349349
}
350-
BIO_printf(bio_out, "%s Fingerprint=", EVP_MD_name(digest));
350+
BIO_printf(bio_out, "%s Fingerprint=",
351+
EVP_MD_get0_name(digest));
351352
for (j = 0; j < (int)n; j++) {
352353
BIO_printf(bio_out, "%02X%c", md[j], (j + 1 == (int)n)
353354
? '\n' : ':');

apps/dgst.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ int dgst_main(int argc, char **argv)
287287
*/
288288
goto end;
289289
}
290-
type = EVP_PKEY_id(sigkey);
290+
type = EVP_PKEY_get_id(sigkey);
291291
if (type == EVP_PKEY_ED25519 || type == EVP_PKEY_ED448) {
292292
/*
293293
* We implement PureEdDSA for these which doesn't have a separate
@@ -381,7 +381,7 @@ int dgst_main(int argc, char **argv)
381381
BIO_printf(bio_err, "Error opening signature file %s\n", sigfile);
382382
goto end;
383383
}
384-
siglen = EVP_PKEY_size(sigkey);
384+
siglen = EVP_PKEY_get_size(sigkey);
385385
sigbuf = app_malloc(siglen, "signature buffer");
386386
siglen = BIO_read(sigbio, sigbuf, siglen);
387387
BIO_free(sigbio);
@@ -399,10 +399,10 @@ int dgst_main(int argc, char **argv)
399399
md = EVP_MD_CTX_get1_md(tctx);
400400
}
401401
if (md != NULL)
402-
md_name = EVP_MD_name(md);
402+
md_name = EVP_MD_get0_name(md);
403403

404404
if (xoflen > 0) {
405-
if (!(EVP_MD_flags(md) & EVP_MD_FLAG_XOF)) {
405+
if (!(EVP_MD_get_flags(md) & EVP_MD_FLAG_XOF)) {
406406
BIO_printf(bio_err, "Length can only be specified for XOF\n");
407407
goto end;
408408
}

apps/dsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ int dsa_main(int argc, char **argv)
269269

270270
/* Passphrase setup */
271271
if (enc != NULL)
272-
OSSL_ENCODER_CTX_set_cipher(ectx, EVP_CIPHER_name(enc), NULL);
272+
OSSL_ENCODER_CTX_set_cipher(ectx, EVP_CIPHER_get0_name(enc), NULL);
273273

274274
/* Default passphrase prompter */
275275
if (enc != NULL || outformat == FORMAT_PVK) {

apps/ec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ int ec_main(int argc, char **argv)
260260
output_type, output_structure,
261261
NULL);
262262
if (enc != NULL) {
263-
OSSL_ENCODER_CTX_set_cipher(ectx, EVP_CIPHER_name(enc), NULL);
263+
OSSL_ENCODER_CTX_set_cipher(ectx, EVP_CIPHER_get0_name(enc), NULL);
264264
/* Default passphrase prompter */
265265
OSSL_ENCODER_CTX_set_passphrase_ui(ectx, get_ui_method(), NULL);
266266
if (passout != NULL)

apps/enc.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ int enc_main(int argc, char **argv)
300300
if (!opt_cipher(ciphername, &cipher))
301301
goto opthelp;
302302
}
303-
if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {
303+
if (cipher && EVP_CIPHER_get_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {
304304
BIO_printf(bio_err, "%s: AEAD ciphers not supported\n", prog);
305305
goto end;
306306
}
307-
if (cipher && (EVP_CIPHER_mode(cipher) == EVP_CIPH_XTS_MODE)) {
307+
if (cipher && (EVP_CIPHER_get_mode(cipher) == EVP_CIPH_XTS_MODE)) {
308308
BIO_printf(bio_err, "%s XTS ciphers not supported\n", prog);
309309
goto end;
310310
}
@@ -360,7 +360,7 @@ int enc_main(int argc, char **argv)
360360
char prompt[200];
361361

362362
BIO_snprintf(prompt, sizeof(prompt), "enter %s %s password:",
363-
EVP_CIPHER_name(cipher),
363+
EVP_CIPHER_get0_name(cipher),
364364
(enc) ? "encryption" : "decryption");
365365
strbuf[0] = '\0';
366366
i = EVP_read_pw_string((char *)strbuf, SIZE, prompt, enc);
@@ -492,8 +492,8 @@ int enc_main(int argc, char **argv)
492492
* concatenated into a temporary buffer
493493
*/
494494
unsigned char tmpkeyiv[EVP_MAX_KEY_LENGTH + EVP_MAX_IV_LENGTH];
495-
int iklen = EVP_CIPHER_key_length(cipher);
496-
int ivlen = EVP_CIPHER_iv_length(cipher);
495+
int iklen = EVP_CIPHER_get_key_length(cipher);
496+
int ivlen = EVP_CIPHER_get_iv_length(cipher);
497497
/* not needed if HASH_UPDATE() is fixed : */
498498
int islen = (sptr != NULL ? sizeof(salt) : 0);
499499
if (!PKCS5_PBKDF2_HMAC(str, str_len, sptr, islen,
@@ -525,7 +525,7 @@ int enc_main(int argc, char **argv)
525525
OPENSSL_cleanse(str, str_len);
526526
}
527527
if (hiv != NULL) {
528-
int siz = EVP_CIPHER_iv_length(cipher);
528+
int siz = EVP_CIPHER_get_iv_length(cipher);
529529
if (siz == 0) {
530530
BIO_printf(bio_err, "warning: iv not used by this cipher\n");
531531
} else if (!set_hex(hiv, iv, siz)) {
@@ -534,7 +534,7 @@ int enc_main(int argc, char **argv)
534534
}
535535
}
536536
if ((hiv == NULL) && (str == NULL)
537-
&& EVP_CIPHER_iv_length(cipher) != 0) {
537+
&& EVP_CIPHER_get_iv_length(cipher) != 0) {
538538
/*
539539
* No IV was explicitly set and no IV was generated.
540540
* Hence the IV is undefined, making correct decryption impossible.
@@ -543,7 +543,7 @@ int enc_main(int argc, char **argv)
543543
goto end;
544544
}
545545
if (hkey != NULL) {
546-
if (!set_hex(hkey, key, EVP_CIPHER_key_length(cipher))) {
546+
if (!set_hex(hkey, key, EVP_CIPHER_get_key_length(cipher))) {
547547
BIO_printf(bio_err, "invalid hex key value\n");
548548
goto end;
549549
}
@@ -563,7 +563,7 @@ int enc_main(int argc, char **argv)
563563

564564
if (!EVP_CipherInit_ex(ctx, cipher, e, NULL, NULL, enc)) {
565565
BIO_printf(bio_err, "Error setting cipher %s\n",
566-
EVP_CIPHER_name(cipher));
566+
EVP_CIPHER_get0_name(cipher));
567567
ERR_print_errors(bio_err);
568568
goto end;
569569
}
@@ -573,7 +573,7 @@ int enc_main(int argc, char **argv)
573573

574574
if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, enc)) {
575575
BIO_printf(bio_err, "Error setting cipher %s\n",
576-
EVP_CIPHER_name(cipher));
576+
EVP_CIPHER_get0_name(cipher));
577577
ERR_print_errors(bio_err);
578578
goto end;
579579
}
@@ -590,15 +590,15 @@ int enc_main(int argc, char **argv)
590590
printf("%02X", salt[i]);
591591
printf("\n");
592592
}
593-
if (EVP_CIPHER_key_length(cipher) > 0) {
593+
if (EVP_CIPHER_get_key_length(cipher) > 0) {
594594
printf("key=");
595-
for (i = 0; i < EVP_CIPHER_key_length(cipher); i++)
595+
for (i = 0; i < EVP_CIPHER_get_key_length(cipher); i++)
596596
printf("%02X", key[i]);
597597
printf("\n");
598598
}
599-
if (EVP_CIPHER_iv_length(cipher) > 0) {
599+
if (EVP_CIPHER_get_iv_length(cipher) > 0) {
600600
printf("iv =");
601-
for (i = 0; i < EVP_CIPHER_iv_length(cipher); i++)
601+
for (i = 0; i < EVP_CIPHER_get_iv_length(cipher); i++)
602602
printf("%02X", iv[i]);
603603
printf("\n");
604604
}
@@ -661,8 +661,8 @@ static void show_ciphers(const OBJ_NAME *name, void *arg)
661661
/* Filter out ciphers that we cannot use */
662662
cipher = EVP_get_cipherbyname(name->name);
663663
if (cipher == NULL ||
664-
(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) != 0 ||
665-
EVP_CIPHER_mode(cipher) == EVP_CIPH_XTS_MODE)
664+
(EVP_CIPHER_get_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) != 0 ||
665+
EVP_CIPHER_get_mode(cipher) == EVP_CIPH_XTS_MODE)
666666
return;
667667

668668
BIO_printf(dec->bio, "-%-25s", name->name);

apps/gendsa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ int gendsa_main(int argc, char **argv)
127127
if (out == NULL)
128128
goto end2;
129129

130-
nbits = EVP_PKEY_bits(pkey);
130+
nbits = EVP_PKEY_get_bits(pkey);
131131
if (nbits > OPENSSL_DSA_MAX_MODULUS_BITS)
132132
BIO_printf(bio_err,
133133
"Warning: It is not recommended to use more than %d bit for DSA keys.\n"
134134
" Your key size is %d! Larger key size may behave not as expected.\n",
135-
OPENSSL_DSA_MAX_MODULUS_BITS, EVP_PKEY_bits(pkey));
135+
OPENSSL_DSA_MAX_MODULUS_BITS, EVP_PKEY_get_bits(pkey));
136136

137137
ctx = EVP_PKEY_CTX_new(pkey, NULL);
138138
if (ctx == NULL) {

apps/genpkey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int genpkey_main(int argc, char **argv)
166166
if (ciphername != NULL) {
167167
if (!opt_cipher(ciphername, &cipher) || do_param == 1)
168168
goto opthelp;
169-
m = EVP_CIPHER_mode(cipher);
169+
m = EVP_CIPHER_get_mode(cipher);
170170
if (m == EVP_CIPH_GCM_MODE || m == EVP_CIPH_CCM_MODE
171171
|| m == EVP_CIPH_XTS_MODE || m == EVP_CIPH_OCB_MODE) {
172172
BIO_printf(bio_err, "%s: cipher mode not supported\n", prog);

apps/lib/s_cb.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ int ssl_print_tmp_key(BIO *out, SSL *s)
386386
if (!SSL_get_peer_tmp_key(s, &key))
387387
return 1;
388388
BIO_puts(out, "Server Temp Key: ");
389-
switch (EVP_PKEY_id(key)) {
389+
switch (EVP_PKEY_get_id(key)) {
390390
case EVP_PKEY_RSA:
391-
BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key));
391+
BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_get_bits(key));
392392
break;
393393

394394
case EVP_PKEY_DH:
395-
BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(key));
395+
BIO_printf(out, "DH, %d bits\n", EVP_PKEY_get_bits(key));
396396
break;
397397
#ifndef OPENSSL_NO_EC
398398
case EVP_PKEY_EC:
@@ -403,13 +403,13 @@ int ssl_print_tmp_key(BIO *out, SSL *s)
403403
if (!EVP_PKEY_get_utf8_string_param(key, OSSL_PKEY_PARAM_GROUP_NAME,
404404
name, sizeof(name), &name_len))
405405
strcpy(name, "?");
406-
BIO_printf(out, "ECDH, %s, %d bits\n", name, EVP_PKEY_bits(key));
406+
BIO_printf(out, "ECDH, %s, %d bits\n", name, EVP_PKEY_get_bits(key));
407407
}
408408
break;
409409
#endif
410410
default:
411-
BIO_printf(out, "%s, %d bits\n", OBJ_nid2sn(EVP_PKEY_id(key)),
412-
EVP_PKEY_bits(key));
411+
BIO_printf(out, "%s, %d bits\n", OBJ_nid2sn(EVP_PKEY_get_id(key)),
412+
EVP_PKEY_get_bits(key));
413413
}
414414
EVP_PKEY_free(key);
415415
return 1;
@@ -1426,7 +1426,7 @@ static int security_callback_debug(const SSL *s, const SSL_CTX *ctx,
14261426
EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL,
14271427
&algname, EVP_PKEY_get0_asn1(pkey));
14281428
BIO_printf(sdb->out, "%s, bits=%d",
1429-
algname, EVP_PKEY_bits(pkey));
1429+
algname, EVP_PKEY_get_bits(pkey));
14301430
}
14311431
break;
14321432
}

0 commit comments

Comments
 (0)