Skip to content

Report ASN.1 decoding errors using a different error type than Unspecified #379

Closed

Description

@briansmith

In #378 (comment), @marshallpierce wrote:

Returning Unspecified here just gets turned into BadDER elsewhere... maybe in the future it would be nice to have DER-related functions return a DER error for easier mapping?

Sounds like a good idea.

AFAICT there's no cases where we're parsing secret DER, so differentiating encoding errors from other errors isn't a security issue, and it would be a usability improvement. One way to do it would be to define an strct ASN1Error; type. Then we'd have to change ever DER-parsing function to return an enum of errors, one label of which is ASN1Error, e.g.

enum SignatureVerificationError { ASN1Error, SomeOtherError }
impl From<ASN1Error> for SignatureVerificationError {
    fn from(&ASN1Error) -> Self { SignatureVerificationError::ASN1Error }
}

This should allow try!(...) and friends to work reliably.

Activity

  1. briansmith commented on Jul 12, 2019

    @briansmith
    OwnerAuthor

    Closing this. Some of this was already done (e.g. for private key parsing). If more needs to be done, we can do that in separate issues/PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions