| Commit message (Collapse) | Author | Age |
|
|
|
|
| |
For consistency with the other Error variants, we rename Unknown to
UnknownError.
|
|
|
|
|
|
|
|
|
| |
Many of our functions do not return a Result<_, Error>, but for example
a Result<_, (Device, Error)>. We only use the typedef in one function,
but it makes the other functions more complicated as we have to use
result::Result (if crate::Result is imported). Therefore, this patch
removes the typedef. Applications or libraries can still redefine it if
they want to.
|
|
|
|
|
|
|
| |
rand_core does not have a stable release yet, and it is unlikely that
there will be one soon. To be able to stabilize nitrokey without
waiting for a stable rand_core version, we remove the rand_core::Error
type from the public API and replace it with a Box<dyn error::Error>.
|
|
|
|
|
|
|
| |
This patch adds license and copyright information to all files to make
nitrokey-rs compliant with the REUSE practices [0].
[0] https://reuse.software/practices/2.0/
|
|
|
|
|
|
| |
Not all users of the authenticate methods want to use the device after
an error, so implementing From<(T: Device, Error)> for Error makes it
easier for them to discard the device.
|
|
|
|
|
| |
Previously, we just ignored UTF-8 errors. This patch prepares the
Utf8Error variant so that we are able to return UTF-8 errors.
|
|
|
|
|
|
| |
The CommandError::Undefined variant has been refactored into
Error::UnexpectedError and CommunicationError::NotConnected and is
therefore no longer needed.
|
|
|
|
|
|
|
| |
The UnexpectedError variant is used when a libnitrokey function returns
a value that violates the function’s contract, for example if a function
returns a null pointer although it guarantees to never return null.
Previously, we returned a CommandError::Unspecified in these cases.
|
|
|
|
| |
For example, the WrongSlot error may also be returned for a PWS slot.
|
|
|
|
|
| |
AsStr is automatically implementeded if Display is implemented, so
having a manual as_str() method is not necessary.
|
|
|
|
|
|
| |
Communication errors returned by libnitrokey were previously not mapped
to an error type in the nitrokey crate. We introduce the
CommunicationError enum to represent these errors.
|
|
|
|
|
|
| |
Previously, library errors were part of the CommandError enum. As
command errors and library errors are two different error types, they
should be split into two enums.
|
|
|
|
|
|
|
| |
An error code can not only indiciate a command error, but also a library
or device communication error. Therefore, the variant for an unknown
error code should be placed in the top-level Error enum instead of the
CommandError enum.
|
|
|
|
|
| |
We reserve CommandError for errors returned by the Nitrokey device.
Errors during random number generation should have their own type.
|
|
|
|
|
|
|
|
|
|
| |
This patch changes all public functions to return the Error enum instead
of the CommandError enum. This breaks the tests which will be fixed
with the next patch.
This patch also adds a placeholder variant Error::CommandError and a
placeholder enum CommandError to make the transition to a new
nitrokey-test version easier.
|
|
|
|
|
| |
The Error enum is a wrapper for the possible error types (currently only
CommandError). Result<T> is defined as Result<T, Error>.
|
| |
|
|
This prepares the refactoring of util::CommandError into multiple enums.
|