<div dir="ltr">Thank you to everyone that has weighed in on my question.  Unfortunately, I have yet to find an answer that I'm fully satisfied with.<div><br></div><div>I'm trying a different approach: I would like to create a sample encrypted Ethereum private key that shares the same 132 character PEM format as the string I'm trying to decrypt.  I can then attempt to decrypt that string with an incorrect password, and see if I get the <span style="font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">EVP_DecryptFinal_ex:</span><wbr style="font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures"><span style="font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures">wrong final block length </span>error.  Does that make sense?</div><div><br></div><div>Here's my basic approach.  I'm starting with Vincent Kobel's excellent "Create a Full Ethereum Wallet, Keypair and Address" article (<a href="https://kobl.one/blog/create-full-ethereum-keypair-and-address/">https://kobl.one/blog/create-full-ethereum-keypair-and-address/</a>)</div><div><br></div><div>He creates a 132-character PEM formatted unencrypted private key with this command:</div><br><font face="monospace, monospace">openssl ecparam -name secp256k1 -genkey -noout </font><div><br></div><div>Unless I have completely failed at reading the man page correctly, there's no way to assign a password from the ecparam command.</div><div><br></div><div>I write the 132 character unencrypted private key (not the -----BEGIN/END EC PRIVATE KEY-----  characters) to a file named sample_pk.pem and I encrypt it with openssl:</div><div><br></div><div>







<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">openssl enc -e -aes-256-cbc -a -in sample_pk.pem -out sample_epk.pem -pass pass:secret</span></p><p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p>I now have a 256 character encrypted private string.  (Note, the string length is 256 characters whether I use AES-128 or AES-256.  That's probably obvious to all of you, but it wasn't to me).<br><br>If I decrypt that string with the correct password<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p><p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">







</span></p><p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">openssl enc -d -aes256 -a -in sample_epk.pem -out recovered.key -pass pass:secret</span></p><p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p><p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span style="font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal">I get my original unencrypted private key back.  Excellent!</span><br></span></p><p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span style="font-family:arial,sans-serif;font-size:small;font-variant-ligatures:normal"><br></span></span></p>However, If I decrypt that string with an incorrect password:</div><div><br></div>







<div><span style="font-variant-ligatures:no-common-ligatures;font-family:Menlo;font-size:11px">openssl enc -d -aes256 -a -in sample_epk.pem -out recovered.key -pass pass:secr3t</span></div><div><br></div><div>I get a new error message:<br></div><div><br></div><div>







<p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">EVP_DecryptFinal_ex:bad decrypt</span></p><p class="gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><br></span></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">And, that message does not match the <span style="font-family:Menlo;font-size:11px;font-style:normal;font-variant-ligatures:no-common-ligatures;font-variant-caps:normal;font-weight:normal">EVP_DecryptFinal_ex:</span><wbr style="font-variant-ligatures:no-common-ligatures"><span style="font-family:Menlo;font-size:11px;font-style:normal;font-variant-ligatures:no-common-ligatures;font-variant-caps:normal;font-weight:normal">wrong final block length </span>error message I was hoping to get.</p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"><br></p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal">I think that all that I have proven with this exercise is that the original unencrypted private key was:</p><p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal"></p><ul><li>not a 132 character PEM formatted unencrypted private key</li><li>and/or<br></li><li>it was not encrypted using the -aes-256-cbc encryption algorithm</li></ul><div>So, on to the question!  Can anyone help me figure out how to create an Ethereum private key such that when it is encrypted it is a 132 character long PEM formatted string?</div><div><br></div><div>Alternately, is there a process for taking an encrypted string, and "backing in" to the details of how it was created?  (ie what algorithm, etc?)</div><div> </div><div>Thanks,</div><div>Chris</div><p></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 15, 2018 at 2:01 PM, Chris B <span dir="ltr"><<a href="mailto:cryptoassetrecovery@gmail.com" target="_blank">cryptoassetrecovery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Daniel,<span class=""><div><br></div><div>><span style="font-size:12.8px">Option #1 from the possibilities you mentioned below seems to be the most logical to me.</span></div></span><div>Thank you, that's very helpful.</div><div><br></div><div>Thanks,</div><div>Chris</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, Jan 15, 2018 at 1:29 PM, Sands, Daniel <span dir="ltr"><<a href="mailto:dnsands@sandia.gov" target="_blank">dnsands@sandia.gov</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">



<div><span>
<div>On Sun, 2018-01-14 at 18:26 -0500, Chris B wrote:</div>
<blockquote type="cite">
<div dir="ltr">Hi Matt,
<div><br>
</div>
<div>><span style="font-size:12.8px">If you *are* using </span><span style="font-size:12.8px">1.1.0 then the default digest was changed between 1.0.2 and 1.1.0.</span></div>
<div>Awesome thought, but I'm also using 1.0.2:</div>
<div><br>
</div>
<div><span style="font-variant-ligatures:no-common-ligatures;font-family:Menlo;font-size:11px">$ openssl version</span></div>
<p class="m_4131458508131877278m_-682383569266261823gmail-p1" style="margin:0px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo">
<span class="m_4131458508131877278m_-682383569266261823gmail-s1" style="font-variant-ligatures:no-common-ligatures">OpenSSL 1.0.2k-fips<span class="m_4131458508131877278m_-682383569266261823gmail-Apple-converted-space"> 
</span>26 Jan 2017</span></p>
<br>
(I also tried adding -md md5 to the previous command, but I got the same error message).<br>
</div>
</blockquote>
<div><br>
</div>
</span><div>Option #1 from the possibilities you mentioned below seems to be the most logical to me. If you use the wrong key, the padding data in the last block will also be decrypted to the wrong values, so the padding block check will fail. The padding is a necessary
 part of decryption because it needs to know how much plaintext is actually represented by that last block.</div><span>
<div><br>
</div>
<blockquote type="cite">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote type="cite"><span class="m_4131458508131877278m_-682383569266261823im m_4131458508131877278m_-682383569266261823HOEnZb"><br>
> I'm not sure how to interpret that output. I could interpret it as:<br>
> o Your system for decrypting the password is perfect, but: this is not<br>
> the right password.<br>
> o There's something wrong with the EPK -- its length must be a multiple<br>
> of the AES block length.<br>
> o There's something wrong with the unencrypted private key -- its length<br>
> must be a multiple of the AES block length.<br>
> o Something else entirely<br>
</span></blockquote>
</div>
<br>
</div>
</blockquote>
</span></div>

<br></div></div><span class="">--<br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" rel="noreferrer" target="_blank">https://mta.openssl.org/mailma<wbr>n/listinfo/openssl-users</a><br>
<br></span></blockquote></div><br></div>
</blockquote></div><br></div>