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

Write tests for lib/utils/encryptor.dart #2149

Closed
palisadoes opened this issue Nov 26, 2023 · 12 comments
Closed

Write tests for lib/utils/encryptor.dart #2149

palisadoes opened this issue Nov 26, 2023 · 12 comments
Labels
good first issue Good for newcomers test Testing application

Comments

@palisadoes
Copy link
Contributor

palisadoes commented Nov 26, 2023

The Talawa code base needs to be 100% reliable. This means we need to have 100% unittest code coverage. No functionality must be removed to achieve this goal.

We will need unittests done for all methods, classes and functions found in this file.

Any widgets referenced in this file must also have unittests done

lib/utils/encryptor.dart

The current code coverage for this file can be found here:

@palisadoes palisadoes added good first issue Good for newcomers test Testing application labels Nov 26, 2023
@github-actions github-actions bot added the unapproved Unapproved, needs to be triaged label Nov 26, 2023
@imshivam-gupta
Copy link
Contributor

imshivam-gupta commented Dec 4, 2023

@Ayush0Chaudhary @noman2002 I would like to work on this issue.. can you please assign it to me?

@Ayush0Chaudhary
Copy link
Contributor

Solve other issues first

@Manik2708
Copy link
Contributor

@Ayush0Chaudhary @noman2002 Can you assign this issue to me?

@noman2002 noman2002 removed the unapproved Unapproved, needs to be triaged label Dec 6, 2023
@Manik2708
Copy link
Contributor

There is a problem lying in the generateRSAKeyPair() function, the parameters passed in final random = SecureRandom('Fortuna') ..seed(secureRandom as CipherParameters); are wrong as secureRandom is not a Cypher Parameter. When changed to the KeyParametres then to start AES Enginer, a key is required and also more configurations are required which can't be done without the assistance of Maintainers. See this link for more info: AES-CBC with Pointy Castle

@Manik2708
Copy link
Contributor

If Maintainers can allow me, I can move forward with random configurations which can be modified further, otherwise test can't be written as parameters are wrong!

@noman2002
Copy link
Member

@literalEval Please answer this query.

@Manik2708
Copy link
Contributor

Manik2708 commented Dec 6, 2023

AsymmetricKeyPair<PublicKey, PrivateKey> generateRSAKeyPair() {
    final secureRandom = FortunaRandom();
    final random = Random.secure();
    final List<int> seeds = [];
    for (int i = 0; i < 32; i++) {
      seeds.add(random.nextInt(255));
    }
    secureRandom.seed(KeyParameter(Uint8List.fromList(seeds)));
    final rsapars = RSAKeyGeneratorParameters(BigInt.from(65537), 2048, 64);
  final params = ParametersWithRandom(rsapars, secureRandom);
  final keyGenerator = RSAKeyGenerator();
  keyGenerator.init(params);
  return keyGenerator.generateKeyPair();
  }

I have modified this function in this way with the help of the blog Asymmetric Key Generation in Flutter. Kindly check if it is right as it is working fine!

@Manik2708
Copy link
Contributor

Was waiting for the response, so I raised a PR #2220, the function is modified, kindly review the PR.

@Manik2708
Copy link
Contributor

I think the PR is not linked with this issue. PR is merged, please close this issue. Will keep in mind next time to link PR properly with issue.

@Manik2708 Manik2708 removed their assignment Dec 23, 2023
@literalEval
Copy link
Member

literalEval commented Dec 25, 2023

Hello @Manik2708. Sorry for being late to the discussion. There were some package changes for the encryption system in the end, which might have caused the issue. The idea was to write a skeleton which can be easily implemented. Thanks for pointing out the issue.

If you are interested, we can work on enhancing the encryption system. Thanks and regards.

@Manik2708
Copy link
Contributor

Hello @Manik2708. Sorry for being late to the discussion. There were some packages changes for the encryption system in the end, which might have caused the issue. I idea was to write a skeleton which can be easily implemented. Thanks for pointing out the issue.

If you are interested, we can work on enhancing the encryption system. Thanks and regards.

No problem, I understand your time constraints. I request you to kindly view the function which I have modified. Is it consistent with the security options? Currently Encryption is working well. I am also working on Chats System in my personal project. So it's a kind of suggestion to move to Cassandra Database for Chats (Other Databases will fail to provide DELETE option to users) in backend. Then I think Chats would work more efficiently. Currently @palisadoes said that Chats are not working, I think we can create a seperate branch to give it a try for chats. Or it might be a probable project for GSoC.

@palisadoes
Copy link
Contributor Author

Fixing Chat and notifications will be a GSoC project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers test Testing application
Projects
None yet
Development

No branches or pull requests

6 participants