Skip to content

Support for encrypt with a key file passed in#224

Open
embhorn wants to merge 2 commits intowolfSSL:mainfrom
embhorn:zd20918
Open

Support for encrypt with a key file passed in#224
embhorn wants to merge 2 commits intowolfSSL:mainfrom
embhorn:zd20918

Conversation

@embhorn
Copy link
Copy Markdown
Member

@embhorn embhorn commented May 6, 2026

  • Add rand -hex output (with -base64/-hex mutual exclusion) and tighten help-flag detection to avoid -hex being mistaken for -h.
  • Implement -key (hex on CLI) and -inkey (hex-with-whitespace or raw binary from file) handling, and plumb keyType into the EVP crypto path so explicit keys/IVs are used directly without salt-based derivation.
  • Update manpages/manual and add regression + interop tests covering explicit key/IV and -inkey file behaviors.

Fixes zd20918

@embhorn embhorn self-assigned this May 6, 2026
Copilot AI review requested due to automatic review settings May 6, 2026 20:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 proper support for supplying explicit cipher keys via either a hex string (-key) or a key file (-inkey) for -encrypt/-decrypt, aligning behavior with the documented man page examples and improving interoperability with OpenSSL. It also extends rand with a -hex output mode to support an end-to-end “generate key → use as -inkey” workflow, and updates docs/tests accordingly.

Changes:

  • Add rand -hex output (with -base64/-hex mutual exclusion) and tighten help-flag detection to avoid -hex being mistaken for -h.
  • Implement -key (hex on CLI) and -inkey (hex-with-whitespace or raw binary from file) handling, and plumb keyType into the EVP crypto path so explicit keys/IVs are used directly without salt-based derivation.
  • Update manpages/manual and add regression + interop tests covering explicit key/IV and -inkey file behaviors.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
wolfclu/clu_optargs.h Adds WOLFCLU_HEX option ID for the new rand -hex flag.
wolfclu/clu_header_main.h Extends wolfCLU_evp_crypto prototype to accept keyType.
src/tools/clu_rand.c Adds -hex output mode, mutual exclusion with -base64, and fixes help matching.
src/crypto/clu_evp_crypto.c Skips PBKDF/BytesToKey and forces -nosalt semantics when an explicit key/IV is provided.
src/crypto/clu_crypto_setup.c Implements -key parsing, -inkey file reading (hex or raw), and adds explicit -iv validation for explicit keys.
tests/rand/rand-test.py Adds tests for rand -hex stdout/file behavior and help-regression coverage.
tests/encrypt/enc-test.py Adds interop and regression tests for -key/-inkey handling and explicit key/IV flows.
manpages/wolfCLU_encrypt.1 Documents -key and -inkey behavior and requirements.
manpages/wolfCLU_decrypt.1 Documents -key and -inkey behavior and requirements.
manpages/manual.txt Updates synopsis/options for -key/-inkey and corrects decrypt synopsis.

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

Comment thread src/tools/clu_rand.c
Comment thread src/crypto/clu_crypto_setup.c
Comment thread wolfclu/clu_header_main.h
Comment thread manpages/manual.txt Outdated
Comment thread manpages/manual.txt Outdated
@embhorn embhorn requested a review from wolfSSL-Fenrir-bot May 6, 2026 20:47
Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #224

Scan targets checked: wolfclu-bugs, wolfclu-src

No new issues found in the changed files. ✅

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