Skip to content

Add OpenSSL support with compatibility for versions 1.0.x through 3.0+ - #34

Closed
HiGarfield with Copilot wants to merge 6 commits into
unifiedfrom
copilot/add-openssl-support
Closed

Add OpenSSL support with compatibility for versions 1.0.x through 3.0+#34
HiGarfield with Copilot wants to merge 6 commits into
unifiedfrom
copilot/add-openssl-support

Conversation

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown

Adds optional OpenSSL backend for cryptographic operations (AES, HMAC-SHA1, MD5) while maintaining backward compatibility with existing built-in implementations.

Implementation

  • Wrapper layer (lib/openssl_wrapper.{h,cpp}) provides version-agnostic interface

    • OpenSSL 3.0+: Uses EVP_MAC API for HMAC
    • OpenSSL 1.1.x: Uses heap-allocated HMAC_CTX (opaque type)
    • OpenSSL 1.0.x: Uses stack-allocated HMAC_CTX
  • Conditional compilation in lib/aes-common.h, lib/md5.h, lib/pbkdf2-sha1.h

    • USE_OPENSSL flag selects OpenSSL or built-in crypto at compile time
    • Built-in implementations excluded from build when OpenSSL enabled

Build System

Makefile:

make                    # OpenSSL enabled (default)
USE_OPENSSL=0 make      # Built-in crypto only

CMake:

cmake -DUSE_OPENSSL=ON  # OpenSSL enabled (default)
cmake -DUSE_OPENSSL=OFF # Built-in crypto only

Auto-detection via pkg-config with fallback to -lssl -lcrypto.

Impact

  • Binary size: 210KB (OpenSSL) vs 234KB (built-in)
  • Enables hardware acceleration (AES-NI, ARM Crypto Extensions) when available
  • No runtime behavior changes for existing deployments

@HiGarfield
HiGarfield marked this pull request as ready for review July 10, 2026 15:07
Copilot AI review requested due to automatic review settings July 10, 2026 15:07
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an optional OpenSSL-based crypto backend (AES-128 CBC/CFB/ECB, HMAC-SHA1, MD5) and wires it into both Makefile and CMake builds via a USE_OPENSSL toggle, along with documentation for building and verification.

Changes:

  • Introduces lib/openssl_wrapper.{h,cpp} to provide an OpenSSL-version-compatible crypto wrapper (1.0.x → 3.x).
  • Switches AES/MD5/HMAC call sites to OpenSSL-backed inline wrappers when USE_OPENSSL is enabled.
  • Updates build scripts (Makefile + CMake) and adds doc/OPENSSL.md to document usage.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
makefile Adds USE_OPENSSL toggle, pkg-config flag discovery, and links OpenSSL when enabled.
lib/pbkdf2-sha1.h Routes sha1_hmac() to OpenSSL when enabled.
lib/openssl_wrapper.h Declares OpenSSL wrapper APIs and 1.0.x compatibility shims.
lib/openssl_wrapper.cpp Implements AES/MD5/HMAC using OpenSSL EVP / legacy APIs by version.
lib/md5.h Routes md5() to OpenSSL when enabled.
lib/aes-common.h Routes AES buffer helpers to OpenSSL when enabled.
doc/OPENSSL.md Documents OpenSSL build options and verification steps.
CMakeLists.txt Adds USE_OPENSSL option, finds/links OpenSSL, adds wrapper source.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/openssl_wrapper.h
Comment on lines +9 to +14
#ifdef USE_OPENSSL

#include <openssl/evp.h>
#include <openssl/hmac.h>
#include <openssl/err.h>
#include <openssl/opensslv.h>
Comment thread lib/openssl_wrapper.cpp
Comment thread lib/pbkdf2-sha1.h
Comment thread lib/md5.h
Comment on lines +6 to +10
#ifdef USE_OPENSSL
#include "openssl_wrapper.h"
static inline void md5(const uint8_t *initial_msg, size_t initial_len, uint8_t *digest) {
openssl_md5(initial_msg, initial_len, digest);
}
Comment thread lib/aes-common.h
Comment thread makefile
Comment on lines +16 to +20
# OpenSSL support detection
USE_OPENSSL ?= 1
ifeq ($(USE_OPENSSL), 1)
OPENSSL_CFLAGS := $(shell pkg-config --cflags openssl 2>/dev/null || echo "-I/usr/include")
OPENSSL_LIBS := $(shell pkg-config --libs openssl 2>/dev/null || echo "-lssl -lcrypto")
Copilot AI requested a review from HiGarfield July 10, 2026 15:20
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@HiGarfield HiGarfield closed this Jul 10, 2026
@HiGarfield
HiGarfield deleted the copilot/add-openssl-support branch July 11, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants