Closed ihsanhaikalz closed 6 years ago
Hi @ihsanhaikalz thanks for submitting the issue! I'll have a look in the next few days. And yes I agree with the bug, I sincerely don't remember why I wrote it like that.
After reviewing the code I remembered the reason behind that choice.
In our use case, we didn't need to set the message to a specific value, but we use the random element as key for the encryption algorithm (hence using two steps: encrypt the resource with a symmetric schema and encrypt the key with a policy based asymmetric schema).
I changed the code adding an utility function that generates random elements for my use case and changed the standard enc
API to use the content of Message
as you suggested.
I discovered this bug while running the test case of your library.
I understand that you want to associate the message byte array with the element M that is generated randomly but surely this won't allow if we set the message by ourselves. Also the bug itself will actually passes the test but also the test should be wrong as in the test case there isn't any byte assigned to it then suddenly after encryption the byte is then filled with random element M, which is wrong.
What I suggest for fix of this bug is something like this: