title: ASN1 encoding routines errors when verifying ECDSA signature type with openssl
body: <p>I'm trying to verify a SHA256 ECDSA digital signature provided to us by an external party. They have verified their signing process in-house, but we've been unsuccessful in our attempts.  We repeatedly get <code>asn1 encoding routines</code> errors during openssl verify, but I'm unable to see what's wrong with the signature or our process.</p>
  
  <p>Here's out test setup...
  Public key (pubkey.pem):</p>
  
  <pre><code>-----BEGIN PUBLIC KEY-----
  MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEOorVp0M8xien/r1/1Ln7TkSpzzcX
  BL/MGRz66J1HSlEgBD5FwwpO1vo6jf/9azcrrrDdCi2NH9/cSDfv5D8gTA==
  -----END PUBLIC KEY-----
  </code></pre>
  
  <p>The message being signed is the plaintext string:</p>
  
  <pre><code>HELLO
  </code></pre>
  
  <p>The digital signature (signature.sig):</p>
  
  <pre><code>JJhwReHev8cxOsNKCR5t/Ee3WU9c7tkf9RuGNamXdpXQu9OL8ZKnsrblCO7vEmOXGKGrk6NsgA5JZpQhXO3A1Q==
  </code></pre>
  
  <p>The general approach we've taken is:</p>
  
  <pre><code># create message file
  echo "HELLO" &gt; hello.txt
  
  #VERIFY
  openssl dgst -sha256 -verify pubkey.pem -signature signature.sig hello.txt
  </code></pre>
  
  <p>and the response is</p>
  
  <pre><code>Error Verifying Data
  4655195756:error:0DFFF09B:asn1 encoding routines:CRYPTO_internal:too long:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.260.1/libressl-2.6/crypto/asn1/asn1_lib.c:143:
  4655195756:error:0DFFF066:asn1 encoding routines:CRYPTO_internal:bad object header:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.260.1/libressl-2.6/crypto/asn1/tasn_dec.c:1113:
  4655195756:error:0DFFF03A:asn1 encoding routines:CRYPTO_internal:nested asn1 error:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.260.1/libressl-2.6/crypto/asn1/tasn_dec.c:306:Type=ECDSA_SIG
  
  </code></pre>
  
  <p>Alternatively, we've base64 encoding the signature <code>base64 -D signature.sig &gt; signature.bin</code> but get the same error responses.  I've tried to use <code>openssl pkeyutl</code> as well, but that results in <code>asn1 encoding routines</code> errors as well.  Using ans1parse to parse the signature yields:</p>
  
  <pre><code>openssl asn1parse -in signature.bin
  Error: offset too large
  </code></pre>
  
  <p>Clearly the digital signature is in a format I'm not handling, but I'm unable to see the problem.</p>