Skip to content

Commit 6b4a89c

Browse files
committed
Fix test failures
1 parent 2b1c91c commit 6b4a89c

3 files changed

Lines changed: 16 additions & 18 deletions

File tree

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ensure cert/key files always use LF line endings so that hashes
2+
# remain consistent across platforms.
3+
*.pem eol=lf
4+
*.cnf eol=lf
5+
*.cfg eol=lf
6+
7+
# DER files are binary and must never be transformed.
8+
*.der binary

src/x509/clu_x509_sign.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,21 +1274,11 @@ int wolfCLU_CertSign(WOLFCLU_CERT_SIGN* csign, WOLFSSL_X509* x509)
12741274
case WC_HASH_TYPE_BLAKE2B:
12751275
case WC_HASH_TYPE_BLAKE2S:
12761276

1277-
#if LIBWOLFSSL_VERSION_HEX > 0x05001000
1278-
#ifndef WOLFSSL_NOSHA512_224
12791277
case WC_HASH_TYPE_SHA512_224:
1280-
#endif
1281-
#ifndef WOLFSSL_NOSHA512_256
12821278
case WC_HASH_TYPE_SHA512_256:
1283-
#endif
1284-
#ifdef WOLFSSL_SHAKE128
12851279
case WC_HASH_TYPE_SHAKE128:
1286-
#endif
1287-
#ifdef WOLFSSL_SHAKE256
12881280
case WC_HASH_TYPE_SHAKE256:
1289-
#endif
12901281
case WC_HASH_TYPE_SM3:
1291-
#endif
12921282
default:
12931283
wolfCLU_LogError("Unsupported hash type");
12941284
ret = WOLFCLU_FATAL_ERROR;

tests/x509/x509-process-test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
HAS_OPENSSL = shutil.which("openssl") is not None
1515

1616

17-
def _check_cert_signature(cert_path, digest):
17+
def _check_cert_signature(cert_path, digest, inform="PEM"):
1818
"""Use OpenSSL to verify the signature on a self-signed certificate.
1919
2020
Returns True on success, raises AssertionError on failure.
@@ -24,10 +24,13 @@ def _check_cert_signature(cert_path, digest):
2424
raise unittest.SkipTest("openssl not available")
2525

2626
stripped = cert_path + ".stripped.pem"
27+
sig_bin = cert_path + ".sig.bin"
28+
body_bin = cert_path + ".body.bin"
29+
pub_pem = cert_path + ".pub.pem"
2730
try:
2831
subprocess.run(
29-
["openssl", "x509", "-in", cert_path, "-out", stripped,
30-
"-outform", "PEM"],
32+
["openssl", "x509", "-inform", inform, "-in", cert_path,
33+
"-out", stripped, "-outform", "PEM"],
3134
check=True, capture_output=True, timeout=60)
3235

3336
# Extract signature hex
@@ -48,17 +51,14 @@ def _check_cert_signature(cert_path, digest):
4851
lines.append(stripped_line)
4952
sig_hex = "".join(lines)
5053

51-
sig_bin = cert_path + ".sig.bin"
5254
with open(sig_bin, "wb") as f:
5355
f.write(bytes.fromhex(sig_hex))
5456

55-
body_bin = cert_path + ".body.bin"
5657
subprocess.run(
5758
["openssl", "asn1parse", "-in", stripped, "-strparse", "4",
5859
"-out", body_bin, "-noout"],
5960
check=True, capture_output=True, timeout=60)
6061

61-
pub_pem = cert_path + ".pub.pem"
6262
with open(pub_pem, "w") as pub_f:
6363
subprocess.run(
6464
["openssl", "x509", "-in", stripped, "-noout", "-pubkey"],
@@ -150,7 +150,7 @@ def test_1c_pem_to_der_signature(self):
150150
"-in", os.path.join(CERTS_DIR, "ca-cert.pem"),
151151
"-out", out)
152152
self.assertEqual(r.returncode, 0, r.stderr)
153-
_check_cert_signature(out, "sha256")
153+
_check_cert_signature(out, "sha256", inform="DER")
154154

155155
def test_1d_der_to_pem_stdout(self):
156156
"""DER -> PEM to stdout succeeds."""
@@ -175,7 +175,7 @@ def test_1e_der_to_der_signature(self):
175175
"-in", os.path.join(CERTS_DIR, "ca-cert.der"),
176176
"-out", out)
177177
self.assertEqual(r.returncode, 0, r.stderr)
178-
_check_cert_signature(out, "sha256")
178+
_check_cert_signature(out, "sha256", inform="DER")
179179

180180
def test_1f_der_text_noout(self):
181181
"""DER text/noout succeeds."""

0 commit comments

Comments
 (0)