Skip to content

Conversation

@kingstjo
Copy link
Contributor

Issues:

Addresses #CryptoAlg-3382

Description of changes:

This PR implements a minimal EC CLI tool for AWS-LC to provide EC key processing capabilities similar to OpenSSL's openssl ec command. The tool supports essential EC key operations including format conversion between PEM/DER for both private and public keys, using AWS-LC's native EC APIs for proper key handling.

Testing:

  • Unit tests: 13 comprehensive test cases in ec_test.cc covering:
    • Format conversion (PEM ↔ DER) for both private and public keys
    • Round-trip validation ensuring data integrity
    • Error handling for invalid inputs and file operations
    • Cross-compatibility with OpenSSL when environment variables are set
  • Manual verification: Tested format conversion and OpenSSL interoperability during development

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@kingstjo kingstjo requested a review from a team as a code owner August 25, 2025 21:55
@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2025

Codecov Report

❌ Patch coverage is 73.78049% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.98%. Comparing base (2c370b0) to head (cd66ebf).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
tool-openssl/ec_test.cc 67.64% 33 Missing ⚠️
tool-openssl/ec.cc 83.87% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2640      +/-   ##
==========================================
+ Coverage   78.96%   78.98%   +0.01%     
==========================================
  Files         671      673       +2     
  Lines      114798   114962     +164     
  Branches    16153    16164      +11     
==========================================
+ Hits        90655    90799     +144     
- Misses      23358    23377      +19     
- Partials      785      786       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

justsmth
justsmth previously approved these changes Oct 3, 2025
smittals2
smittals2 previously approved these changes Oct 6, 2025
@kingstjo kingstjo dismissed stale reviews from smittals2 and justsmth via 37222e1 October 6, 2025 22:48
@kingstjo kingstjo requested review from justsmth and smittals2 October 6, 2025 22:48
justsmth
justsmth previously approved these changes Oct 6, 2025
smittals2
smittals2 previously approved these changes Oct 6, 2025
@kingstjo kingstjo enabled auto-merge (squash) October 6, 2025 22:51
- Create ec.cc with EC-specific key processing
- Support options: -inform, -in, -pubout, -out, -outform
- Handle PEM/DER format conversion for EC private/public keys
- Use EC-specific AWS-LC APIs for proper key handling
- Integrate ecTool into build system (CMakeLists.txt, internal.h, tool.cc)
- Tested format conversion and OpenSSL interoperability

Assisted by Amazon Q
- Create ec_test.cc with cross-compatibility testing
- Test all minimal EC options: -inform, -in, -pubout, -out, -outform
- Include format conversion tests (PEM/DER) and round-trip validation
- Add error handling tests for invalid inputs/outputs
- Support conditional OpenSSL cross-compatibility when env vars set
- Use BIO pattern consistent with other AWS-LC tool tests
- All 13 tests pass including OpenSSL interoperability validation

Assisted by Amazon Q
- Load original keys for comparison in both round-trip tests
- Use BN_cmp() to validate private key values remain identical
- Ensures data integrity through PEM↔DER format conversions
- Use isStringUpperCaseEqual() for case-insensitive format checking
- Simplify error messages to show only supported formats
- Make format validation consistent with other tools
@justsmth justsmth dismissed stale reviews from smittals2 and themself via cd66ebf October 7, 2025 13:35
@justsmth justsmth requested review from justsmth and smittals2 October 7, 2025 13:35
@kingstjo kingstjo merged commit ffe498f into aws:main Oct 7, 2025
365 of 369 checks passed
@justsmth justsmth mentioned this pull request Oct 13, 2025
justsmth added a commit that referenced this pull request Oct 13, 2025
### Description of changes: 
Prepare v1.62.0 release

#### What's Changed
* nginx now supports AWS-LC by @samuel40791765 in
#2714
* Fix tests that assume X25519 will be negotiated by @alexw91 in
#2682
* Fixing a bug in ML-DSA poly_uniform function by @dkostic in
#2721
* Migrate integration omnibus by @skmcgrail in
#2715
* Delete util/bot directory by @justsmth in
#2723
* Don't ignore CMAKE_C_FLAGS w/ MSVC by @justsmth in
#2722
* Bump urllib3 from 2.2.3 to 2.5.0 in /tests/ci by @dependabot[bot] in
#2551
* Type fix in mldsa by @manastasova in
#2308
* Centralize password handling tool-openssl by @kingstjo in
#2555
* crypto/pem: replace strncmp with CRYPTO_memcmp to fix -Wstring-compare
error by @R3hankhan123 in #2724
* Implement dgst CLI command by @nhatnghiho in
#2638
* Add ASN.1 decoding for ML-KEM private keys as seeds by @jakemas in
#2707
* Implement genrsa command by @kingstjo in
#2535
* Move udiv and sencond tweak calculations to when needed by @nebeid in
#2726
* Add null check on RSA key checks by @samuel40791765 in
#2727
* Implement workaround for FORTIFY_SOURCE warning with jitterentropy by
@skmcgrail in #2728
* Implement coverity suggestions by @skmcgrail in
#2730
* Add minimal EC CLI tool implementation by @kingstjo in
#2640
* Adding pkeyutl tool to the CLI by @smittals2 in
#2575
* Add CI dimensions for legacy AVX512 flags by @smittals2 in
#2732
* Fix Libwebsockets CI by @smittals2 in
#2737
* Add option ENABLE_SOURCE_MODIFICATION by @justsmth in
#2739
* Simple script to build/run tests by @justsmth in
#2736
* Add build-time option to opt-out of CPU Jitter Entropy by
@torben-hansen in #2733


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
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.

4 participants