cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
pqc_layer.c
Go to the documentation of this file.
1
8#include <cwist/sys/app/app.h>
9#include <cwist/core/log.h>
10#include <openssl/ssl.h>
11#include <string.h>
12
20 if (!ctx) return false;
21
22 if (!app || !app->pqc_layer_enabled) return true;
23
24#ifdef CWIST_TLS_MBEDTLS
25 /* mbedTLS 3.6 LTS has no hybrid post-quantum key exchange (X25519MLKEM768
26 * is BoringSSL-only): degrade to TLS 1.3 with classical groups instead of
27 * silently pretending PQC is on. */
28 CWIST_LOG_WARN("PQC layer: mbedTLS backend has no hybrid post-quantum groups; "
29 "enforcing TLS 1.3 with classical key exchange");
31 CWIST_LOG_ERROR("PQC layer requires TLS 1.3");
32 return false;
33 }
34 return true;
35#else
36 const char *groups = app->tls_groups;
37 if (!groups) {
38 groups = "X25519MLKEM768:X25519:P-256";
39 }
40
41 if (SSL_CTX_set1_groups_list(ctx, groups) != 1) {
42 CWIST_LOG_ERROR("PQC layer rejected hybrid TLS groups: %s", groups);
43 return false;
44 }
45
47 CWIST_LOG_ERROR("PQC layer requires TLS 1.3");
48 return false;
49 }
50
52
53 CWIST_LOG_INFO("PQC Layer enabled: groups=%s protocol=TLS1.3", groups);
54
55 return true;
56#endif
57}
Lightweight macro-based internal logging for CWIST.
#define CWIST_LOG_ERROR(fmt,...)
Definition log.h:57
#define CWIST_LOG_INFO(fmt,...)
Definition log.h:55
#define CWIST_LOG_WARN(fmt,...)
Definition log.h:56
size_t cap
Definition otel.c:56
bool cwist_tls_apply_pqc_layer(cwist_app *app, SSL_CTX *ctx)
Apply PQC hybrid key exchange settings to an SSL context.
Definition pqc_layer.c:19
mbedTLS TLS backend: OpenSSL-shaped seam over the CWIST TLS subset.
#define TLS1_3_VERSION
Definition ssl.h:49
#define SSL_CTX_set_options
Definition ssl.h:107
#define SSL_OP_NO_TLSv1
Definition ssl.h:66
#define SSL_OP_NO_TLSv1_2
Definition ssl.h:68
#define SSL_CTX_set1_groups_list
Definition ssl.h:126
struct cwist_mtls_ctx SSL_CTX
Definition ssl.h:43
#define SSL_OP_NO_TLSv1_1
Definition ssl.h:67
#define SSL_CTX_set_min_proto_version
Definition ssl.h:106
Main Application Context.
Definition app.h:155
char * tls_groups
Explicit TLS groups override (NULL = automatic)
Definition app.h:197
bool pqc_layer_enabled
PQC Layer enabled flag.
Definition app.h:195
Core Application Structure and Lifecycle Management.