Does BIO_read() behave differently on diff architectures?

Venkata Veldanda vvr.83 at
Tue Aug 13 05:37:49 UTC 2019

@Andrew - Thanks for pointing that out. Indeed, that was the issue.

Get Outlook for Android

On Fri, Aug 9, 2019 at 6:18 PM +0530, "Lynch, Andrew" <andrew.lynch at> wrote:



Your issue is not with BIO_read(), but with the differing signedness of the char type on your two platforms.


On your PPC platform the char type defaults to unsigned, on your x86 platform it is signed.  The %x format expects an unsigned int, so on x86 the
 signed char values are being sign-extended to int which adds the ffffff to any values where the high bit is set (i.e. seen as negative).


One possible fix:  Change "char *ptr = buf;" to "unsigned char *ptr = buf;", then you should get the expected output.




From: openssl-users [mailto:openssl-users-bounces at]
On Behalf Of Venkata Veldanda via openssl-users

Sent: Friday, August 09, 2019 11:20 AM

To: openssl-users at

Subject: Does BIO_read() behave differently on diff architectures?


Hi Experts,


I am using openssl 1.0.2 


I recently moved my app from a PPC to x86 platform (application is compiled on the respective platform) where I met an issue with BIO_read(). 


I read a 20bytes of data using BIO_read like following..


int    res = BIO_read(bio, buf, 20);

char *ptr = buf;


The content that I send as input is a signed file content that I get from a different source. The issue is that the output 'buf' is not as expected on my x86. The behavior is different
 on different architectures. 


For e.g. on intel x86 platform I get the following output with additional 0xffffff padded.>> For me this is not the expected result. 



This is what I was getting on my PPC platform which is as expected with the same app code.



Ofcourse, I need to further check on the source where/how the signed file was generated, but does anyone have any idea if BIO_read() has any specific handling with repsect to architectures?.
 I'd rule out the endianess factor as I would expect the entire byte order to be reversed if so. 


I print the above output using the following code. 

INFO( STR(" ..> Header@%02d: %02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,"


                     ptr-buf, *(ptr+0),*(ptr+1),*(ptr+2),*(ptr+3),*(ptr+4),






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the openssl-users mailing list