<div dir="ltr"><div>Thanks for the update.</div><div><br></div><div>I&#39;m having another weird bug. Decryption works sometimes, but this is due to the ciphertext length not always being a multiple of 16 (AES-256 block length).</div><div><br></div><div>Directly after reading from stdin, I have the following two debug lines:</div><div>        printf(&quot;read %lu bytes\n&quot;, nread);<br>        printf(&quot;encrypted length: %lu\n&quot;, strlen(buff + 8 + SALT_LENGTH));</div><div><br></div><div>It always reads 176 bytes when using the same constant input. However, the encrypted length is 160 when it&#39;s properly decrypted, and various other lengths when it fails (I&#39;ve seen 95, 53, 43, etc.) `buff` is properly null-terminated. `nread` is the return value of read(2).<br></div><div><br></div><div>The exact error is:</div><div>140187583043396:error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length:/usr/src/crypto/external/bsd/openssl/dist/crypto/evp/evp_enc.c:505</div><div><br></div><div>Any advice would be greatly appreciated. I&#39;ve tried debugging myself and looking at various online resources, but haven&#39;t found anything too helpful.<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 5, 2017 at 12:03 PM Jan Schaumann &lt;<a href="mailto:jschauma@stevens.edu">jschauma@stevens.edu</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Jason G Ajmo &lt;<a href="mailto:jajmo@stevens.edu" target="_blank">jajmo@stevens.edu</a>&gt; wrote:<br>
<br>
&gt; I began working on the code last night to decrypt an input passed to<br>
&gt; crysh using the professor&#39;s examples, but I&#39;m only able to decrypt the<br>
&gt; input assuming it uses an MD5 digest instead of SHA1.<br>
<br>
You&#39;re right.  The examples provided in the manual page did not use the<br>
right digest.  I&#39;ve updated the man page.  The correct input generation<br>
is:<br>
<br>
echo &quot;date&quot; | openssl enc -aes-256-cbc -md sha1 | crysh<br>
<br>
-Jan<br>
_______________________________________________<br>
cs631apue mailing list<br>
<a href="mailto:cs631apue@lists.stevens.edu" target="_blank">cs631apue@lists.stevens.edu</a><br>
<a href="https://lists.stevens.edu/mailman/listinfo/cs631apue" rel="noreferrer" target="_blank">https://lists.stevens.edu/mailman/listinfo/cs631apue</a><br>
</blockquote></div><div dir="ltr">-- <br></div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Jason Ajmo</div><div>Stevens Institute of Technology</div><div>B.S. Cybersecurity &#39;17</div><div>M.S. Computer Science &#39;18</div><div>0x56FA3123</div></div></div>