Skip to content

Removing warnings from libencrypt and libdecrypt #2629

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

Merged
merged 14 commits into from
Jul 30, 2024
Merged

Conversation

behzadmehmood-rs
Copy link
Contributor

Description

This change simply removes warnings due to type casting.

Related Issue

Motivation and Context

It is necessary for a warning free CI.

How Has This Been Tested?

Types of changes

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@behzadmehmood-rs behzadmehmood-rs self-assigned this Jun 25, 2024
@github-actions github-actions bot added the lang-cpp C/C++ code label Jun 25, 2024
@behzadmehmood-rs behzadmehmood-rs marked this pull request as draft June 25, 2024 13:07
@github-actions github-actions bot added the lang-make CMake/Make code label Jul 8, 2024
@behzadmehmood-rs behzadmehmood-rs marked this pull request as ready for review July 9, 2024 03:59
@behzadmehmood-rs
Copy link
Contributor Author

@tangxifan some QoR tests are failing in CI which are not related to the changes in this PR.

@tangxifan
Copy link
Contributor

@behzadmehmood-rs Thanks. The CI failures are expected then. Good job.

@tangxifan
Copy link
Contributor

@Tulong4Dev Please help on reviewing this PR.

Copy link
Contributor

@Tulong4Dev Tulong4Dev left a comment

Choose a reason for hiding this comment

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

did a quick screening and suggested to make some minor fix.
meanwhile, i'm afraid there could be some memory leakage which i suggest to use valgrind to detect and verify it, if possible.

*
* @param input The base64-encoded input string.
* @return The decoded output string.
* @param encoded he base64-encoded input string.
Copy link
Contributor

Choose a reason for hiding this comment

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

"he" -> "the"

std::ptrdiff_t offset = 0;
char buffer[1024];
std::size_t size;
//std::ptrdiff_t offset = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the commented unused variables.

unsigned char iv[EVP_MAX_IV_LENGTH];
if (RAND_bytes(iv, sizeof(iv)) != 1) {
std::cerr << "Error generating IV." << std::endl;
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

should return a Boolean here.

RSA* publicKey = loadPublicKey(publicKeyFile);
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
unsigned char sessionKey[16];
Copy link
Contributor

Choose a reason for hiding this comment

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

can we avoid using constant number here ("16") directly? we can use a meaningful constant variable to represent it.

@behzadmehmood
Copy link

did a quick screening and suggested to make some minor fix. meanwhile, i'm afraid there could be some memory leakage which i suggest to use valgrind to detect and verify it, if possible.

I have made the changes, now I will run it with valgrind.

@behzadmehmood
Copy link

did a quick screening and suggested to make some minor fix. meanwhile, i'm afraid there could be some memory leakage which i suggest to use valgrind to detect and verify it, if possible.

I have made the changes, now I will run it with valgrind.

@Tulong4Dev , I have also updated the code to avoid memory leaks.

Copy link
Contributor

@Tulong4Dev Tulong4Dev left a comment

Choose a reason for hiding this comment

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

LGTM. In addition, I'd suggest to add a test with encrypt/decrypt so VTR's Valgrind test flow could help to detect potential memory leak.

@behzadmehmood
Copy link

LGTM. In addition, I'd suggest to add a test with encrypt/decrypt so VTR's Valgrind test flow could help to detect potential memory leak.

Is it okay to put the test data and code in libdecrypt?

@github-actions github-actions bot added the infra Project Infrastructure label Jul 10, 2024
@behzadmehmood
Copy link

LGTM. In addition, I'd suggest to add a test with encrypt/decrypt so VTR's Valgrind test flow could help to detect potential memory leak.

@Tulong4Dev I have added a test but I could not update workflow file properly. Can you please suggest how should I run the test?

@behzadmehmood
Copy link

@tangxifan , @Tulong4Dev please review again. Code is updated and test has been added.

#endif

// Function to create a sample XML file for testing
void createTestXMLFile(const std::string& filePath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Tulong4Dev Please check if the test provided is sufficient. If a local run on the unit test is o.k., I suggest to merge this PR. This PR is currently a blocking factor on another PR #2637

@tangxifan tangxifan merged commit 9eef18c into openfpga Jul 30, 2024
51 of 53 checks passed
@tangxifan tangxifan deleted the rem_warnings branch July 30, 2024 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra Project Infrastructure lang-cpp C/C++ code lang-make CMake/Make code libpugiutil
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants