open-quantum-safe / liboqs-python

Python 3 bindings for liboqs
https://openquantumsafe.org/
MIT License
108 stars 39 forks source link

Changing the ciphertext a keys #37

Closed JamshedMemon closed 2 years ago

JamshedMemon commented 3 years ago

Hi,

I am working with the liboqs-python. Wanted to know how can i change the ciphertext and input encryption and shared key. I can see that It is importing oqs library and there are functions like encap and decap inside the oqs.py file where ciphertext is being generated. However, changing oqs.py file does nothing. Could you guide how to make these changes?

thanks

dstebila commented 3 years ago

https://github.com/open-quantum-safe/liboqs-python/blob/main/examples/kem.py shows an example of how to call the KEM code.

JamshedMemon commented 3 years ago

Hi,

I am talking about the kem.py. want to know how can we have input our custom plaintext to get the ciphertext as at the moment ciphertext is being generated within encap_secret function inside oqs.py file ciphertext, shared_secret_server = server.encap_secret(public_key) It is encrypting the random generated bytes. I am changing the ciphertext inside the encap_secret function in oqs.py file but it doesnt seem to be working. Then i noticed that there are two oqs.py files one in oqs folder and another in lib folder i changed both but it is still using the random generated bytes to encap the text.

jhocce commented 2 years ago

someone managed to see the ciphertext?

dstebila commented 2 years ago

Rereading this, I think there's a misunderstanding about what KEMs do. A key encapsulation mechanism does not allow you to specify a plaintext. The "ciphertext" only allows the receiver to decapsulate to arrive at the same shared secret as the sender, but neither part can selectively control the shared secret. If you want to be able to encrypt an arbitrary plaintext, you would need to use a public key encryption scheme. While there are standard ways of building a public key encryption scheme from a KEM, that is outside the scope of what liboqs provides.