Using openssl with embedded systems

2019-05-23 Thread Mahmoud Abd El-Hafeez
Greetings,
I wonder if it's possible to compile the library for Microcontrollers like
ARM STM32
The situation is: I have some project written c code that depends on
OpenSSL library functionality. The project assumes that OpenSSL is
installed on the machine. I want to cross compile the project for some
microcontroller architecture like mentioned above. Is there a way to:
1- Compile the OpenSSL library to produce the .a files using the
microcontroller special compiler like GNU for ARM?
Or
2- Include all the library source files and headers to be compiled with the
project using the microcontroller special compiler?

Is there a way to handle the opensslconf.h and bn.h for the
microcontroller's compiler and architecture?

Please accept my apologize if questions are not eligible or not in the
right place.

Thank you


Re: Compiling openssl executable as static binary

2019-05-23 Thread Raveendra Padasalagi via openssl-users
Thanks Richard, this is what I was expecting. It worked.

Configure script is not showing this option.

Configuring OpenSSL version 3.0.0-dev for target
Using os-specific seed configuration
Usage: Configure [no- ...] [enable- ...] [-Dxxx] [-lxxx]
[-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared]
[[no-]zlib|zlib-dynamic] [no-asm] [no-egd] [sctp] [386] [--prefix=DIR]
[--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE]
os/compiler[:flags]

Regards,
Raveendra

On Thu, May 23, 2019 at 6:36 PM Richard Levitte  wrote:

> How static do you want it to be?  There is the configuration option
> '-static' that makes the binary as independent as possible, i.e. even
> links it with static libc.
>
> Cheers,
> Richard
>
> On Thu, 23 May 2019 08:26:43 +0200,
> Raveendra Padasalagi via openssl-users wrote:
> >
> >
> > Hi,
> >
> >
> >
> > Any help/pointers on compiling openssl library to generate static
> version of openssl executable
> > for ARM64 bit linux platform will help.
> >
> >
> >
> > Thanks,
> >
> > Raveendra
> >
> >
> --
> Richard Levitte levi...@openssl.org
> OpenSSL Project http://www.openssl.org/~levitte/
>


Re: Compiling openssl executable as static binary

2019-05-23 Thread Richard Levitte
How static do you want it to be?  There is the configuration option
'-static' that makes the binary as independent as possible, i.e. even
links it with static libc.

Cheers,
Richard

On Thu, 23 May 2019 08:26:43 +0200,
Raveendra Padasalagi via openssl-users wrote:
> 
> 
> Hi,
> 
>  
> 
> Any help/pointers on compiling openssl library to generate static version of 
> openssl executable
> for ARM64 bit linux platform will help.
> 
>  
> 
> Thanks,
> 
> Raveendra
> 
> 
-- 
Richard Levitte levi...@openssl.org
OpenSSL Project http://www.openssl.org/~levitte/


Opaque structures - Cant access buf_len variable from evp_cipher_ctx_st

2019-05-23 Thread Pedro Lopes
Good morning,

I'd like to know how to get buffer length from cipher structures since 1.1
version.

I'm using that variable member to know what should be the required length
if something gets wrong and return to the caller. Snippet of my source code:

DecryptUpdate(unsigned char* pEncryptedPart, unsigned long int
ulEncryptedPartLen,
unsigned char* pPart, unsigned long int *pulPartLen){

unsigned long required_rest = (ctx.buf_len + ulEncryptedPartLen) %
EVP_CIPHER_block_size(mCipher);
unsigned long required_len = ctx.buf_len + ulEncryptedPartLen -
required_rest;

if (pPart == NULL_PTR || *pulPartLen < required_len)
{
*pulPartLen = required_len;
return pPart == NULL_PTR  ? CKR_OK : CKR_BUFFER_TOO_SMALL;
}
...
}

-- 
Kind Regards,
Pedro Lopes


RE: Compiling openssl executable as static binary

2019-05-23 Thread Raveendra Padasalagi via openssl-users
Yes Paul.



I tried following steps:



export INSTALLDIR=/tmp/openssl_arm

export OPENSSLDIR=/tmp/openssl_arm

export PATH=$INSTALLDIR/bin:$PATH

export CROSS=aarch64-linux-gnu

export CC=${CROSS}-gcc

export LD=${CROSS}-ld

export AS=${CROSS}-as

export AR=${CROSS}-ar

export AR=${CROSS}-ar

./Configure linux-arm64 *no-shared*

make

make install



Thanks,

Raveendra

*From:* Dr Paul Dale [mailto:paul.d...@oracle.com]
*Sent:* Thursday, May 23, 2019 12:10 PM
*To:* Raveendra Padasalagi
*Cc:* openssl-users@openssl.org
*Subject:* Re: Compiling openssl executable as static binary



Link against the generated .a files rather than the .so ones?





Pauli

-- 
Dr Paul Dale | Cryptographer | Network Security & Encryption
Phone +61 7 3031 7217
Oracle Australia







On 23 May 2019, at 4:26 pm, Raveendra Padasalagi via openssl-users <
openssl-users@openssl.org> wrote:



Hi,



Any help/pointers on compiling openssl library to generate static version
of openssl executable for ARM64 bit linux platform will help.



Thanks,

Raveendra


Re: Compiling openssl executable as static binary

2019-05-23 Thread Dr Paul Dale
Link against the generated .a files rather than the .so ones?


Pauli
-- 
Dr Paul Dale | Cryptographer | Network Security & Encryption 
Phone +61 7 3031 7217
Oracle Australia



> On 23 May 2019, at 4:26 pm, Raveendra Padasalagi via openssl-users 
>  wrote:
> 
> Hi,
>  
> Any help/pointers on compiling openssl library to generate static version of 
> openssl executable for ARM64 bit linux platform will help.
>  
> Thanks,
> Raveendra



Compiling openssl executable as static binary

2019-05-23 Thread Raveendra Padasalagi via openssl-users
Hi,



Any help/pointers on compiling openssl library to generate static version
of openssl executable for ARM64 bit linux platform will help.



Thanks,

Raveendra