Premise: coding.c:660 `if (in == NULL || out == NULL || outLen == NULL)
return BAD_FUNC_ARG;` establishes in != NULL unconditionally -- note
it is stronger than the Base64 entry checks, which only reject a NULL
input when inLen > 0.
Claim: coding.c:663 `if (inLen == 1 && *outLen && in)` -- the `in` operand.
Proof: in is a parameter and is never reassigned; reaching :663 implies the
:660 check did not fire, hence in != NULL. The operand is invariantly
true and its independence pair is unreachable.
Scope: the whole function is inside a single WOLFSSL_BASE16 block with no
nested #if in the span, so the argument holds in every configuration
that compiles it.
Evidence: llvm-cov MC/DC records this condition's pair as uncovered
(reports/coding/GAPS.md row 663:9:663:36:2).
Compiler cross-check: gcc -O2 emits byte-identical code for this file before
and after this commit -- the optimiser had already folded the removed
condition, independently confirming it was dead.
Premise: coding.c:177 (Base64_Decode_nonCT) and coding.c:298 (Base64_Decode)
both open with
if ((in == NULL && inLen > 0) || out == NULL || outLen == NULL)
return BAD_FUNC_ARG;
which establishes out != NULL for the rest of each function.
Claim: coding.c:281 and coding.c:395, `if (out && *outLen > i)` -- the `out`
operand in both.
Proof: out is a parameter and is never reassigned in either function; the
only uses between the entry check and the null-terminator write are
subscripted stores (out[i]). Reaching :281 / :395 therefore implies
out != NULL, so the operand is invariantly true and its independence
pair is unreachable.
Scope: neither function contains an #if/#ifdef in the span. Base64_Decode_nonCT
is compiled under !BASE64_NO_TABLE and aliased to Base64_Decode under
BASE64_NO_TABLE (:404-408); both variants carry the same entry check,
so the argument holds either way.
Evidence: llvm-cov MC/DC records both conditions' pairs as uncovered
(reports/coding/GAPS.md rows 281:9:281:27:0 and 395:9:395:27:0).
Deliberately untouched: the textually identical line in DoBase64_Encode
(coding.c:608). There out == NULL is the documented size-query mode
(`getSzOnly = (out == NULL)` at :520, returning LENGTH_ONLY_E), so that operand
is live and load-bearing -- base64_test exercises it.
Compiler cross-check: gcc -O2 emits byte-identical code for this file before
and after this commit -- the optimiser had already folded the removed
condition, independently confirming it was dead.
Premise: coding.c:127 `if (len == 0) { return BUFFER_E; }` establishes len >= 1
on every path that continues.
Claim: coding.c:137 `if (len && (curChar == '\r' || curChar == '\n'))` --
the `len` operand.
Proof: len is only written between :127 and :137 by the loop at :132,
`while (len > 1 && curChar == ' ') { ...; len--; }`, whose guard
admits the decrement only when len > 1. So the loop preserves
len >= 1, and len >= 1 => the `len` operand is invariantly true.
Its false half, and therefore its MC/DC independence pair, is
unreachable.
Scope: no #if/#ifdef occurs between :120 and :166; the whole function sits
inside one uniform WOLFSSL_BASE64_DECODE block. The argument holds
in every configuration that compiles the function.
Evidence: llvm-cov MC/DC records this condition's pair as uncovered
(reports/coding/GAPS.md row 137:9:137:52:0).
The later `if (len)` at :141/:151 and `while (len && ...)` at :155 stay: the
decrements at :139/:143 can drive len to 0 before those are evaluated.
Compiler cross-check: gcc -O2 emits byte-identical code for this file before
and after this commit -- the optimiser had already folded the removed
condition, independently confirming it was dead.
wolfcrypt/src/coding.c: in Base64_Decode() and Base64_Decode_nonCT(), check for non-whitespace characters past the end and return ASN_INPUT_E if found;
wolfcrypt/test/test.c: in base64_test(), remove ';' from goodChar[], and add trailing*[] test strings and N_BYTE_TRAILING_TEST(), for positive and negative testing of new checks.
which force on BUILDING_WOLFSSL and do boilerplate includes, and update library
sources to include them at the top.
wolfssl_sources.h includes types.h, error-crypt.h, and logging.h, and
conditionally, config.h. settings.h and wc_port.h are unconditionally
included at the top of types.h.
wolfssl_sources_asm.h includes settings.h, and conditionally, config.h.
Add wolfssl_sources*.h to wolfcrypt/src/include.am, and to several IDE/ project
files.
Also added a TEST_WOLFSSL_SOURCES_INCLUSION_SEQUENCE clause in
wolfssl/wolfcrypt/settings.h to allow coverage testing.
In wolfcrypt/src/misc.c, retain existing ad hoc boilerplate includes, and use
them if WOLFSSL_VIS_FOR_TESTS, otherwise include the new wolfssl_sources.h.
Define WOLFSSL_VIS_FOR_TESTS at top of wolfcrypt/test/test.c.
Also renamed WOLFSSL_NEED_LINUX_CURRENT to WOLFSSL_LINUXKM_NEED_LINUX_CURRENT,
for clarity.
wolfcrypt/test/test.c: refactor Base64_Decode() with separate always-CT
Base64_Decode() and never-CT Base64_Decode_nonCT(), and use the latter only to
decode known-public PEM objects, otherwise use always-CT Base64_Decode().
in wolfcrypt/src/coding.c, add ALIGN64 to hexDecode[], and add hexEncode[] for use by Base16_Encode();
in wolfcrypt/src/misc.c and wolfssl/wolfcrypt/misc.h:
move ctMask*() up so that min() and max() can use them, and add ctMaskWord32GTE();
add ALIGN64 to kHexChar[];
add CT implementation of CharIsWhiteSpace();
remove min_size_t() and max_size_t() recently added, but only one user (refactored).
* fix TLS layer to consistently use WOLFSSL_FATAL_ERROR for error retvals, rather than literal -1.
* add WC_NO_ERR_TRACE() wrapper around LENGTH_ONLY_E (it does not signify an error condition).
* refactor errcode handling for traceability in wolfSSL_DSA_do_sign(), wolfSSL_DH_size(), wolfSSL_EC_KEY_get_conv_form(), wolfSSL_d2i_DSA_SIG(), wolfSSL_DSA_do_sign(), SetDhInternal(), and wolfSSL_EC_KEY_get_conv_form().
Fix checking of negative with unsigned variables.
Check digestSz for 0 in wc_SSH_KDF() so that no possibility of dividing
by zero.
Change XMEMCPY to XMEMSET in renesas_sce_util.c.
Fix test.c to free prvTmp and pubTmp on read error.
Remove unused variables.
XFREE checks for NULL so don't check before call.
Move variable declarations to reduce scope.
* Refactor the PEM saving code in `test.c`, so its not using large 4K buffer and calculates based on DER.
* Enable ECC key generation test even without `WOLFSSL_KEY_GEN`.
* Added `ECC_KEYGEN_SIZE` macro for ECC key generation testing.
* Refactor ECC DER key generation to use `ECC_BUFSIZE`.