Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new APIs to read EC private keys and public keys #533

Merged
merged 8 commits into from
Dec 6, 2023

Conversation

Bhashinee
Copy link
Member

@Bhashinee Bhashinee commented Nov 28, 2023

Purpose

This PR is to introduce 4 new APIs to the Crypto module to interact with the private keys and public keys signed with "EC" algorithms.

Fixes: ballerina-platform/ballerina-library#5821

Examples

Newly introduced APIs,

Decode a 'EC' private key

crypto:PrivateKey privateKey = check crypto:decodeEcPrivateKeyFromKeyStore(keyStore, "keyAlias", "keyPassword");

Decode a 'EC' public key

crypto:PublicKey publicKey = check crypto:decodeEcPublicKeyFromTrustStore(trustStore, "keyAlias");

Generate a SHA384withECDSA based signature

byte[] signature = check crypto:signSha384withEcdsa(data, privateKey);

Verify a SHA384withECDSA based signature

boolean validity = check crypto:verifySha384withEcdsaSignature(data, signature, publicKey);

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility

Copy link

codecov bot commented Nov 28, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (0c97dc2) 86.25% compared to head (6f1b573) 87.52%.

Files Patch % Lines
.../io/ballerina/stdlib/crypto/nativeimpl/Decode.java 90.00% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #533      +/-   ##
============================================
+ Coverage     86.25%   87.52%   +1.27%     
- Complexity       76       93      +17     
============================================
  Files            16       16              
  Lines           422      465      +43     
  Branches         56       65       +9     
============================================
+ Hits            364      407      +43     
  Misses           47       47              
  Partials         11       11              

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

Copy link

sonarqubecloud bot commented Dec 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@MohamedSabthar MohamedSabthar left a comment

Choose a reason for hiding this comment

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

LGTM

@Bhashinee Bhashinee merged commit 1f4311f into ballerina-platform:master Dec 6, 2023
8 checks passed
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.

Signing and verifying using the algorithm SHA384withECDSA in the ballerina/crypto module
2 participants