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 RSASSA-PSS support #53

Merged
merged 23 commits into from Jul 10, 2020
Merged

Conversation

ackerleytng
Copy link
Contributor

Would appreciate any feedback on this work in progress! I'll be adding more test cases

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@ackerleytng
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

src/verify.cc Outdated Show resolved Hide resolved
src/jwt.cc Outdated Show resolved Hide resolved
@qiwzhang
Copy link
Contributor

qiwzhang commented Jul 9, 2020

Thanks you for your contribution.

@ackerleytng
Copy link
Contributor Author

ackerleytng commented Jul 9, 2020

I'm a little confused about variable naming on the google style guide, do let me know if there's anything I should change!

src/jwt.cc Outdated Show resolved Hide resolved
src/verify_jwk_rsa_pss_test.cc Outdated Show resolved Hide resolved
src/verify_jwk_rsa_pss_test.cc Outdated Show resolved Hide resolved
src/verify_jwk_rsa_pss_test.cc Outdated Show resolved Hide resolved
src/verify_jwk_rsa_pss_test.cc Show resolved Hide resolved
src/verify_jwk_rsa_pss_test.cc Show resolved Hide resolved
Copy link
Contributor

@qiwzhang qiwzhang left a comment

Choose a reason for hiding this comment

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

Thanks, just a small nit change.

src/jwt.cc Outdated
namespace {

static const absl::flat_hash_set<std::string> kImplementedAlgs = {
bool hasImplementedAlg(std::string alg) {
Copy link
Contributor

Choose a reason for hiding this comment

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

please use string_view

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ad3a68b, thanks!

src/jwt.cc Outdated Show resolved Hide resolved
@@ -23,6 +24,19 @@
namespace google {
namespace jwt_verify {

bool isImplemented(absl::string_view alg) {
Copy link
Contributor

Choose a reason for hiding this comment

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

please add annoymous namespace for this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 0eac53f!

@ackerleytng
Copy link
Contributor Author

ackerleytng commented Jul 10, 2020

I'd like to propose using the direct initializer syntax (without new). Specifically for this implementation, the handle to implemented_args never leaves the isImplemented function, so C++ is able to insert the destructor appropriately (just before the program exits).

I wrote a small program to illustrate this here and here's the output:

$ g++ ok.cc && valgrind --leak-check=full --show-leak-kinds=all ./a.out
==354120== Memcheck, a memory error detector
==354120== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==354120== Using Valgrind-3.16.0.GIT and LibVEX; rerun with -h for copyright info
==354120== Command: ./a.out
==354120==
Foobar()
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
Foobar()
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111~Foobar()
==354120==
==354120== HEAP SUMMARY:
==354120==     in use at exit: 32 bytes in 1 blocks
==354120==   total heap usage: 3 allocs, 2 frees, 73,760 bytes allocated
==354120==
==354120== 32 bytes in 1 blocks are still reachable in loss record 1 of 1
==354120==    at 0x4839DEF: operator new(unsigned long) (vg_replace_malloc.c:342)
==354120==    by 0x1092A1: leak(char) (in /home/ackerleytng/scratch/a.out)
==354120==    by 0x109424: main (in /home/ackerleytng/scratch/a.out)
==354120==
==354120== LEAK SUMMARY:
==354120==    definitely lost: 0 bytes in 0 blocks
==354120==    indirectly lost: 0 bytes in 0 blocks
==354120==      possibly lost: 0 bytes in 0 blocks
==354120==    still reachable: 32 bytes in 1 blocks
==354120==         suppressed: 0 bytes in 0 blocks
==354120==
==354120== For lists of detected and suppressed errors, rerun with: -s
==354120== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

The output shows that when leak() is called, the destructor ~Foobar() is never called, and valgrind reports a leak due to the call to new, whereas the destructor does its work correctly in noLeak(), not in every iteration of the loop, but at the end of the program.

@qiwzhang
Copy link
Contributor

OK, thanks.

Copy link
Contributor

@qiwzhang qiwzhang left a comment

Choose a reason for hiding this comment

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

Thank you very much for your contribution.

@qiwzhang qiwzhang merged commit 894ba8e into google:master Jul 10, 2020
@ackerleytng ackerleytng changed the title [WIP] Add RSASSA-PSS support Add RSASSA-PSS support Jul 10, 2020
@ackerleytng
Copy link
Contributor Author

Thanks! I suppose we can close #49 ?

@ackerleytng ackerleytng deleted the add-rsassa-pss-support branch July 10, 2020 06:52
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.

None yet

3 participants