Skip to content

Commit 3fff5e8

Browse files
committed
wolfKeyMgr v1.0:
* Support for Curve25519 and Curve448 in key manager. * Support for Curve25519 in middle-box decryption. * Support for loading all supported ephemeral keys. * Refactor common ETSI client test code. * Improved middle-box decryption to better handle concurrent keys of different formats. * Improved handling for not compiled in cases. * Fix for ./configure config summary.
1 parent 6de1fdd commit 3fff5e8

29 files changed

+770
-505
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ $ ./autogen.sh
5050
$ git clone https://github.com/wolfssl/wolfssl
5151
$ cd wolfssl
5252
$ ./autogen.sh
53-
$ ./configure --enable-sniffer CFLAGS="-DWOLFSSL_DH_EXTRA"
53+
$ ./configure --enable-sniffer --enable-curve25519 CFLAGS="-DWOLFSSL_DH_EXTRA"
5454
$ make
5555
$ make check # (optional, but highly recommended)
5656
$ sudo make install
@@ -62,6 +62,7 @@ Notes:
6262
* To enable all ARMv8 (aarch64) speedups use `--enable-armasm --enable-sp --enable-sp-asm`
6363
* Requires at least wolfSSL v4.8.0 with PR:
6464
- https://github.com/wolfSSL/wolfssl/pull/4181
65+
- https://github.com/wolfSSL/wolfssl/pull/4335 (required for Curve25519)
6566

6667
2. Install libevent version 2.0+
6768

@@ -101,7 +102,7 @@ Notes:
101102
* A custom install location can be specified using: `./configure --prefix=/opt/local`
102103
* `autogen.sh` is script to generate configure, you'll need the autoconf tools
103104
installed, then proceed to the next step.
104-
105+
* `src/wolfkeymgr` is the key manager service / dameon. A make install will typically put it into `/usr/local/bin/wolfkeymgr` or ``/usr/bin/wolfkeymgr`.
105106

106107
## Examples
107108

@@ -115,7 +116,7 @@ This application handles secure distribution and optional storage of the generat
115116

116117
```sh
117118
$ ./src/wolfkeymgr -?
118-
wolfKeyManager 0.11
119+
wolfKeyManager 1.0
119120
-? Help, print this usage
120121
-i Do not chdir / in daemon mode
121122
-b Daemon mode, run in background
@@ -141,7 +142,7 @@ This demonstrates secure interactions with the key manager service using the ETS
141142

142143
```sh
143144
$ ./examples/etsi_test/etsi_test -?
144-
etsi_test 0.11
145+
etsi_test 1.0
145146
-? Help, print this usage
146147
-e Error mode, force error response
147148
-h <str> Host to connect to, default localhost
@@ -316,8 +317,8 @@ Content-Length: 44
316317
```
317318

318319
## Features Missing
320+
319321
* Find error response message (currently disconnects with socket FIN)
320-
* Curve25519 and Curve448
321322
* X509 Visibility support
322323
* TLS v1.2 ephemeral key support
323324

configure.ac

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
AC_PREREQ(2.59)
77

8-
AC_INIT([wolfKeyManager],[0.11],[http://www.wolfssl.com])
8+
AC_INIT([wolfKeyManager],[1.0],[http://www.wolfssl.com])
99
AC_CONFIG_AUX_DIR(config)
1010
AC_CONFIG_HEADERS([wolfkeymgr/config.h])
1111
AC_CONFIG_MACRO_DIR(m4)
@@ -71,7 +71,7 @@ LT_PREREQ([2.2])
7171
LT_INIT([disable-static win32-dll])
7272

7373
# Shared library versioning
74-
WOLFKM_LIBRARY_VERSION=7:0:0
74+
WOLFKM_LIBRARY_VERSION=8:0:0
7575
# | | |
7676
# +------+ | +---+
7777
# | | |
@@ -252,11 +252,13 @@ echo ""
252252
echo " * Installation prefix: $prefix"
253253
echo " * System type: $host_vendor-$host_os"
254254
echo " * Host CPU: $host_cpu"
255-
echo " * C Compiler: $CC_VERSION"
255+
echo " * C Compiler: $CC"
256256
echo " * C Flags: $CFLAGS"
257+
echo " * C++ Compiler: $CXX"
258+
echo " * C++ Flags: $CXXFLAGS"
257259
echo " * CPP Flags: $CPPFLAGS"
260+
echo " * CCAS Flags: $CCASFLAGS"
258261
echo " * LIB Flags: $LIB"
259-
echo " * Debug enabled: $ax_enable_debug"
260262

261263
echo " * Vault $ENABLED_VAULT"
262264
echo " * Sniffer $ENABLED_SNIFFER"

examples/etsi_test/etsi_test.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ static int keyCb(EtsiClientCtx* client, EtsiKey* key, void* userCtx)
8484
ret = wolfSSL_CTX_set_ephemeral_key(tctx->ctx,
8585
keyAlgo, (char*)key->response, key->responseSz,
8686
WOLFSSL_FILETYPE_ASN1);
87+
if (ret == NOT_COMPILED_IN) {
88+
ret = 0; /* not compiled in case is okay */
89+
}
8790
#endif
8891
}
8992
if (ret == 0) {
@@ -170,7 +173,7 @@ static void* DoRequests(void* arg)
170173
if (ret != 0) {
171174
XLOG(WOLFKM_LOG_ERROR, "Error loading ETSI client key/cert %d!\n", ret);
172175
}
173-
ret = wolfEtsiClientConnect(client, info->host, info->port,
176+
ret = wolfEtsiClientConnect(client, info->host, info->port,
174177
info->timeoutSec);
175178
if (ret == 0) {
176179
/* setup test CTX to demonstrate loading static ephemeral */
@@ -328,7 +331,7 @@ int etsi_test(int argc, char** argv)
328331

329332
if (errorMode)
330333
return DoErrorMode();
331-
334+
332335
wolfEtsiClientInit();
333336

334337
if (poolSize == 0) {

examples/https/include.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ examples_https_client_DEPENDENCIES = src/libwolfkeymgr.la
1313

1414
noinst_PROGRAMS += examples/https/server
1515
noinst_HEADERS += examples/https/server.h
16-
examples_https_server_SOURCES = examples/https/server.c
16+
examples_https_server_SOURCES = examples/https/server.c \
17+
examples/test_config.c
1718
examples_https_server_LDADD = src/libwolfkeymgr.la $(LIB_STATIC_ADD)
1819
examples_https_server_DEPENDENCIES = src/libwolfkeymgr.la

examples/https/server.c

Lines changed: 15 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
static volatile int mStop = 0;
3030
static WKM_SOCKET_T listenFd = WKM_SOCKET_INVALID;
3131

32-
static EtsiClientCtx* gEtsiClient;
33-
static int etsi_client_get(WOLFSSL_CTX* ctx);
34-
3532
static void sig_handler(const int sig)
3633
{
3734
printf("SIGINT handled = %d.\n", sig);
@@ -40,6 +37,16 @@ static void sig_handler(const int sig)
4037
mStop = 1;
4138
}
4239

40+
static int etsi_key_cb(EtsiKey* key, void* cbCtx)
41+
{
42+
WOLFSSL_CTX* ctx = (WOLFSSL_CTX*)cbCtx;
43+
int ret = wolfEtsiKeyLoadCTX(key, ctx);
44+
if (ret == NOT_COMPILED_IN) {
45+
ret = 0; /* this is okay - if feature is not compiled in */
46+
}
47+
return ret;
48+
}
49+
4350
int https_server_test(int argc, char** argv)
4451
{
4552
int ret;
@@ -51,6 +58,7 @@ int https_server_test(int argc, char** argv)
5158
HttpHeader headers[2];
5259
const char* body = HTTPS_TEST_RESPONSE;
5360
SOCKADDR_IN_T clientAddr;
61+
const char* etsiServer = "https://" ETSI_TEST_HOST ":" ETSI_TEST_PORT_STR;
5462

5563
signal(SIGINT, sig_handler);
5664

@@ -61,7 +69,7 @@ int https_server_test(int argc, char** argv)
6169
printf("HTTPS Server: Port %d\n", HTTPS_TEST_PORT);
6270

6371
wolfSSL_Init();
64-
72+
6573
/* log setup */
6674
//wolfSSL_Debugging_ON();
6775
wolfKeyMgr_SetLogFile(NULL, 0, WOLFKM_LOG_DEBUG);
@@ -81,7 +89,7 @@ int https_server_test(int argc, char** argv)
8189
if (ret != 0) goto exit;
8290

8391
do {
84-
ret = etsi_client_get(ctx);
92+
ret = etsi_client_get_all(etsiServer, etsi_key_cb, ctx);
8593
if (ret != 0) {
8694
mStop = 1;
8795
goto end_sess;
@@ -91,14 +99,14 @@ int https_server_test(int argc, char** argv)
9199
HTTPS_TEST_TIMEOUT_SEC);
92100
if (ret == WOLFKM_BAD_TIMEOUT) continue;
93101
if (ret != 0) goto end_sess;
94-
102+
95103
printf("TLS Accept %s\n", wolfSocketAddrStr(&clientAddr));
96104

97105
/* Get HTTP request and print */
98106
dataSz = (int)sizeof(data);
99107
ret = wolfTlsRead(ssl, data, &dataSz, HTTPS_TEST_TIMEOUT_SEC);
100108
if (ret < 0) goto end_sess;
101-
109+
102110
ret = wolfHttpServer_ParseRequest(&req, data, dataSz);
103111
if (ret == 0) {
104112
wolfHttpRequestPrint(&req);
@@ -142,68 +150,6 @@ int https_server_test(int argc, char** argv)
142150
return ret;
143151
}
144152

145-
/* ETSI Client */
146-
static void etsi_client_cleanup(void)
147-
{
148-
if (gEtsiClient) {
149-
wolfEtsiClientFree(gEtsiClient);
150-
gEtsiClient = NULL;
151-
152-
wolfEtsiClientCleanup();
153-
}
154-
}
155-
static int etsi_client_get(WOLFSSL_CTX* ctx)
156-
{
157-
int ret = -1;
158-
static EtsiKey key;
159-
160-
/* setup key manager connection */
161-
if (gEtsiClient == NULL) {
162-
wolfEtsiClientInit();
163-
164-
gEtsiClient = wolfEtsiClientNew();
165-
if (gEtsiClient) {
166-
wolfEtsiClientAddCA(gEtsiClient, ETSI_TEST_CLIENT_CA);
167-
wolfEtsiClientSetKey(gEtsiClient,
168-
ETSI_TEST_CLIENT_KEY, ETSI_TEST_CLIENT_PASS,
169-
ETSI_TEST_CLIENT_CERT, WOLFSSL_FILETYPE_PEM);
170-
171-
ret = wolfEtsiClientConnect(gEtsiClient, ETSI_TEST_HOST,
172-
ETSI_TEST_PORT, ETSI_TEST_TIMEOUT_MS);
173-
if (ret != 0) {
174-
printf("Error connecting to ETSI server! %d\n", ret);
175-
etsi_client_cleanup();
176-
}
177-
}
178-
else {
179-
ret = WOLFKM_BAD_MEMORY;
180-
}
181-
}
182-
if (gEtsiClient) {
183-
ret = wolfEtsiClientGet(gEtsiClient, &key, ETSI_TEST_KEY_TYPE,
184-
NULL, NULL, ETSI_TEST_TIMEOUT_MS);
185-
/* positive return means new key returned */
186-
/* zero means, same key is used */
187-
/* negative means error */
188-
if (ret < 0) {
189-
printf("Error getting ETSI static ephemeral key! %d\n", ret);
190-
etsi_client_cleanup();
191-
}
192-
else if (ret > 0) {
193-
/* got new key */
194-
printf("Got ETSI static ephemeral key (%d bytes)\n", key.responseSz);
195-
wolfEtsiKeyPrint(&key);
196-
ret = wolfEtsiKeyLoadCTX(&key, ctx);
197-
}
198-
else {
199-
/* key has not changed */
200-
printf("ETSI Key Cached (valid for %lu sec)\n",
201-
key.expires - wolfGetCurrentTimeT());
202-
}
203-
}
204-
return ret;
205-
}
206-
207153
#ifndef NO_MAIN_DRIVER
208154
int main(int argc, char* argv[])
209155
{

examples/include.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ include examples/etsi_test/include.am
66
include examples/middlebox/include.am
77
include examples/https/include.am
88

9-
EXTRA_DIST += examples/test_config.h
9+
EXTRA_DIST += examples/test_config.h \
10+
examples/test_config.c

0 commit comments

Comments
 (0)