-
Notifications
You must be signed in to change notification settings - Fork 57
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
Refactor pgp_encrypted_material_t to C++ classes. #2304
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2304 +/- ##
==========================================
+ Coverage 84.90% 85.14% +0.24%
==========================================
Files 114 118 +4
Lines 22788 22780 -8
==========================================
+ Hits 19349 19397 +48
+ Misses 3439 3383 -56 ☔ View full report in Codecov by Sentry. |
4a5ed2b
to
c438d4d
Compare
c438d4d
to
c499a5d
Compare
11f9fae
to
a670e2b
Compare
21c0822
to
39e3e5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple constructs where a set of dynamic_cast
's in placed inside case
statement. I marked it in rnp.cpp
but I saw it in stream-dump.cpp
and other files
While not an error, such pattern (dynamic_cast
's inside case
) clearly indicate an option to create a virtual function.
May be you can consider it fot future refactoring
return add_json_mpis(jso, "r", &material.eg.r, "s", &material.eg.s, NULL); | ||
case PGP_PKA_DSA: | ||
return add_json_mpis(jso, "r", &material.dsa.r, "s", &material.dsa.s, NULL); | ||
case PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this piece of code call for virtual function
something like
virtual mpi* SigMaterial::get_mpi() = 0;
and appropriate redefinitions for EgSigMaterial
et al
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the way it is currently done as well. The problem here is that different signature types may have different MPIs. In this case it is simple, one or two, but for EncMaterial and KeyMaterial it is more complicated, however I think we should use the same approach in both cases. Don't know a good solution yet.
Just few more types left to avoid unions and move pgp::mpi to std::vector.