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: added a check to handle self symmetric shared #1072

Draft
wants to merge 38 commits into
base: trunk
Choose a base branch
from

Conversation

Xlin123
Copy link
Member

@Xlin123 Xlin123 commented Jun 20, 2023

- What I did
I fixed bug with AtClient.get and shared symmetric keys #1071
- How I did it
Added symmetric shared key specific exceptions and also made sure they used proper encryption type on the keys.
- How to verify it
A made a test in decryption_service_test, I'm not sure if I did it right or if it even ran in the suite.
- Description for the changelog
Fixed bug with AtClient.get and shared symmetric keys

@Xlin123 Xlin123 marked this pull request as draft June 20, 2023 23:15
@Xlin123
Copy link
Member Author

Xlin123 commented Jun 21, 2023

conclusion: to fix the issue I need to use at_chops to do RSA encryption because it's trying to use the private symmetric key to decrypt an AES key. If there's any place where at_chops is used so I can see an example it would be very helpful.

@gkc
Copy link
Contributor

gkc commented Jun 21, 2023

See here to understand what happens when, as @bob, you decrypt a message from @alice https://github.com/atsign-foundation/at_protocol/blob/trunk/usage-examples/how-to-exchange-encrypted-data.md#4-fetch-the-symmetric-key-which-alice-shared

The code which handles this is in shared_key_decryption.dart, and part of that code handles the fetching of the symmetric key, decoding from base64, and decrypting using at_chops and the 'receiving' atSign's private key

@Xlin123
Copy link
Member Author

Xlin123 commented Jun 21, 2023

Ahhh, okay got it. I did some work on self_key_decryption first since keys like "shared_key.bob@alice" I think fall under self keys. Let me know if that's incorrect and I can just revert changes. I'll do shared_key_decryption when I get home.

@Xlin123 Xlin123 marked this pull request as ready for review June 28, 2023 00:21
@Xlin123 Xlin123 requested a review from gkc June 28, 2023 00:21
@@ -19,7 +20,16 @@ class SelfKeyDecryption implements AtKeyDecryption {
intent: Intent.decryptData,
exceptionScenario: ExceptionScenario.decryptionFailed);
}

if (atKey.key == "shared_key") {
Copy link
Contributor

Choose a reason for hiding this comment

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

The copy alice will create for themselves of a shared key they cut for bob will be shared_key.bob@alice. Will this test work? What happens when you use this branch with your REPL?

@@ -19,7 +20,16 @@ class SelfKeyDecryption implements AtKeyDecryption {
intent: Intent.decryptData,
exceptionScenario: ExceptionScenario.decryptionFailed);
}

if (atKey.key == "shared_key") {
if (atKey.sharedWith != _atClient.getCurrentAtSign()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

sharedWith is not set - when we create shared_key.bob@alice - again, what happens when you run this branch with your REPL? Do you get the desired outcomes?

@Xlin123
Copy link
Member Author

Xlin123 commented Jun 28, 2023

Two decryptable cases
image

However, /get @bob:shared_key@alice isn't throwing it's exception properly. I should finish it tonight.

@Xlin123
Copy link
Member Author

Xlin123 commented Jun 28, 2023

image
@gkc I think I fixed everything.

@gkc
Copy link
Contributor

gkc commented Jun 28, 2023

Please add unit tests which verify each case

@Xlin123 Xlin123 marked this pull request as draft July 10, 2023 21:20
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.

2 participants