ctaphid-dispatch v0.3.0 makes Dispatch generic over the message size
instead of using a constant value. This patch adapts usbd-ctaphid to
this patch and changes the usbd-ctaphid buffer to use the same buffer
size as ctaphid-dispatch. (Previously, we used 3072 and
ctaphid-dispatch used 7609.) This means that we no longer need the
MESSAGE_SIZE constant and can remove it.
We only need the ctap-types for six error codes. It makes more sense to
define these error codes directly inside the crate so that we don’t need
to make usbd-ctaphid releases just to bump ctap-types.
Arguably, this also makes the code more correct: Previously, we used a
type that represents the CTAP2 error codes, but we actually want to use
the CTAPHID error codes. Those happen to be the same, but it could be a
cause for confusion.
In the future, we could also use the ctaphid-types crate instead.
When we receive a CTAPHID_CANCEL command and cancel a user presence
check, we still need to respond to the original command, typically with
a CTAP2_ERR_KEEPALIVE_CANCEL error. And if we already finished
executing the command, there is no harm in sending out its response.
With this patch, we never discard responses that have already been
calculated. Also, we never reset the pipe state and just finish the
normal command flow. We just set the interrupt flag if the
authenticator is currently processing a command.