[openssl-users] base64 decode in C

Prashant Bapat prashant at apigee.com
Thu Mar 19 11:54:21 UTC 2015


Hey I got this. Sorry I was confused with the length. BIO_read returns the
length which I was able to use to get the MD5. Problem solved!!!

Many thanks.
--Pashant

On 19 March 2015 at 14:24, Prashant Bapat <prashant at apigee.com> wrote:

> Hi,
>
> 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 ?
>
> 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.
>
> Also, I tried to use the EVP_DecodeBlock function with same result. It
> decodes everything except the SSH pubkey.
>
> Thanks.
> --Prashant
>
> On 18 March 2015 at 22:56, Scott Neugroschl <scott_n at xypro.com> wrote:
>
>>  I believe the SSH pubkey is binary data, not ASCII, so strlen() will
>> not work on it if it has embedded NUL chars.
>>
>> As Dave Thompson suggested, instead of strlen(), use the length returned
>> from BIO_read.
>>
>>
>>
>>
>>
>> *From:* openssl-users [mailto:openssl-users-bounces at openssl.org] *On
>> Behalf Of *Prashant Bapat
>> *Sent:* Wednesday, March 18, 2015 8:08 AM
>> *To:* openssl-users
>> *Subject:* Re: [openssl-users] base64 decode in C
>>
>>
>>
>> Hi Dave and Walter,
>>
>>
>>
>> Thanks for our reply.
>>
>>
>>
>> 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.
>>
>>
>>
>> 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.
>>
>>
>>
>> Thanks again.
>>
>>
>>
>> --Prashant
>>
>>
>>
>> On 18 March 2015 at 18:04, Walter H. <Walter.H at mathemainzel.info> wrote:
>>
>> Hi,
>>
>> before calling this function,
>> remove any whitespace;
>>
>> Walter
>>
>>
>>
>> _______________________________________________
>> openssl-users mailing list
>> To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
>>
>>
>>
>> _______________________________________________
>> openssl-users mailing list
>> To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20150319/dfc30218/attachment.html>


More information about the openssl-users mailing list