title: What's the proper way to get a fixed-length bytes representation of an ECDSA Signature?
body: <p>I'm using python and cryptography.io to sign and verify messages.  I can get a DER-encoded bytes representation of a signature with:</p>
  
  <p><code>cryptography_priv_key.sign(message, hash_function)</code></p>
  
  <p>...per this document: <a href="https://cryptography.io/en/latest/hazmat/primitives/asymmetric/ec/" rel="nofollow noreferrer">https://cryptography.io/en/latest/hazmat/primitives/asymmetric/ec/</a></p>
  
  <p>A DER-encoded ECDSA Signature from a 256-bit curve is, at most, 72 bytes; see: <a href="https://stackoverflow.com/questions/17269238/ecdsa-signature-length">ECDSA signature length</a></p>
  
  <p>However, depending on the values of r and s, it can also be 70 or 71 bytes.  Indeed, if I examine length of the output of this function, it varies from 70-72.  Do I have that right so far?</p>
  
  <p>I can decode the signature to ints r and s.  These are both apparently 32 bytes, but it's not clear to me whether that will <em>always</em> be so.</p>
  
  <p>Is it safe to cast these two ints to bytes and send them over the wire, with the intention of encoding them again on the other side?</p>