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

FIx some PQC issues. #2131

Merged
merged 4 commits into from
Nov 26, 2023
Merged

FIx some PQC issues. #2131

merged 4 commits into from
Nov 26, 2023

Conversation

ni4
Copy link
Contributor

@ni4 ni4 commented Sep 28, 2023

Among other minor issues this PR adds RNP_EXPERIMENTAL_* defines to the rnp_export.h header, allowing to cut-off by default yet experimental features. Probably better solution would be to remove those function calls from the header at all, however don't see good solution for that at the moment.

@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

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

Comparison is base (05f59e9) 76.88% compared to head (977cf19) 76.89%.
Report is 1 commits behind head on main.

❗ Current head 977cf19 differs from pull request most recent head 3824009. Consider uploading reports for the commit 3824009 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2131      +/-   ##
==========================================
+ Coverage   76.88%   76.89%   +0.01%     
==========================================
  Files         193      193              
  Lines       36982    36976       -6     
==========================================
  Hits        28432    28432              
+ Misses       8550     8544       -6     
Files Coverage Δ
src/lib/rnp.cpp 80.20% <ø> (+0.10%) ⬆️
src/librepgp/stream-parse.cpp 77.60% <0.00%> (ø)

... and 1 file with indirect coverage changes

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

@ni4
Copy link
Contributor Author

ni4 commented Sep 28, 2023

@falko-strenzke what do you think about this solution on hiding PQC/v6 calls from the FFI API?

@falko-strenzke
Copy link
Contributor

First of allo sorry for the delayed relpy.
As I understand it, this should force the application that uses RNP to also set the define RNP_EXPERIMENTAL_CRYPTO_REFRESH (or RNP_EXPERIMENTAL_PQC) in its own code. From our side this is fine.

@ni4
Copy link
Contributor Author

ni4 commented Oct 10, 2023

@falko-strenzke Thanks for the reply. It's actually simpler, CMake will set those variables automatically and include into the rnp_export.h header, via this patch: https://github.com/rnpgp/rnp/pull/2131/files#diff-7567fde99fcba090ecb1958dd4ab9ba4367c10ba5d444e580cb61c3b404ced3a

@ni4 ni4 marked this pull request as ready for review October 11, 2023 12:38
@ni4
Copy link
Contributor Author

ni4 commented Oct 26, 2023

@maxirmx @ribose-jeffreylau Could you please review this? Thanks!

src/lib/rnp.cpp Outdated
@@ -70,6 +70,13 @@
RNP_LOG_FD(fp, __VA_ARGS__); \
} while (0)

#if defined(RNP_EXPERIMENTAL_CRYPTO_REFRESH) && !defined(ENABLE_CRYPTO_REFRESH)
Copy link
Member

Choose a reason for hiding this comment

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

(This is a suggestion to consider)

IMHO it will be much easier to support a single flags
Something like this:

#include <iostream>

//   Defintion of CRYPTO_REFRESH options
#define ENABLE_CRYPTO_REFRESH 0
#define ENABLE_EXPERIMENTAL_CRYPTO_REFRESH 1
#define DISABLE_CRYPTO_REFRESH  2

//   Selection of CRYPTO_REFRESH option
#define RNP_CRYPTO_REFRESH RNP_CRYPTO_REFRESH


int main(int, char**)
{
#if RNP_CRYPTO_REFRESH == ENABLE_CRYPTO_REFRESH
    std::cout << "ENABLE_CRYPTO_REFRESH" << std::endl;
#elif RNP_CRYPTO_REFRESH == ENABLE_EXPERIMENTAL_CRYPTO_REFRESH
    std::cout << "ENABLE_EXPERIMENTAL_CRYPTO_REFRESH" << std::endl;
#else
    std::cout << "DISABLE_CRYPTO_REFRESH (" << RNP_CRYPTO_REFRESH << ")" << std::endl;
#endif
return 0;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maxirmx Thanks for noticing this, but it's suggested to work in a bit different way: both defines are for the same purpose, and this check is to make sure that they are in sync. The problem here is that one goes to the config.h.in, which is not installed and used only during compilation, and second is needed to be installed and used by another installed header rnp.h. This is needed to hide some function declarations from the rnp.h. So it's not the best solution, but I didn't find any better idea. Maybe you have some suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

If it is a check that both defines are in sync I guess it shall be

#if defined(RNP_EXPERIMENTAL_CRYPTO_REFRESH) != defined(ENABLE_CRYPTO_REFRESH)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maxirmx Indeed, thanks! Re-pushed.

@@ -70,6 +70,13 @@
RNP_LOG_FD(fp, __VA_ARGS__); \
} while (0)

#if defined(RNP_EXPERIMENTAL_CRYPTO_REFRESH) && !defined(ENABLE_CRYPTO_REFRESH)
#error "Invalid defines combination."
Copy link
Member

Choose a reason for hiding this comment

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

(This is a suggestion to consider)
Pls refer to the note about CRYPTO_REFRESH flags

src/lib/CMakeLists.txt Outdated Show resolved Hide resolved
@ni4 ni4 force-pushed the ni4-fix-minor-pqc-issues branch from 1d66cc5 to 9fa19a4 Compare November 1, 2023 10:45
Copy link
Contributor

@ribose-jeffreylau ribose-jeffreylau left a comment

Choose a reason for hiding this comment

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

Not a C expert so nothing to add...

@ni4 ni4 force-pushed the ni4-fix-minor-pqc-issues branch from 9fa19a4 to 3824009 Compare November 8, 2023 12:59
@ni4
Copy link
Contributor Author

ni4 commented Nov 26, 2023

Merging as it has 2 approvals and green CI.

@ni4 ni4 merged commit b02c64e into main Nov 26, 2023
111 checks passed
@ni4 ni4 deleted the ni4-fix-minor-pqc-issues branch November 26, 2023 10:31
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.

5 participants