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

Cannot decrypt Message instances inside ez_cli.py. #19

Open
JNicL opened this issue Oct 4, 2014 · 11 comments
Open

Cannot decrypt Message instances inside ez_cli.py. #19

JNicL opened this issue Oct 4, 2014 · 11 comments
Assignees

Comments

@JNicL
Copy link
Collaborator

JNicL commented Oct 4, 2014

Im sending a message from Bob to Alice. The information of recipient etc is transmit well, however, I get the following error when I try to clear_text()

File "ez_cli.py", line 635, in received_output
reply.data.clear_text()
File "/home/nick/eZchat/ez_message.py", line 54, in clear_text
clear_dict = ec.eZ_CryptoScheme(crypt_dict).decrypt_verify()
File "/home/nick/eZchat/ez_crypto.py", line 86, in decrypt_verify
_aes_output = eZ_AES(
_aes_input).decrypt()
File "/home/nick/eZchat/ez_crypto.py", line 233, in decrypt
_key = self.key.decode('base64')
AttributeError: 'NoneType' object has no attribute 'decode'

Is the private is not found?

You can reproduce the error as follows:

start the server via:

python ez_server "" 1234

start two clients via:

python ez_cli.py Alice

python ez_cli.py Bob

connect one client to the server (now in ez_cli)

In Alice
:connect 127.0.0.1 1234

add server to Bob

In Bob
:add server 127.0.0.1 1234

request connection

In Bob
:ips server

now Alice and Bob are connected

send a msg from Bob to Alice

In Bob
:send Alice Hi

@JNicL
Copy link
Collaborator Author

JNicL commented Oct 5, 2014

There seems to be a problem with how I create the user instances. For instance, I cannot reproduce the test_message.py inside ez_p2p.py, and when I try to use the Bob & Alice instances the Userdatabase gets corrupted and nosetests fail.

@JNicL
Copy link
Collaborator Author

JNicL commented Oct 5, 2014

OK. I found the problem. Instead of using the eu.user_database i created an instance in ez_user_methods. Retrieving and adding users was just working fine, however, there seems to be a problem with retrieving the public key.

Is this a bug? I mean it should be possible to have two working user databases at the same time.

@bijancn
Copy link
Collaborator

bijancn commented Oct 5, 2014

I would guess that this is related to the fact how you use databases. Have a look at your working directory and what database files are created. I don't think it is possible to open the same database file and write to it from two sides. Different working user databases should be no problem.

@JNicL
Copy link
Collaborator Author

JNicL commented Oct 5, 2014

I did not open the same database. Mine were initiated as follows:

  • self.UserDatabase = eu.UserDatabase(localdb=user_db_name)
    The line is found in ez_user_methods.py in init of class ez_user_methods.

Right now, when I run the test, i open the !same! database like three times. One time when including ez_users.py and twice when starting two ez_cli.py and I don't run into problems.

And I stress that the problem was not retrieving or storing userinformation, but somehow the public/private keys were not properly initiated.

@gsec
Copy link
Owner

gsec commented Oct 15, 2014

File "ez_cli.py", line 731, in received_output
ez_cli.msg_update((str(reply.data.clear_text())))
File "/home/gsec/repos/eZchat/ez_message.py", line 54, in clear_text
clear_dict = ec.eZ_CryptoScheme(crypt_dict).decrypt_verify()
File "/home/gsec/repos/eZchat/ez_crypto.py", line 87, in decrypt_verify
_aes_output = eZ_AES(
_aes_input).decrypt()
File "/home/gsec/repos/eZchat/ez_crypto.py", line 244, in decrypt
_key = self.key.decode('base64')
AttributeError: 'NoneType' object has no attribute 'decode'

@JNicL
Copy link
Collaborator Author

JNicL commented Oct 15, 2014

The bug seems to appear only when a user is created for the first time. Exchanging keys and trying to decrypt a msg fails. The problem seems to be pretty similar to what I posted two weeks ago.

@bijancn
Copy link
Collaborator

bijancn commented Oct 17, 2014

I'm investigating...

@JNicL
Copy link
Collaborator Author

JNicL commented Oct 17, 2014

Do not focus too hard on this issue. It might no longer show up after the UID fix.

@bijancn
Copy link
Collaborator

bijancn commented Oct 18, 2014

Cannot reproduce. At least not with the original description. Does it work now?

@JNicL
Copy link
Collaborator Author

JNicL commented Oct 18, 2014

I ran tests locally and the problem did not show up again. However, we should test it remotely with the tracker where the problem showed up every time the public and private keys have been generated for the first time.

@bijancn
Copy link
Collaborator

bijancn commented Oct 18, 2014

I will try to see what happens when I remove the Alice and Bob keys...

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

No branches or pull requests

3 participants