[openssl-dev] Making assembly language optimizations working onCortex-M3

Andy Polyakov appro at openssl.org
Sat Jun 25 21:55:41 UTC 2016


> The BoringSSL works as follows:
> 
> 1. The person building the code passes -DOPENSSL_STATIC_ARMCAP and some
> other flags like -DOPENSSL_STATIC_ARMCAP_NEON, to indicate which
> features are available on the target.
> 
> 2. When OPENSSL_STATIC_ARMCAP is defined, the runtime detection of
> features is disabled.
> 
> 3. When OPENSSL_STATIC_ARMCAP is defined, OPENSSL_armcap_P is fixed to a
> value based on which of DOPENSSL_STATIC_ARMCAP_NEON, etc. are defined.
> 
> 4. When OPENSSL_STATIC_ARMCAP isn't defined, then everything works like
> it currently does; i.e. features are detected at runtime.
> 
> The idea is that, instead having to go in and manually edit the code for
> each different target system, one can just define these flags and the
> code will auto-configure itself at build-time.

I again seem to be failing to grasp the point. For far I was under
impression that goal [denoted by subject] is to minimize resource
consumption including code size. OPENSSL_STATIC_ARMCAP doesn't reduce
code size, it simply sets OPENSSL_armcap_P to predefined value. And as
we already established that we are talking about some overly specific
usage case effectively outside OpenSSL, then why don't you simply
replace armcap.c with one-liner that assigns OPENSSL_armcap_P to 0 or 1?

>     The problem here is you can't have both and having the capability
>     switch at runtime depending on hardware quirks is the better option
>     for the majority of users.
> 
> That's usually true, but the topic of this thread is about how to get
> OpenSSL working well on Cortex-M microcontrollers. In those situations,
> we cannot really afford the dynamic detection or the many different
> implementations of the same algorithm to exist in the final image.

I doubt that current OPENSSL_STATIC_ARMCAP implementation result in any
code savings. In order for compiler to omit code OPENSSL_armcap_P has to
be at least declared constant (and it's not) and code omission can be
performed only during link-time optimizations. Latter should not be
recommended in security programming context and we don't...



More information about the openssl-dev mailing list