<div dir="ltr"><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">Hi,</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">My problem is if the string that I want to decode start with null terminated char (as in a SSH pubkey), the base64_decode does not return anything at all. The encoded string itself does not have null terminated chars but rather the decoded result. The "buffer" being returned is empty. How to overcome this ? </div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">Also my C is relatively rusty, it would be great help if someone could look look at my code and suggest what I'm doing wrong. </div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">Also, I tried to use the EVP_DecodeBlock function with same result. It decodes everything except the SSH pubkey. </div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif"><br></div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">Thanks.</div><div class="gmail_default" style="font-family:'trebuchet ms',sans-serif">--Prashant</div><div class="gmail_extra"><br><div class="gmail_quote">On 18 March 2015 at 22:56, Scott Neugroschl <span dir="ltr"><<a href="mailto:scott_n@xypro.com" target="_blank">scott_n@xypro.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I believe the SSH pubkey is binary data, not ASCII, so strlen() will not work on it if it has embedded NUL chars.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">As Dave Thompson suggested, instead of strlen(), use the length returned from BIO_read.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span style="font-size:10pt;font-family:Tahoma,sans-serif"> openssl-users [mailto:<a href="mailto:openssl-users-bounces@openssl.org" target="_blank">openssl-users-bounces@openssl.org</a>]
<b>On Behalf Of </b>Prashant Bapat<br>
<b>Sent:</b> Wednesday, March 18, 2015 8:08 AM<br>
<b>To:</b> openssl-users<br>
<b>Subject:</b> Re: [openssl-users] base64 decode in C<u></u><u></u></span></p><div><div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif">Hi Dave and Walter, <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif">Thanks for our reply. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif">I'm not doing anything different for the ssh pubkey. I'm able to decode it using the "openssl enc -base64 -d -A" command. But not using the C program. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif">Attaching my entire code here. After getting the base64 decoded I'm calculating the MD5 sum and printing it. This works for a regular string but not for SSH pubkey. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif">Thanks again. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:'Trebuchet MS',sans-serif">--Prashant<u></u><u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On 18 March 2015 at 18:04, Walter H. <<a href="mailto:Walter.H@mathemainzel.info" target="_blank">Walter.H@mathemainzel.info</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal" style="margin-bottom:12pt">Hi,<br>
<br>
before calling this function,<br>
remove any whitespace;<br>
<br>
Walter<br>
<br>
<br>
<br>
_______________________________________________<br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" target="_blank">
https://mta.openssl.org/mailman/listinfo/openssl-users</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div></div>
</div>

<br>_______________________________________________<br>
openssl-users mailing list<br>
To unsubscribe: <a href="https://mta.openssl.org/mailman/listinfo/openssl-users" target="_blank">https://mta.openssl.org/mailman/listinfo/openssl-users</a><br>
<br></blockquote></div><br></div></div>