Skip to content

Commit 54d502a

Browse files
committed
Implement SSL_CIPHER_get_kx_nid
1 parent 9afac70 commit 54d502a

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

MATRIX.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
| `SSL_CIPHER_get_digest_nid` | | | | |
3737
| `SSL_CIPHER_get_handshake_digest` | | | | |
3838
| `SSL_CIPHER_get_id` | | :white_check_mark: | :white_check_mark: | :white_check_mark: |
39-
| `SSL_CIPHER_get_kx_nid` | | | | |
39+
| `SSL_CIPHER_get_kx_nid` | | | | :white_check_mark: |
4040
| `SSL_CIPHER_get_name` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
4141
| `SSL_CIPHER_get_protocol_id` | | | | :white_check_mark: |
4242
| `SSL_CIPHER_get_version` | | | | :white_check_mark: |

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const ENTRYPOINTS: &[&str] = &[
5555
"SSL_CIPHER_get_auth_nid",
5656
"SSL_CIPHER_get_bits",
5757
"SSL_CIPHER_get_id",
58+
"SSL_CIPHER_get_kx_nid",
5859
"SSL_CIPHER_get_name",
5960
"SSL_CIPHER_get_protocol_id",
6061
"SSL_CIPHER_get_version",

src/constants.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,6 @@ pub fn named_group_to_nid(group: NamedGroup) -> Option<c_int> {
154154
pub(super) const NID_AUTH_ANY: c_int = 1064;
155155
pub(super) const NID_AUTH_ECDSA: c_int = 1047;
156156
pub(super) const NID_AUTH_RSA: c_int = 1046;
157+
158+
pub(super) const NID_KX_ANY: c_int = 1063;
159+
pub(super) const NID_KX_ECDHE: c_int = 1038;

src/entry.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,12 @@ entry! {
15561556
}
15571557
}
15581558

1559+
entry! {
1560+
pub fn _SSL_CIPHER_get_kx_nid(cipher: *const SSL_CIPHER) -> c_int {
1561+
try_ref_from_ptr!(cipher).kx
1562+
}
1563+
}
1564+
15591565
entry! {
15601566
pub fn _SSL_CIPHER_get_protocol_id(cipher: *const SSL_CIPHER) -> u16 {
15611567
try_ref_from_ptr!(cipher).protocol_id()

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static TLS_METHOD: SslMethod = SslMethod {
9494
pub struct SslCipher {
9595
pub bits: usize,
9696
pub auth: i32,
97+
pub kx: i32,
9798
pub openssl_name: &'static CStr,
9899
pub standard_name: &'static CStr,
99100
pub version: &'static CStr,
@@ -141,6 +142,7 @@ impl SslCipher {
141142
static TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: SslCipher = SslCipher {
142143
rustls: &provider::cipher_suite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
143144
auth: constants::NID_AUTH_ECDSA,
145+
kx: constants::NID_KX_ECDHE,
144146
bits: 128,
145147
openssl_name: c"ECDHE-ECDSA-AES128-GCM-SHA256",
146148
standard_name: c"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
@@ -151,6 +153,7 @@ static TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: SslCipher = SslCipher {
151153
static TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: SslCipher = SslCipher {
152154
rustls: &provider::cipher_suite::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
153155
auth: constants::NID_AUTH_ECDSA,
156+
kx: constants::NID_KX_ECDHE,
154157
bits: 256,
155158
openssl_name: c"ECDHE-ECDSA-AES256-GCM-SHA384",
156159
standard_name: c"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
@@ -161,6 +164,7 @@ static TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: SslCipher = SslCipher {
161164
static TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
162165
rustls: &provider::cipher_suite::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
163166
auth: constants::NID_AUTH_ECDSA,
167+
kx: constants::NID_KX_ECDHE,
164168
bits: 256,
165169
openssl_name: c"ECDHE-ECDSA-CHACHA20-POLY1305",
166170
standard_name: c"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
@@ -171,6 +175,7 @@ static TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
171175
static TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: SslCipher = SslCipher {
172176
rustls: &provider::cipher_suite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
173177
auth: constants::NID_AUTH_RSA,
178+
kx: constants::NID_KX_ECDHE,
174179
bits: 128,
175180
openssl_name: c"ECDHE-RSA-AES128-GCM-SHA256",
176181
standard_name: c"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
@@ -181,6 +186,7 @@ static TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: SslCipher = SslCipher {
181186
static TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: SslCipher = SslCipher {
182187
rustls: &provider::cipher_suite::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
183188
auth: constants::NID_AUTH_RSA,
189+
kx: constants::NID_KX_ECDHE,
184190
bits: 256,
185191
openssl_name: c"ECDHE-RSA-AES256-GCM-SHA384",
186192
standard_name: c"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
@@ -191,6 +197,7 @@ static TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: SslCipher = SslCipher {
191197
static TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
192198
rustls: &provider::cipher_suite::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
193199
auth: constants::NID_AUTH_RSA,
200+
kx: constants::NID_KX_ECDHE,
194201
bits: 256,
195202
openssl_name: c"ECDHE-RSA-CHACHA20-POLY1305",
196203
standard_name: c"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
@@ -201,6 +208,7 @@ static TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
201208
static TLS13_AES_128_GCM_SHA256: SslCipher = SslCipher {
202209
rustls: &provider::cipher_suite::TLS13_AES_128_GCM_SHA256,
203210
auth: constants::NID_AUTH_ANY,
211+
kx: constants::NID_KX_ANY,
204212
bits: 128,
205213
openssl_name: c"TLS_AES_128_GCM_SHA256",
206214
standard_name: c"TLS_AES_128_GCM_SHA256",
@@ -211,6 +219,7 @@ static TLS13_AES_128_GCM_SHA256: SslCipher = SslCipher {
211219
static TLS13_AES_256_GCM_SHA384: SslCipher = SslCipher {
212220
rustls: &provider::cipher_suite::TLS13_AES_256_GCM_SHA384,
213221
auth: constants::NID_AUTH_ANY,
222+
kx: constants::NID_KX_ANY,
214223
bits: 256,
215224
openssl_name: c"TLS_AES_256_GCM_SHA384",
216225
standard_name: c"TLS_AES_256_GCM_SHA384",
@@ -221,6 +230,7 @@ static TLS13_AES_256_GCM_SHA384: SslCipher = SslCipher {
221230
static TLS13_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
222231
rustls: &provider::cipher_suite::TLS13_CHACHA20_POLY1305_SHA256,
223232
auth: constants::NID_AUTH_ANY,
233+
kx: constants::NID_KX_ANY,
224234
bits: 256,
225235
openssl_name: c"TLS_CHACHA20_POLY1305_SHA256",
226236
standard_name: c"TLS_CHACHA20_POLY1305_SHA256",

tests/ciphers.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
static void print_cipher(const SSL_CIPHER *cipher) {
1010
if (cipher) {
11-
printf("openssl_id=0x%08x protocol_id=0x%08x auth=%d ",
11+
printf("openssl_id=0x%08x protocol_id=0x%08x auth=%d kx=%d ",
1212
SSL_CIPHER_get_id(cipher), SSL_CIPHER_get_protocol_id(cipher),
13-
SSL_CIPHER_get_auth_nid(cipher));
13+
SSL_CIPHER_get_auth_nid(cipher), SSL_CIPHER_get_kx_nid(cipher));
1414
} else {
1515
// SSL_CIPHER_get_id(NULL), SSL_CIPHER_get_protocol_id(NULL),
16-
// SSL_CIPHER_get_auth_nid(NULL) all segfault
17-
printf("openssl_id=undef protocol_id=undef auth=undef ");
16+
// SSL_CIPHER_get_auth_nid(NULL), SSL_CIPHER_get_kx_nid(NULL) all segfault
17+
printf("openssl_id=undef protocol_id=undef auth=undef kx=undef ");
1818
}
1919
int alg_bits = -1;
2020
printf("bits=%d ", SSL_CIPHER_get_bits(cipher, &alg_bits));

0 commit comments

Comments
 (0)