Skip to content

Commit 9e96c0c

Browse files
committed
Address third round of review comments
- Include <ctype.h> for isalpha() in Windows absolute path check - Reject zero-length payload (length <= saltAndIvSize) in decrypt - Assert x509 extraction succeeds and produces output file in client test
1 parent 4e2f166 commit 9e96c0c

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/crypto/clu_decrypt.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ int wolfCLU_decrypt(int alg, char* mode, byte* pwdKey, byte* key, int size,
7777
length = (int)XFTELL(inFile);
7878
XFSEEK(inFile, 0, SEEK_SET);
7979

80-
/* Validate file is large enough for salt + IV header */
81-
if (length < saltAndIvSize) {
82-
wolfCLU_LogError("Input file too small (missing salt/IV).");
80+
/* Validate file contains salt + IV header plus at least one byte of
81+
* ciphertext. A length equal to saltAndIvSize means there is no
82+
* encrypted payload to decrypt. */
83+
if (length <= saltAndIvSize) {
84+
wolfCLU_LogError("Input file too small (missing salt/IV or payload).");
8385
XFCLOSE(inFile);
8486
XFCLOSE(outFile);
8587
return DECRYPT_ERROR;

src/x509/clu_x509_sign.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <wolfclu/x509/clu_parse.h>
2626
#include <wolfclu/x509/clu_x509_sign.h>
2727
#include <wolfclu/x509/clu_cert.h>
28+
29+
#include <ctype.h>
2830
#ifdef HAVE_DILITHIUM
2931
#include <wolfssl/wolfcrypt/dilithium.h>
3032
#endif /* HAVE_DILITHIUM */

tests/client/client-test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def test_s_client_x509(self):
4949
capture_output=True,
5050
timeout=60,
5151
)
52+
self.assertEqual(x509_extract.returncode, 0,
53+
f"x509 extraction failed: {x509_extract.stderr}")
54+
self.assertTrue(os.path.exists(tmp_crt),
55+
f"x509 did not create output file: "
56+
f"{x509_extract.stderr}")
5257

5358
# Read back the cert
5459
result = run_wolfssl("x509", "-in", tmp_crt)

0 commit comments

Comments
 (0)