Skip to content

Commit d3c9b58

Browse files
authored
Merge pull request #4 from dgarske/rel_v1.1
2 parents 8e76166 + 28637b7 commit d3c9b58

File tree

8 files changed

+72
-41
lines changed

8 files changed

+72
-41
lines changed

ChangeLog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# wolfKeyMgr v1.1 (Nov 9, 2021)
2+
* Added support for x448 (curve448).
3+
* Added argument support to HTTP server.
4+
* Fixed `ets_test` help messages for fingerprint and context string.
5+
* Fix to use `memmove` for relocation of memory within same buffer.
6+
* Fixed sanitizer and scan-build reports.
7+
* Fixed support for `HAVE_PUBLIC_FFDHE` not defined.
8+
* Fixed HTTPS example server to send shutdown.
9+
* Renamed "ETSI" API/structs to be "ETS" (Enterprise Transport Security) not ETSI org.
10+
* Improved error reporting when connection to key manager fails.
11+
* Improved help on middlebox/decrypt tool.
12+
113
# wolfKeyMgr v1.0 (Sep 1, 2021)
214
* Support for Curve25519 and Curve448 in key manager.
315
* Support for Curve25519 in middle-box decryption.

README.md

Lines changed: 22 additions & 12 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 --enable-curve25519 CFLAGS="-DWOLFSSL_DH_EXTRA"
53+
$ ./configure --enable-sniffer --enable-curve25519 --enable-curve448 CFLAGS="-DWOLFSSL_DH_EXTRA"
5454
$ make
5555
$ make check # (optional, but highly recommended)
5656
$ sudo make install
@@ -60,9 +60,9 @@ Notes:
6060

6161
* To enable all Intel (AESNI/AVX) speedups use `--enable-intelasm --enable-sp --enable-sp-asm`
6262
* To enable all ARMv8 (aarch64) speedups use `--enable-armasm --enable-sp --enable-sp-asm`
63-
* Requires at least wolfSSL v4.8.0 with PR:
64-
- https://github.com/wolfSSL/wolfssl/pull/4181
65-
- https://github.com/wolfSSL/wolfssl/pull/4335 (required for Curve25519)
63+
64+
* Requires at least wolfSSL v5.0.0 with PR:
65+
- https://github.com/wolfSSL/wolfssl/pull/4522 (required for Curve448)
6666

6767
2. Install libevent version 2.0+
6868

@@ -116,22 +116,25 @@ This application handles secure distribution and optional storage of the generat
116116

117117
```sh
118118
$ ./src/wolfkeymgr -?
119-
wolfKeyManager 1.0
119+
wolfKeyManager 1.1
120120
-? Help, print this usage
121121
-i Do not chdir / in daemon mode
122122
-b Daemon mode, run in background
123123
-p <str> Pid File name, default ./wolfkeymgr.pid
124+
-P <port> Listener port, default 8119
124125
-l <num> Log Level (1=Error to 4=Debug), default 4
125126
-f <str> Log file name, default None
126127
-o <num> Max open files, default 1024
127128
-s <num> Seconds to timeout non-push connections, default 60
128129
-r <num> Key renewal timeout, default 3600
130+
-u <num> Key renewal max use count, default 100
129131
-t <num> Thread pool size, default 16
130-
-k <pem> TLS Server TLS Key, default ./certs/server-key.pem
132+
-k <pem> TLS Server TLS Key, default ./certs/server-rsa-key.pem
131133
-w <pass> TLS Server Key Password, default wolfssl
132-
-c <pem> TLS Server Certificate, default ./certs/server-cert.pem
134+
-c <pem> TLS Server Certificate, default ./certs/server-rsa-cert.pem
133135
-A <pem> TLS CA Certificate, default ./certs/ca-cert.pem
134136
-K <keyt> Key Type: SECP256R1, FFDHE_2048, X25519 or X448 (default SECP256R1)
137+
-v <file> Vault file for key storage, default ./wolfkeymgr.vault
135138
```
136139

137140
To exit the key manager use ctrl+c.
@@ -142,7 +145,7 @@ This demonstrates secure interactions with the key manager service using the ETS
142145

