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

Can some error results be merged or replaced with panics? #85

Open
fjarri opened this issue Dec 22, 2021 · 0 comments
Open

Can some error results be merged or replaced with panics? #85

fjarri opened this issue Dec 22, 2021 · 0 comments
Labels
API Related to public API
Milestone

Comments

@fjarri
Copy link
Contributor

fjarri commented Dec 22, 2021

At the moment umbral is designed to never panic and always return a Result/Option. In some cases this results in rather silly errors that, if happen, are not something one can recover from, but rather indicate a bug in the rust-umbral, or the calling code. Perhaps we can introduce some panics to simplify the API. Although we need to remember that rust-umbral may be run in embedded environments.

Additional reading:
https://doc.rust-lang.org/book/ch09-03-to-panic-or-not-to-panic.html
https://www.unwoundstack.com/blog/rust-error-handling.html

A (perhaps non-exhaustive) list of candidates for replacement with panic:

  • OpenReencryptedError::NoCapsuleFrags - the caller should ensure that the list of cfrags is not empty
  • OpenReencryptedError::ZeroHash - very low probability of happening either randomly or intentionally (caused by some malicious actor)
  • SecretKeyFactoryError::ZeroHash - see above.
  • EncryptionError::PlaintextTooLarge - this is basically an OOM situation. In all other cases of OOM the code will panic anyway. For embedded environments we may provide an infallible encrypt_to_buffer or something.

Some errors may be merged, since they are effectively the same from the user's point of view:

  • IncorrectKeyFragSignature and IncorrectReencryption in CapsuleFragVerificationError
  • CiphertextTooShort and AuthenticationFailed in DecryptionError
  • IncorrectCommitment and IncorrectSignature in KeyFragVerificationError. Possibly merged with DelegatingKeyNotProvided and ReceivingKeyNotProvided too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Related to public API
Projects
None yet
Development

No branches or pull requests

1 participant