Skip to content

Commit d2ed974

Browse files
davidbensamuel40791765
authored andcommitted
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]> (cherry picked from commit 4e88a3557f6a022e30d1ff85fbd87e1173848be2)
1 parent 5a22c52 commit d2ed974

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

include/openssl/ssl.h

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5601,16 +5601,7 @@ OPENSSL_EXPORT int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg);
56015601
SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_HASH_VALUE
56025602
#define SSL_R_TLSV1_CERTIFICATE_REQUIRED SSL_R_TLSV1_ALERT_CERTIFICATE_REQUIRED
56035603

5604-
// The following symbols are compatibility aliases for equivalent functions that
5605-
// use the newer "group" terminology. New code should use the new functions for
5606-
// consistency, but we do not plan to remove these aliases.
5607-
#define SSL_CTX_set1_curves SSL_CTX_set1_groups
5608-
#define SSL_set1_curves SSL_set1_groups
5609-
#define SSL_CTX_set1_curves_list SSL_CTX_set1_groups_list
5610-
#define SSL_set1_curves_list SSL_set1_groups_list
5611-
#define SSL_get_curve_id SSL_get_group_id
5612-
#define SSL_get_curve_name SSL_get_group_name
5613-
#define SSL_get_all_curve_names SSL_get_all_group_names
5604+
// The following symbols are compatibility aliases for |SSL_GROUP_*|.
56145605
#define SSL_CURVE_SECP224R1 SSL_GROUP_SECP224R1
56155606
#define SSL_CURVE_SECP256R1 SSL_GROUP_SECP256R1
56165607
#define SSL_CURVE_SECP384R1 SSL_GROUP_SECP384R1
@@ -5619,6 +5610,29 @@ OPENSSL_EXPORT int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg);
56195610
#define SSL_CURVE_SECP256R1_KYBER768_DRAFT00 SSL_GROUP_SECP256R1_KYBER768_DRAFT00
56205611
#define SSL_CURVE_X25519_KYBER768_DRAFT00 SSL_GROUP_X25519_KYBER768_DRAFT00
56215612

5613+
// SSL_get_curve_id calls |SSL_get_group_id|.
5614+
OPENSSL_EXPORT uint16_t SSL_get_curve_id(const SSL *ssl);
5615+
5616+
// SSL_get_curve_name calls |SSL_get_group_name|.
5617+
OPENSSL_EXPORT const char *SSL_get_curve_name(uint16_t curve_id);
5618+
5619+
// SSL_get_all_curve_names calls |SSL_get_all_group_names|.
5620+
OPENSSL_EXPORT size_t SSL_get_all_curve_names(const char **out, size_t max_out);
5621+
5622+
// SSL_CTX_set1_curves calls |SSL_CTX_set1_groups|.
5623+
OPENSSL_EXPORT int SSL_CTX_set1_curves(SSL_CTX *ctx, const int *curves,
5624+
size_t num_curves);
5625+
5626+
// SSL_set1_curves calls |SSL_set1_groups|.
5627+
OPENSSL_EXPORT int SSL_set1_curves(SSL *ssl, const int *curves,
5628+
size_t num_curves);
5629+
5630+
// SSL_CTX_set1_curves_list calls |SSL_CTX_set1_groups_list|.
5631+
OPENSSL_EXPORT int SSL_CTX_set1_curves_list(SSL_CTX *ctx, const char *curves);
5632+
5633+
// SSL_set1_curves_list calls |SSL_set1_groups_list|.
5634+
OPENSSL_EXPORT int SSL_set1_curves_list(SSL *ssl, const char *curves);
5635+
56225636

56235637
// Nodejs compatibility section (hidden).
56245638
//
@@ -5725,6 +5739,7 @@ OPENSSL_EXPORT int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg);
57255739
#define SSL_CTX_sess_set_cache_size SSL_CTX_sess_set_cache_size
57265740
#define SSL_CTX_set0_chain SSL_CTX_set0_chain
57275741
#define SSL_CTX_set1_chain SSL_CTX_set1_chain
5742+
#define SSL_CTX_set1_curves SSL_CTX_set1_curves
57285743
#define SSL_CTX_set1_groups SSL_CTX_set1_groups
57295744
#define SSL_CTX_set_max_cert_list SSL_CTX_set_max_cert_list
57305745
#define SSL_CTX_set_max_send_fragment SSL_CTX_set_max_send_fragment
@@ -5760,6 +5775,7 @@ OPENSSL_EXPORT int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg);
57605775
#define SSL_session_reused SSL_session_reused
57615776
#define SSL_set0_chain SSL_set0_chain
57625777
#define SSL_set1_chain SSL_set1_chain
5778+
#define SSL_set1_curves SSL_set1_curves
57635779
#define SSL_set1_groups SSL_set1_groups
57645780
#define SSL_set_max_cert_list SSL_set_max_cert_list
57655781
#define SSL_set_max_send_fragment SSL_set_max_send_fragment

ssl/ssl_lib.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3267,3 +3267,29 @@ int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg) {
32673267
ctx->legacy_ocsp_callback_arg = arg;
32683268
return 1;
32693269
}
3270+
3271+
uint16_t SSL_get_curve_id(const SSL *ssl) { return SSL_get_group_id(ssl); }
3272+
3273+
const char *SSL_get_curve_name(uint16_t curve_id) {
3274+
return SSL_get_group_name(curve_id);
3275+
}
3276+
3277+
size_t SSL_get_all_curve_names(const char **out, size_t max_out) {
3278+
return SSL_get_all_group_names(out, max_out);
3279+
}
3280+
3281+
int SSL_CTX_set1_curves(SSL_CTX *ctx, const int *curves, size_t num_curves) {
3282+
return SSL_CTX_set1_groups(ctx, curves, num_curves);
3283+
}
3284+
3285+
int SSL_set1_curves(SSL *ssl, const int *curves, size_t num_curves) {
3286+
return SSL_set1_groups(ssl, curves, num_curves);
3287+
}
3288+
3289+
int SSL_CTX_set1_curves_list(SSL_CTX *ctx, const char *curves) {
3290+
return SSL_CTX_set1_groups_list(ctx, curves);
3291+
}
3292+
3293+
int SSL_set1_curves_list(SSL *ssl, const char *curves) {
3294+
return SSL_set1_groups_list(ssl, curves);
3295+
}

0 commit comments

Comments
 (0)