From 8ad6ca42e34766750e14487eb0aa0e518c3ba9ca Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 13 Aug 2026 13:10:54 -0700 Subject: [PATCH] Use wolfCrypt's Base16_Decode in test.h when it is available - test.h's static Base16_Decode collides with wolfSSL's public one when coding.h lands first, breaking --enable-tpm builds. - Include coding.h in test.h, keeping the local copy only when WOLFSSL_BASE16 is absent; --enable-wolfssh alone does not set it. - api.c includes coding.h too, dropping its hand-declared Base64_Encode_NoNl, which would now be a duplicate. --- tests/api.c | 7 +------ wolfssh/test.h | 9 +++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/api.c b/tests/api.c index 8a61ea2ee..6571815b3 100644 --- a/tests/api.c +++ b/tests/api.c @@ -53,12 +53,7 @@ #endif #ifdef WOLFSSH_OSSH_CERTS #include - #ifdef WOLFSSL_BASE64_ENCODE - /* Declared rather than including coding.h, whose Base16_Decode - * collides with the one wolfssh/test.h defines. */ - WOLFSSL_API int Base64_Encode_NoNl(const byte* in, word32 inLen, - byte* out, word32* outLen); - #endif + #include #endif #if defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP) diff --git a/wolfssh/test.h b/wolfssh/test.h index f1bc19159..a03f43686 100644 --- a/wolfssh/test.h +++ b/wolfssh/test.h @@ -1158,6 +1158,13 @@ static INLINE void build_addr_ipv6(struct sockaddr_in6* addr, const char* peer, #ifdef WOLFSSH_TEST_HEX2BIN +/* Declares Base16_Decode when wolfSSL has it, and settles WOLFSSL_BASE16 + * for the guard below. Only --enable-base16 and the options that imply it + * (openssh, sm2, all) build it, so the local copy is still needed. */ +#include + +#ifndef WOLFSSL_BASE16 + #define BAD 0xFF static const byte hexDecode[] = @@ -1230,6 +1237,8 @@ static int Base16_Decode(const byte* in, word32 inLen, return 0; } +#endif /* !WOLFSSL_BASE16 */ + static void FreeBins(byte* b1, byte* b2, byte* b3, byte* b4) {