Skip to content

Commit 4e88a35

Browse files
davidbenBoringssl LUCI CQ
authored and
Boringssl LUCI CQ
committed
Make the curve compat APIs into real functions
The standard macro-based pattern does not work in bindgen because of rust-lang/rust-bindgen#2544 Change-Id: Ic2b92e779ade2ed55a627bba9c76f7df5c0f6136 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61185 Reviewed-by: Bob Beck <[email protected]> Commit-Queue: Bob Beck <[email protected]> Auto-Submit: David Benjamin <[email protected]>
1 parent ff96a48 commit 4e88a35

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

include/openssl/ssl.h

+26-10
Original file line numberDiff line numberDiff line change
@@ -5256,23 +5256,37 @@ OPENSSL_EXPORT int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg);
52565256
SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_HASH_VALUE
52575257
#define SSL_R_TLSV1_CERTIFICATE_REQUIRED SSL_R_TLSV1_ALERT_CERTIFICATE_REQUIRED
52585258

5259-
// The following symbols are compatibility aliases for equivalent functions that
5260-
// use the newer "group" terminology. New code should use the new functions for
5261-
// consistency, but we do not plan to remove these aliases.
5262-
#define SSL_CTX_set1_curves SSL_CTX_set1_groups
5263-
#define SSL_set1_curves SSL_set1_groups
5264-
#define SSL_CTX_set1_curves_list SSL_CTX_set1_groups_list
5265-
#define SSL_set1_curves_list SSL_set1_groups_list
5266-
#define SSL_get_curve_id SSL_get_group_id
5267-
#define SSL_get_curve_name SSL_get_group_name
5268-
#define SSL_get_all_curve_names SSL_get_all_group_names
5259+
// The following symbols are compatibility aliases for |SSL_GROUP_*|.
52695260
#define SSL_CURVE_SECP224R1 SSL_GROUP_SECP224R1
52705261
#define SSL_CURVE_SECP256R1 SSL_GROUP_SECP256R1
52715262
#define SSL_CURVE_SECP384R1 SSL_GROUP_SECP384R1
52725263
#define SSL_CURVE_SECP521R1 SSL_GROUP_SECP521R1
52735264
#define SSL_CURVE_X25519 SSL_GROUP_X25519
52745265
#define SSL_CURVE_X25519_KYBER768_DRAFT00 SSL_GROUP_X25519_KYBER768_DRAFT00
52755266

5267+
// SSL_get_curve_id calls |SSL_get_group_id|.
5268+
OPENSSL_EXPORT uint16_t SSL_get_curve_id(const SSL *ssl);
5269+
5270+
// SSL_get_curve_name calls |SSL_get_group_name|.
5271+
OPENSSL_EXPORT const char *SSL_get_curve_name(uint16_t curve_id);
5272+
5273+
// SSL_get_all_curve_names calls |SSL_get_all_group_names|.
5274+
OPENSSL_EXPORT size_t SSL_get_all_curve_names(const char **out, size_t max_out);
5275+
5276+
// SSL_CTX_set1_curves calls |SSL_CTX_set1_groups|.
5277+
OPENSSL_EXPORT int SSL_CTX_set1_curves(SSL_CTX *ctx, const int *curves,
5278+
size_t num_curves);
5279+
5280+
// SSL_set1_curves calls |SSL_set1_groups|.
5281+
OPENSSL_EXPORT int SSL_set1_curves(SSL *ssl, const int *curves,
5282+
size_t num_curves);
5283+
5284+
// SSL_CTX_set1_curves_list calls |SSL_CTX_set1_groups_list|.
5285+
OPENSSL_EXPORT int SSL_CTX_set1_curves_list(SSL_CTX *ctx, const char *curves);
5286+
5287+
// SSL_set1_curves_list calls |SSL_set1_groups_list|.
5288+
OPENSSL_EXPORT int SSL_set1_curves_list(SSL *ssl, const char *curves);
5289+
52765290
// TLSEXT_nid_unknown is a constant used in OpenSSL for
52775291
// |SSL_get_negotiated_group| to return an unrecognized group. BoringSSL never
52785292
// returns this value, but we define this constant for compatibility.
@@ -5444,6 +5458,7 @@ OPENSSL_EXPORT int SSL_set_compliance_policy(
54445458
#define SSL_CTX_sess_set_cache_size SSL_CTX_sess_set_cache_size
54455459
#define SSL_CTX_set0_chain SSL_CTX_set0_chain
54465460
#define SSL_CTX_set1_chain SSL_CTX_set1_chain
5461+
#define SSL_CTX_set1_curves SSL_CTX_set1_curves
54475462
#define SSL_CTX_set1_groups SSL_CTX_set1_groups
54485463
#define SSL_CTX_set_max_cert_list SSL_CTX_set_max_cert_list
54495464
#define SSL_CTX_set_max_send_fragment SSL_CTX_set_max_send_fragment
@@ -5478,6 +5493,7 @@ OPENSSL_EXPORT int SSL_set_compliance_policy(
54785493
#define SSL_session_reused SSL_session_reused
54795494
#define SSL_set0_chain SSL_set0_chain
54805495
#define SSL_set1_chain SSL_set1_chain
5496+
#define SSL_set1_curves SSL_set1_curves
54815497
#define SSL_set1_groups SSL_set1_groups
54825498
#define SSL_set_max_cert_list SSL_set_max_cert_list
54835499
#define SSL_set_max_send_fragment SSL_set_max_send_fragment

ssl/ssl_lib.cc

+26
Original file line numberDiff line numberDiff line change
@@ -3213,6 +3213,32 @@ int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg) {
32133213
return 1;
32143214
}
32153215

3216+
uint16_t SSL_get_curve_id(const SSL *ssl) { return SSL_get_group_id(ssl); }
3217+
3218+
const char *SSL_get_curve_name(uint16_t curve_id) {
3219+
return SSL_get_group_name(curve_id);
3220+
}
3221+
3222+
size_t SSL_get_all_curve_names(const char **out, size_t max_out) {
3223+
return SSL_get_all_group_names(out, max_out);
3224+
}
3225+
3226+
int SSL_CTX_set1_curves(SSL_CTX *ctx, const int *curves, size_t num_curves) {
3227+
return SSL_CTX_set1_groups(ctx, curves, num_curves);
3228+
}
3229+
3230+
int SSL_set1_curves(SSL *ssl, const int *curves, size_t num_curves) {
3231+
return SSL_set1_groups(ssl, curves, num_curves);
3232+
}
3233+
3234+
int SSL_CTX_set1_curves_list(SSL_CTX *ctx, const char *curves) {
3235+
return SSL_CTX_set1_groups_list(ctx, curves);
3236+
}
3237+
3238+
int SSL_set1_curves_list(SSL *ssl, const char *curves) {
3239+
return SSL_set1_groups_list(ssl, curves);
3240+
}
3241+
32163242
namespace fips202205 {
32173243

32183244
// (References are to SP 800-52r2):

0 commit comments

Comments
 (0)