Skip to content

Commit a9dba77

Browse files
committed
Clean, and tweak returned values, in some bssl-compat functions
Signed-off-by: Dario Cillerai <[email protected]>
1 parent 0b27124 commit a9dba77

File tree

2 files changed

+7
-70
lines changed

2 files changed

+7
-70
lines changed

bssl-compat/source/SSL_CTX_set_compliance_policy.cc

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,6 @@
66
#define OPENSSL_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
77

88

9-
int SSL_set_strict_cipher_list(SSL *ssl, const char *str) {
10-
int ret;
11-
if(SSL_version(ssl) <= TLS1_2_VERSION) {
12-
// TLSv1.2 and below
13-
ret = ossl.ossl_SSL_set_cipher_list(ssl, str);
14-
}
15-
else {
16-
// TLSv1.3
17-
ret = ossl.ossl_SSL_set_ciphersuites(ssl, str);
18-
}
19-
if (ret==0) {
20-
return 0;
21-
}
22-
std::string osslstr {iana_2_ossl_names(str)};
23-
STACK_OF(SSL_CIPHER)* ciphers = reinterpret_cast<STACK_OF(SSL_CIPHER)*>(ossl.ossl_SSL_get_ciphers(ssl));
24-
char* dup = strdup(osslstr.c_str());
25-
char* token = strtok(dup, ":+![|]");
26-
while (token != NULL) {
27-
std::string str1(token);
28-
bool found = false;
29-
for (int i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) {
30-
const SSL_CIPHER* cipher = sk_SSL_CIPHER_value(ciphers, i);
31-
std::string str2(SSL_CIPHER_get_name(cipher));
32-
if (str1.compare(str2) == 0) {
33-
found = true;
34-
}
35-
}
36-
37-
if (!found && str1.compare("-ALL") && str1.compare("ALL")) {
38-
free(dup);
39-
return 0;
40-
}
41-
42-
token = strtok(NULL, ":[]|");
43-
}
44-
45-
free(dup);
46-
return 1;
47-
}
48-
49-
50-
int SSL_set_verify_algorithm_prefs(SSL *ssl,
51-
const char *prefs) {
52-
// TODO: couldn't find an equivalent in OpenSSL
53-
return 1;
54-
}
55-
56-
57-
int SSL_CTX_set_verify_algorithm_prefs(SSL_CTX *ctx, const char *prefs) {
58-
// TODO: couldn't find an equivalent in OpenSSL
59-
return 1;
60-
}
61-
629
namespace fips202205 {
6310

6411
// (References are to SP 800-52r2):
@@ -111,22 +58,7 @@ static int Configure(SSL_CTX *ctx) {
11158
// it's easier to drop them.
11259
SSL_CTX_set_strict_cipher_list(ctx, kTLS12Ciphers) &&
11360
ossl.ossl_SSL_CTX_set1_groups (ctx, kGroups, OPENSSL_ARRAY_SIZE(kGroups)) &&
114-
ossl.ossl_SSL_CTX_set1_sigalgs_list(ctx, kSigAlgs) &&
115-
SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs);
116-
}
117-
118-
static int Configure(SSL *ssl) {
119-
// tls13_cipher_policy field not present in OpenSSL
120-
// ssl->config->tls13_cipher_policy = ssl_compliance_policy_fips_202205;
121-
122-
// See |Configure(SSL_CTX)|, above, for reasoning.
123-
return ossl.ossl_SSL_set_min_proto_version(ssl, TLS1_2_VERSION) &&
124-
ossl.ossl_SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
125-
SSL_set_strict_cipher_list(ssl, kTLS12Ciphers) &&
126-
ossl.ossl_SSL_set1_groups(ssl, kGroups, OPENSSL_ARRAY_SIZE(kGroups)) &&
127-
ossl.ossl_SSL_set1_sigalgs_list(ssl, kSigAlgs) &&
128-
SSL_set_verify_algorithm_prefs(ssl, kSigAlgs)
129-
;
61+
ossl.ossl_SSL_CTX_set1_sigalgs_list(ctx, kSigAlgs);
13062
}
13163

13264
} // namespace fips202205

bssl-compat/source/SSL_CTX_set_select_certificate_cb.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <openssl/ssl.h>
22
#include <ossl.h>
3+
#include "log.h"
34

45

56
/**
@@ -113,7 +114,11 @@ static int ssl_ctx_client_hello_cb(SSL *ssl, int *alert, void *arg) {
113114
case ssl_select_cert_success: return ossl_SSL_CLIENT_HELLO_SUCCESS;
114115
case ssl_select_cert_retry: return ossl_SSL_CLIENT_HELLO_RETRY;
115116
case ssl_select_cert_error: return ossl_SSL_CLIENT_HELLO_ERROR;
116-
case ssl_select_cert_disable_ech: return ossl_SSL_CLIENT_HELLO_RETRY;
117+
case ssl_select_cert_disable_ech: {
118+
// None of the Envoy code ever returns the new ssl_select_cert_disable_ech enumerator
119+
bssl_compat_error("Unexpected ssl_select_cert_disable_ech result from callback");
120+
return ossl_SSL_CLIENT_HELLO_ERROR;
121+
}
117122
};
118123
}
119124

0 commit comments

Comments
 (0)