From 7c9c5ac12eee5bea6462c52dba0c1cf6c38f2c82 Mon Sep 17 00:00:00 2001 From: Chad Fraleigh Date: Tue, 15 Aug 2023 19:35:48 -0700 Subject: [PATCH] Added VERIFY_ALWAYS_SUCCEEDS conditional to allow signature verifiers to always succeed during fuzzing for maximum code coverage. --- libi2pd/Ed25519.cpp | 5 +++++ libi2pd/Gost.cpp | 5 +++++ libi2pd/Signature.cpp | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libi2pd/Ed25519.cpp b/libi2pd/Ed25519.cpp index 3e0795d5..e0fe38ee 100644 --- a/libi2pd/Ed25519.cpp +++ b/libi2pd/Ed25519.cpp @@ -126,6 +126,11 @@ namespace crypto BN_CTX_free (ctx); if (!passed) LogPrint (eLogError, "25519 signature verification failed"); + +#ifdef VERIFY_ALWAYS_SUCCEEDS + passed = true; +#endif + return passed; } diff --git a/libi2pd/Gost.cpp b/libi2pd/Gost.cpp index 2dafc9ae..b81fc74b 100644 --- a/libi2pd/Gost.cpp +++ b/libi2pd/Gost.cpp @@ -102,6 +102,11 @@ namespace crypto EC_POINT_free (C); BN_CTX_end (ctx); BN_CTX_free (ctx); + +#ifdef VERIFY_ALWAYS_SUCCEEDS + ret = true; +#endif + return ret; } diff --git a/libi2pd/Signature.cpp b/libi2pd/Signature.cpp index ebc188a9..c8378dc8 100644 --- a/libi2pd/Signature.cpp +++ b/libi2pd/Signature.cpp @@ -34,7 +34,13 @@ namespace crypto bool EDDSA25519Verifier::Verify (const uint8_t * buf, size_t len, const uint8_t * signature) const { - return EVP_DigestVerify (m_MDCtx, signature, 64, buf, len); + bool ret = EVP_DigestVerify (m_MDCtx, signature, 64, buf, len); + +#ifdef VERIFY_ALWAYS_SUCCEEDS + ret = true; +#endif + + return ret; } #else