Skip to content

Commit 9afac70

Browse files
committed
Implement SSL_CIPHER_get_auth_nid
1 parent 63790ee commit 9afac70

File tree

6 files changed

+28
-6
lines changed

6 files changed

+28
-6
lines changed

MATRIX.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
| `SRP_Calc_A_param` [^deprecatedin_3_0] [^srp] | | | | |
3131
| `SSL_CIPHER_description` | | :white_check_mark: | | :white_check_mark: |
3232
| `SSL_CIPHER_find` | | :white_check_mark: | :white_check_mark: | :white_check_mark: |
33-
| `SSL_CIPHER_get_auth_nid` | | | :white_check_mark: | |
33+
| `SSL_CIPHER_get_auth_nid` | | | :white_check_mark: | :white_check_mark: |
3434
| `SSL_CIPHER_get_bits` | | | :white_check_mark: | :white_check_mark: |
3535
| `SSL_CIPHER_get_cipher_nid` | | | | |
3636
| `SSL_CIPHER_get_digest_nid` | | | | |

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const ENTRYPOINTS: &[&str] = &[
5252
"SSL_check_private_key",
5353
"SSL_CIPHER_description",
5454
"SSL_CIPHER_find",
55+
"SSL_CIPHER_get_auth_nid",
5556
"SSL_CIPHER_get_bits",
5657
"SSL_CIPHER_get_id",
5758
"SSL_CIPHER_get_name",

src/constants.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,7 @@ pub fn named_group_to_nid(group: NamedGroup) -> Option<c_int> {
150150
_ => None,
151151
}
152152
}
153+
154+
pub(super) const NID_AUTH_ANY: c_int = 1064;
155+
pub(super) const NID_AUTH_ECDSA: c_int = 1047;
156+
pub(super) const NID_AUTH_RSA: c_int = 1046;

src/entry.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,12 @@ entry! {
15501550
}
15511551
}
15521552

1553+
entry! {
1554+
pub fn _SSL_CIPHER_get_auth_nid(cipher: *const SSL_CIPHER) -> c_int {
1555+
try_ref_from_ptr!(cipher).auth
1556+
}
1557+
}
1558+
15531559
entry! {
15541560
pub fn _SSL_CIPHER_get_protocol_id(cipher: *const SSL_CIPHER) -> u16 {
15551561
try_ref_from_ptr!(cipher).protocol_id()

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ static TLS_METHOD: SslMethod = SslMethod {
9393
/// Functions that return `SSL_CIPHER` give static-lifetime pointers.
9494
pub struct SslCipher {
9595
pub bits: usize,
96+
pub auth: i32,
9697
pub openssl_name: &'static CStr,
9798
pub standard_name: &'static CStr,
9899
pub version: &'static CStr,
@@ -139,6 +140,7 @@ impl SslCipher {
139140

140141
static TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: SslCipher = SslCipher {
141142
rustls: &provider::cipher_suite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
143+
auth: constants::NID_AUTH_ECDSA,
142144
bits: 128,
143145
openssl_name: c"ECDHE-ECDSA-AES128-GCM-SHA256",
144146
standard_name: c"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
@@ -148,6 +150,7 @@ static TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: SslCipher = SslCipher {
148150

149151
static TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: SslCipher = SslCipher {
150152
rustls: &provider::cipher_suite::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
153+
auth: constants::NID_AUTH_ECDSA,
151154
bits: 256,
152155
openssl_name: c"ECDHE-ECDSA-AES256-GCM-SHA384",
153156
standard_name: c"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
@@ -157,6 +160,7 @@ static TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: SslCipher = SslCipher {
157160

158161
static TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
159162
rustls: &provider::cipher_suite::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
163+
auth: constants::NID_AUTH_ECDSA,
160164
bits: 256,
161165
openssl_name: c"ECDHE-ECDSA-CHACHA20-POLY1305",
162166
standard_name: c"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
@@ -166,6 +170,7 @@ static TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
166170

167171
static TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: SslCipher = SslCipher {
168172
rustls: &provider::cipher_suite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
173+
auth: constants::NID_AUTH_RSA,
169174
bits: 128,
170175
openssl_name: c"ECDHE-RSA-AES128-GCM-SHA256",
171176
standard_name: c"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
@@ -175,6 +180,7 @@ static TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: SslCipher = SslCipher {
175180

176181
static TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: SslCipher = SslCipher {
177182
rustls: &provider::cipher_suite::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
183+
auth: constants::NID_AUTH_RSA,
178184
bits: 256,
179185
openssl_name: c"ECDHE-RSA-AES256-GCM-SHA384",
180186
standard_name: c"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
@@ -184,6 +190,7 @@ static TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: SslCipher = SslCipher {
184190

185191
static TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
186192
rustls: &provider::cipher_suite::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
193+
auth: constants::NID_AUTH_RSA,
187194
bits: 256,
188195
openssl_name: c"ECDHE-RSA-CHACHA20-POLY1305",
189196
standard_name: c"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
@@ -193,6 +200,7 @@ static TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
193200

194201
static TLS13_AES_128_GCM_SHA256: SslCipher = SslCipher {
195202
rustls: &provider::cipher_suite::TLS13_AES_128_GCM_SHA256,
203+
auth: constants::NID_AUTH_ANY,
196204
bits: 128,
197205
openssl_name: c"TLS_AES_128_GCM_SHA256",
198206
standard_name: c"TLS_AES_128_GCM_SHA256",
@@ -202,6 +210,7 @@ static TLS13_AES_128_GCM_SHA256: SslCipher = SslCipher {
202210

203211
static TLS13_AES_256_GCM_SHA384: SslCipher = SslCipher {
204212
rustls: &provider::cipher_suite::TLS13_AES_256_GCM_SHA384,
213+
auth: constants::NID_AUTH_ANY,
205214
bits: 256,
206215
openssl_name: c"TLS_AES_256_GCM_SHA384",
207216
standard_name: c"TLS_AES_256_GCM_SHA384",
@@ -211,6 +220,7 @@ static TLS13_AES_256_GCM_SHA384: SslCipher = SslCipher {
211220

212221
static TLS13_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
213222
rustls: &provider::cipher_suite::TLS13_CHACHA20_POLY1305_SHA256,
223+
auth: constants::NID_AUTH_ANY,
214224
bits: 256,
215225
openssl_name: c"TLS_CHACHA20_POLY1305_SHA256",
216226
standard_name: c"TLS_CHACHA20_POLY1305_SHA256",

tests/ciphers.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +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 ", SSL_CIPHER_get_id(cipher),
12-
SSL_CIPHER_get_protocol_id(cipher));
11+
printf("openssl_id=0x%08x protocol_id=0x%08x auth=%d ",
12+
SSL_CIPHER_get_id(cipher), SSL_CIPHER_get_protocol_id(cipher),
13+
SSL_CIPHER_get_auth_nid(cipher));
1314
} else {
14-
// SSL_CIPHER_get_id(NULL) and SSL_CIPHER_get_protocol_id(NULL) both
15-
// segfault
16-
printf("openssl_id=undef protocol_id=undef ");
15+
// 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 ");
1718
}
1819
int alg_bits = -1;
1920
printf("bits=%d ", SSL_CIPHER_get_bits(cipher, &alg_bits));

0 commit comments

Comments
 (0)