I am reverse engineering a binary that contains a raw, DER-encoded X.509 certificate containing a DSA public key. I want to replace this certificate with one that I have generated so that I have access to the private key.
Due to this certificate being inside the binary, I need to replace it with a certificate of the same size in bytes, so that offsets of other data within the file are unharmed.
When I generate my own key-pair using OpenSSL, or Python, or any other method, and I export it, it is close to the file size I need, but not quite. This is just due to the random nature of generating a DSA key.
Is there an easy way to do this, besides picking my own numbers and manually performing the math necessary to generate the DSA keys? It doesn’t need to be secure, this is just a fun little experiment.