nucypher / pyUmbral

NuCypher's reference implementation of Umbral (threshold proxy re-encryption) using OpenSSL and Cryptography.io
https://pyumbral.readthedocs.io
GNU General Public License v3.0
284 stars 71 forks source link

What's a better error message in decapsulate_reencrypted than "generic umbral error"? #22

Open jMyles opened 6 years ago

jMyles commented 6 years ago

I don't exactly understand what is being asserted here.

Perhaps, "This capsule doesn't appear to have been made for this public key" ?

jMyles commented 6 years ago

This error seems to be raised if not enough cFrags are present to open the Capsule.

However, currently the assertion requires original Alice components to check. @cygnusv: Is there a way to check without those?

cygnusv commented 6 years ago

That check is ensuring that the reconstructed capsule comes from the original capsule, so by definition, there is no way to check that without the original components.

There are many possible problems that may make this check to fail, but from the cryptographic point of view, we don't want to give detailed information of the error in order to avoid potential attacks. The reason is that there are many attacks out there exploiting the different possible error messages to infer secret information (e.g., private keys). An example (not applicable here), is padding oracle attacks

cygnusv commented 6 years ago

Having said that, this error message could be something like you said: "This capsule doesn't appear to have been made for this public key" or perhaps "This capsule doesn't appear to be openable with your private key"

tuxxy commented 6 years ago

I propose: "Failed to decrypt with the provided private key"

jMyles commented 6 years ago

Poking around, I seem to be able to generate this error in two ways:

1) Trying to decap with the wrong private key. 2) Trying to decap without enough cFrags.

Is there a way to naively (ie, without injecting the value of m) distinguish between these problems? Worse to give a generic error message is to give an incorrect one.

jMyles commented 6 years ago

There are many possible problems that may make this check to fail, but from the cryptographic point of view, we don't want to give detailed information of the error in order to avoid potential attacks. The reason is that there are many attacks out there exploiting the different possible error messages to infer secret information (e.g., private keys)

Well, if something is knowable in the scope of this function, then it is already in the purview of an attacker who has direct witness over its execution. Sure, we don't want to encourage users to spread detailed error information in a public way (as with any application), but I don't think there's any harm in this function failing in such a way that discriminates between the various possibilities, is there?

cygnusv commented 6 years ago

Is there a way to naively (ie, without injecting the value of m) distinguish between these problems?

I think there is not (and there shouldn't be).

Well, if something is knowable in the scope of this function, then it is already in the purview of an attacker who has direct witness over its execution.

Yes, that's true, but that's not the target type of adversary for this measure. We are dealing here with the ones that have black-box access (e.g., remote access).

jMyles commented 6 years ago

Yes, that's true, but that's not the target type of adversary for this measure. We are dealing here with the ones that have black-box access (e.g., remote access).

Exactly, so there's no harm in the function raising different errors for these different conditions.

KPrasch commented 6 years ago

This now an exception class umbral.GenericUmbralError. Still could use a better message.

tuxxy commented 6 years ago

I think we can go ahead and close this now. @jMyles @KPrasch @cygnusv

KPrasch commented 6 years ago

At the moment, there is no message at all: https://github.com/nucypher/pyUmbral/blob/master/umbral/pre.py#L476

Edit: line moved: https://github.com/nucypher/pyUmbral/blob/master/umbral/pre.py#L440

KPrasch commented 6 years ago

Do we intend to leave the message blank here? https://github.com/nucypher/pyUmbral/blob/master/umbral/pre.py#L440