143146
```sh
144147
$ ./examples/ets_test/ets_test -?
145-
ets_test 1.0
148+
ets_test 1.1
146149
-? Help, print this usage
147150
-e Error mode, force error response
148151
-h <str> Host to connect to, default localhost
@@ -158,8 +161,8 @@ ets_test 1.0
158161
-c <pem> TLS Client Certificate, default certs/client-cert.pem
159162
-A <pem> TLS CA Certificate, default certs/ca-cert.pem
160163
-K <keyt> Key Type: SECP256R1, FFDHE_2048, X25519 or X448 (default SECP256R1)
161-
-F <fprint> Fingerprint of ephemeral public key (first 80-bit of pkey hash as hex string)
162-
-C <ctxstr> Context string (used for multiple servers)
164+
-F <fprint> Fingerprint to find (first 80-bit of pkey hash as hex string)
165+
-C <name> Unique key name (used for multiple servers)
163166
```
164167

165168
This client also support stress testing options:
@@ -225,8 +228,15 @@ This is a passive way to decrypt TLS traffic including Perfect Forward Secrecy (
225228
This can be run in a real-time mode capturing ethernet traffic on a port for one or more server interfaces. It can also be run passing a previously captured pcap file.
226229

227230
```sh
228-
./examples/middlebox/decrypt -?
229-
usage: ./decrypt or ./decrypt dumpFile keyServerURL [server] [port] [password]
231+
$ ./examples/middlebox/decrypt -?
232+
decrypt 1.1
233+
usage: ./decrypt or ./decrypt pcapFile keyServerURL [server] [port] [password]
234+
-? Help, print this usage
235+
pcapFile A previously saved pcap file
236+
keyServerURL Key Manager URL or private key as PEM (default https://localhost:8119)
237+
server The server’s IP address (v4 or v6) (default 127.0.0.1)
238+
port The server port to sniff (default 443)
239+
password Private Key Password if required
230240
```
231241
232242

configure.ac

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

66
AC_PREREQ(2.59)
77

8-
AC_INIT([wolfKeyManager],[1.0],[http://www.wolfssl.com])
8+
AC_INIT([wolfKeyManager],[1.1],[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=8:0:0
74+
WOLFKM_LIBRARY_VERSION=9:0:0
7575
# | | |
7676
# +------+ | +---+
7777
# | | |

src/mod_http.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ static void HttpParseHeader(HttpHeader* headers, word32* headerCount, char* hdrS
165165
int wolfHttpServer_ParseRequest(HttpReq* req, byte* buf, word32 sz)
166166
{
167167
char* sec = (char*)buf, *endline, *last;
168-
word32 len = sz;
169168
word32 itemSz;
170169

171170
if (req == NULL) {
@@ -185,7 +184,7 @@ int wolfHttpServer_ParseRequest(HttpReq* req, byte* buf, word32 sz)
185184
}
186185
req->method = sec;
187186
itemSz = strlen(sec) + 1; /* include space */
188-
sec += itemSz; len -= itemSz;
187+
sec += itemSz;
189188

190189
/* Find end of line */
191190
endline = strstr(sec, kCrlf);
@@ -291,7 +290,6 @@ int wolfHttpServer_EncodeResponse(int rspCode, const char* message,
291290
bodySz = remain;
292291
memcpy(out, body, bodySz);
293292
out += bodySz;
294-
remain -= bodySz;
295293
}
296294

297295
/* calculate total length */
@@ -306,7 +304,6 @@ int wolfHttpServer_EncodeResponse(int rspCode, const char* message,
306304
int wolfHttpClient_ParseResponse(HttpRsp* rsp, char* buf, word32 sz)
307305
{
308306
char* sec = buf, *endline;
309-
word32 len = sz;
310307
word32 itemSz;
311308

312309
if (rsp == NULL) {
@@ -322,7 +319,7 @@ int wolfHttpClient_ParseResponse(HttpRsp* rsp, char* buf, word32 sz)
322319
}
323320
rsp->version = sec;
324321
itemSz = strlen(sec) + 1; /* include space */
325-
sec += itemSz; len -= itemSz;
322+
sec += itemSz;
326323

327324
/* HTTP Response Code */
328325
/* find next space */
@@ -332,7 +329,7 @@ int wolfHttpClient_ParseResponse(HttpRsp* rsp, char* buf, word32 sz)
332329
}
333330
rsp->code = atoi(sec);
334331
itemSz = strlen(sec) + 1; /* include space */
335-
sec += itemSz; len -= itemSz;
332+
sec += itemSz;
336333

337334
/* HTTP Response Message */
338335
/* find end of line */

src/mod_vault.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,16 @@ int wolfVaultOpen(wolfVaultCtx** ctx, const char* file)
184184
ret = WOLFKM_BAD_FILE;
185185
}
186186

187-
/* read remainder */
188-
headSz = ctx_new->header.headerSz-headSz;
189-
ret = (int)fread(headPtr, 1, headSz, ctx_new->fd);
190-
ret = (ret == headSz) ? 0 : WOLFKM_BAD_FILE;
191-
192-
vaultSz = wolfVaultGetSize(ctx_new);
193-
if (vaultSz > ctx_new->header.headerSz)
194-
vaultSz -= ctx_new->header.headerSz;
187+
if (ret == 0) {
188+
/* read remainder */
189+
headSz = ctx_new->header.headerSz-headSz;
190+
ret = (int)fread(headPtr, 1, headSz, ctx_new->fd);
191+
ret = (ret == headSz) ? 0 : WOLFKM_BAD_FILE;
192+
193+
vaultSz = wolfVaultGetSize(ctx_new);
194+
if (vaultSz > ctx_new->header.headerSz)
195+
vaultSz -= ctx_new->header.headerSz;
196+
}
195197
if (ret == 0 && ctx_new->header.vaultSz != vaultSz) {
196198
XLOG(WOLFKM_LOG_ERROR, "Vault size does not match actual %lu != %lu\n",
197199
vaultSz, ctx_new->header.vaultSz);

src/sock_mgr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ void ServiceConnFree(SvcConn* conn)
298298

299299
me = conn->me;
300300

301-
XLOG(WOLFKM_LOG_DEBUG, "Freeing %s Service Connection\n", conn->svc->desc);
301+
if (conn->svc) {
302+
XLOG(WOLFKM_LOG_DEBUG, "Freeing %s Service Connection\n",
303+
conn->svc->desc);
304+
}
302305
DecrementCurrentConnections(conn);
303306

304307
if (conn->svc && conn->svc->closeCb) {

src/svc_ets.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,12 @@ static int wolfEtsSvcVaultAuthCb(wolfVaultCtx* ctx, byte* key, word32 keySz,
625625
if (memcmp(keyEnc, zeroBuffer, keyEncSz) == 0) {
626626
/* Generate key for encryption */
627627
ret = wc_RNG_GenerateBlock(&rng, key, keySz);
628-
628+
if (ret != 0) {
629+
XLOG(WOLFKM_LOG_ERROR, "Error %s (%d) generating key\n",
630+
wolfKeyMgr_GetError(ret), ret);
631+
wc_FreeRng(&rng);
632+
return ret;
633+
}
629634
newKey = 1;
630635
}
631636

@@ -677,22 +682,24 @@ static int wolfEtsSvcVaultAuthCb(wolfVaultCtx* ctx, byte* key, word32 keySz,
677682

678683
if (newKey || ret != 0) {
679684
XLOG(WOLFKM_LOG_WARN, "Vault Auth: Setting up new encryption key\n");
685+
ret = 0; /* reset error code */
680686
if (!newKey) {
681687
/* Generate key for encryption */
682688
ret = wc_RNG_GenerateBlock(&rng, key, keySz);
683689
}
684-
685-
/* use long term private RSA key to encrypt key */
686-
ret = wc_RsaPublicEncrypt(key, keySz, keyEnc, privKeySz, &rsa,
687-
&rng);
688-
if (ret > 0) {
689-
if (ret != (int)privKeySz) {
690-
XLOG(WOLFKM_LOG_WARN, "Vault Auth: "
691-
"Encrypted key size %d not expected %d\n", ret, privKeySz);
690+
if (ret == 0) {
691+
/* use long term private RSA key to encrypt key */
692+
ret = wc_RsaPublicEncrypt(key, keySz, keyEnc, privKeySz, &rsa,
693+
&rng);
694+
if (ret > 0) {
695+
if (ret != (int)privKeySz) {
696+
XLOG(WOLFKM_LOG_WARN, "Vault Auth: "
697+
"Encrypted key size %d not expected %d\n", ret, privKeySz);
698+
}
699+
ret = 0; /* success */
692700
}
693-
ret = 0; /* success */
694701
}
695-
else {
702+
if (ret != 0) {
696703
XLOG(WOLFKM_LOG_ERROR, "Vault Auth: encrypt key error %s (%d)\n",
697704
wolfKeyMgr_GetError(ret), ret);
698705
}

wolfkeymgr/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
extern "C" {
2828
#endif
2929

30-
#define LIBWOLFSSL_VERSION_STRING "1.0"
30+
#define LIBWOLFSSL_VERSION_STRING "1.1"
3131
#define LIBWOLFSSL_VERSION_HEX @HEX_VERSION@
3232

3333
#ifdef __cplusplus

0 commit comments

Comments
 (0)