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

Refactor rnp_key_store_t to rnp::KeyStore. #2122

Merged
merged 28 commits into from
Oct 27, 2023
Merged

Conversation

ni4
Copy link
Contributor

@ni4 ni4 commented Aug 26, 2023

...hopefully at some point we'll finally get rid from C leftovers.

src/librekey/rnp_key_store.cpp Fixed Show fixed Hide fixed
src/tests/cli.cpp Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Aug 26, 2023

Codecov Report

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

Comparison is base (fdfc1f5) 76.87% compared to head (fd2345a) 76.86%.

❗ Current head fd2345a differs from pull request most recent head 31e2e52. Consider uploading reports for the commit 31e2e52 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2122      +/-   ##
==========================================
- Coverage   76.87%   76.86%   -0.01%     
==========================================
  Files         193      193              
  Lines       37051    37003      -48     
==========================================
- Hits        28484    28444      -40     
+ Misses       8567     8559       -8     
Files Coverage Δ
include/rekey/rnp_key_store.h 100.00% <100.00%> (ø)
src/fuzzing/keyring_g10.cpp 100.00% <100.00%> (ø)
src/lib/ffi-priv-types.h 100.00% <ø> (ø)
src/lib/generate-key.cpp 75.37% <100.00%> (ø)
src/lib/key-provider.h 100.00% <100.00%> (ø)
src/lib/logging.h 100.00% <ø> (ø)
src/lib/pgp-key.h 91.66% <ø> (ø)
src/lib/types.h 100.00% <ø> (ø)
src/librekey/kbx_blob.hpp 90.47% <ø> (ø)
src/librekey/key_store_g10.cpp 78.86% <100.00%> (ø)
... and 26 more

... and 2 files with indirect coverage changes

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

@ni4 ni4 force-pushed the ni4-refactor-rnp_key_store_t branch 2 times, most recently from d0a2649 to a43e565 Compare August 29, 2023 09:08
ni4 added 25 commits September 26, 2023 11:32
@ni4 ni4 force-pushed the ni4-refactor-rnp_key_store_t branch from a43e565 to 31e2e52 Compare September 26, 2023 09:08
Comment on lines +3008 to +3075
switch (alg) {
case PGP_PKA_RSA:
case PGP_PKA_RSA_SIGN_ONLY:
case PGP_PKA_RSA_ENCRYPT_ONLY:
grip_hash_mpi(*hash, rsa.n, '\0');
break;
case PGP_PKA_DSA:
grip_hash_mpi(*hash, dsa.p, 'p');
grip_hash_mpi(*hash, dsa.q, 'q');
grip_hash_mpi(*hash, dsa.g, 'g');
grip_hash_mpi(*hash, dsa.y, 'y');
break;
case PGP_PKA_ELGAMAL:
case PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN:
grip_hash_mpi(*hash, eg.p, 'p');
grip_hash_mpi(*hash, eg.g, 'g');
grip_hash_mpi(*hash, eg.y, 'y');
break;
case PGP_PKA_ECDH:
case PGP_PKA_ECDSA:
case PGP_PKA_EDDSA:
case PGP_PKA_SM2:
grip_hash_ec(*hash, ec);
break;
#if defined(ENABLE_CRYPTO_REFRESH)
// TODO: if GnuPG would ever support v6, check whether this works correctly.
case PGP_PKA_ED25519:
hash->add(key->ed25519.pub);
break;
case PGP_PKA_X25519:
hash->add(key->x25519.pub);
break;
#endif
#if defined(ENABLE_PQC)
case PGP_PKA_KYBER768_X25519:
FALLTHROUGH_STATEMENT;
// TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT;
case PGP_PKA_KYBER768_P256:
FALLTHROUGH_STATEMENT;
case PGP_PKA_KYBER1024_P384:
FALLTHROUGH_STATEMENT;
case PGP_PKA_KYBER768_BP256:
FALLTHROUGH_STATEMENT;
case PGP_PKA_KYBER1024_BP384:
hash->add(key->kyber_ecdh.pub.get_encoded());
break;
case PGP_PKA_DILITHIUM3_ED25519:
FALLTHROUGH_STATEMENT;
// TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT;
case PGP_PKA_DILITHIUM3_P256:
FALLTHROUGH_STATEMENT;
case PGP_PKA_DILITHIUM5_P384:
FALLTHROUGH_STATEMENT;
case PGP_PKA_DILITHIUM3_BP256:
FALLTHROUGH_STATEMENT;
case PGP_PKA_DILITHIUM5_BP384:
hash->add(key->dilithium_exdsa.pub.get_encoded());
break;
case PGP_PKA_SPHINCSPLUS_SHA2:
FALLTHROUGH_STATEMENT;
case PGP_PKA_SPHINCSPLUS_SHAKE:
hash->add(key->sphincsplus.pub.get_encoded());
break;
#endif
default:
RNP_LOG("unsupported public-key algorithm %d", (int) alg);
return false;
}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
PGP_PKA_SM2 (42 lines)
.
break;
case PGP_PKA_DILITHIUM3_ED25519:
FALLTHROUGH_STATEMENT;
// TODO: add case PGP_PKA_DILITHIUM5_ED448: FALLTHROUGH_STATEMENT;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
#if defined(ENABLE_PQC)
case PGP_PKA_KYBER768_X25519:
FALLTHROUGH_STATEMENT;
// TODO add case PGP_PKA_KYBER1024_X448: FALLTHROUGH_STATEMENT;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
@ni4 ni4 marked this pull request as ready for review September 26, 2023 13:24
@ni4
Copy link
Contributor Author

ni4 commented Sep 29, 2023

@ronaldtse Ping for review :)

@ni4
Copy link
Contributor Author

ni4 commented Oct 26, 2023

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

@ronaldtse
Copy link
Contributor

Two approvals and merging. Thank you @ni4 !

@ronaldtse ronaldtse merged commit 3dcfb12 into main Oct 27, 2023
110 checks passed
@ronaldtse ronaldtse deleted the ni4-refactor-rnp_key_store_t branch October 27, 2023 03:48
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.

4 participants