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

Add support for NETSCAPE_SPKI_print #1624

Merged
merged 3 commits into from
Jun 14, 2024

Conversation

samuel40791765
Copy link
Contributor

Issues:

Resolves CryptoAlg-1717

Description of changes:

Ruby consumes NETSCAPE_SPKI_print for debugging purposes. This adds support for the symbol for easier integration.

Call-outs:

N/A

Testing:

Expected output test

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.

@samuel40791765 samuel40791765 requested a review from a team as a code owner June 5, 2024 21:34
Copy link
Contributor

@WillChilds-Klein WillChilds-Klein left a comment

Choose a reason for hiding this comment

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

can we get away with just defining no-op'ing this? given that this is used for debugging, i'm wondering whether this would actually impact any tests or programmatic functionality required by applications.

@codecov-commenter
Copy link

codecov-commenter commented Jun 5, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.

Project coverage is 78.16%. Comparing base (37ba0e2) to head (d3bcc10).

Files Patch % Lines
crypto/x509/x509spki.c 89.65% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1624   +/-   ##
=======================================
  Coverage   78.15%   78.16%           
=======================================
  Files         562      562           
  Lines       94638    94675   +37     
  Branches    13573    13576    +3     
=======================================
+ Hits        73969    74006   +37     
  Misses      20075    20075           
  Partials      594      594           

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

@samuel40791765
Copy link
Contributor Author

can we get away with just defining no-op'ing this?

We could consider it, but it did seem harmless to incorporate given that we have support for all the surrounding functions within the module: https://github.com/ruby/ruby/blob/ruby_2_7/ext/openssl/ossl_ns_spki.c#L378-L405

Great question on potential impact, I did some more digging. The only concern would be us failing this Ruby test which asserts that the inputted BIO has at least some contents, but we can pass a short string into BIO to prevent that from happening.

My preference would be supporting the entire module with no caveats, but I'm open to any other concerns with us supporting this.

crypto/x509/x509_test.cc Show resolved Hide resolved
if (pkey == NULL) {
BIO_printf(out, " Unable to load public key\n");
} else {
EVP_PKEY_print_public(out, pkey, 4, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the significance of 4 here?

Copy link
Contributor

Choose a reason for hiding this comment

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

The 4 appears to be the indentation. ¯\_(ツ)_/¯

Copy link
Contributor Author

@samuel40791765 samuel40791765 Jun 11, 2024

Choose a reason for hiding this comment

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

Yes the seemingly arbitrary numbers throughout this code are all indentations
Jokes on me, I thought I had thought the 7 below was an indentation as well haha

crypto/x509/x509spki.c Show resolved Hide resolved
crypto/x509/x509spki.c Show resolved Hide resolved
crypto/x509/x509spki.c Outdated Show resolved Hide resolved
crypto/x509/x509spki.c Show resolved Hide resolved
crypto/x509/x509spki.c Outdated Show resolved Hide resolved
: OBJ_nid2ln(OBJ_obj2nid(spkioid)));
EVP_PKEY *pkey = X509_PUBKEY_get0(spki->spkac->pubkey);
if (pkey == NULL) {
BIO_printf(out, " Unable to load public key\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, the function would still return success?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this function is just printing out the contents of the struct. The absence of a public key doesn't indicate that the print is unsuccessful, it just means that there isn't one set.
We could make the argument that the wording could be better though, but I didn't want any unnecessary misalignments from upstream behavior.

if (pkey == NULL) {
BIO_printf(out, " Unable to load public key\n");
} else {
EVP_PKEY_print_public(out, pkey, 4, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

The 4 appears to be the indentation. ¯\_(ツ)_/¯

crypto/x509/x509spki.c Outdated Show resolved Hide resolved
@samuel40791765 samuel40791765 force-pushed the netscape-print branch 2 times, most recently from f8cb242 to fc40fe4 Compare June 13, 2024 18:04
@samuel40791765 samuel40791765 merged commit e7e64f8 into aws:main Jun 14, 2024
97 of 98 checks passed
@samuel40791765 samuel40791765 deleted the netscape-print branch June 14, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants