Hello,
we are implementing a TLS 1.3 feature into OpenSSL to get an idea of how well our feature performs in a concrete server library. In the feature, we want to use the log function. When we try to use the log function from the math.h header, OpenSSL won't compile with the statement that 'log' is a reference to an undefined function. The BigNum library from OpenSSL does also not seem to offer a log function. We suspect that the compile error comes from the fact that OpenSSL is C90 compatible but are unsure. Does anyone know how to compute the logarithm of a number in OpenSSL? Thanks, Niklas 
If you want to use the log() from math.h, then you must compile with lm, eg.: clang source.c lm The log() in math.h only supports floating point numbers. If you require computing logarithms of bignums, try https://www.mpfr.org/ On Wed, Jul 24, 2019 at 6:39 PM Niklas Niere <[hidden email]> wrote: Hello, 
Thank you for the answer. We are using the Makefile from OpenSSL to compile our feature as it changes OpenSSL directly. As I understood it, we would have to import another number library to compile our code with the standard OpenSSL settings and using the logarithm, correct? On 20190724 6:51 p.m., Guido Vranken
wrote:

log() in math.h only supports float or double type. float and double are limited in the range of numbers they can express. For example, these types cannot hold large numbers like "99999999999999999999999999999999999999999". Depending on your purpose, float and double may be sufficient, and you can use log() from math.h and link with lm. If you require logarithms of large numbers, you'll have to resort to a library that supports this, like the one I linked to. Alternatively, you can implement a logarithm extension to OpenSSL's bignum library using existing bignum functions. On Wed, Jul 24, 2019 at 7:02 PM Niklas Niere <[hidden email]> wrote:

In reply to this post by Niklas Niere
[hidden email] said: > If you require logarithms of large numbers, you'll have to resort to a > library that supports this, like the one I linked to. Or scale the large number so it fits and add the log of the scale factor which you can compute by hand from the scale factor. For example, log10(1234) is log10(1.234)+3*log10(10).  These are my opinions. I hate spam. 
In reply to this post by Niklas Niere
I’m wondering why you need the log function?
If you’re measuring performance, could the analysis tool perform the logarithm? A first order approximation to log_2(n) where n is a BIGNUM would be BN_num_bits(n). Pauli  Dr Paul Dale  Cryptographer  Network Security & Encryption Phone +61 7 3031 7217 Oracle Australia > On 25 Jul 2019, at 2:22 am, Niklas Niere <[hidden email]> wrote: > > Hello, > > we are implementing a TLS 1.3 feature into OpenSSL to get an idea of how well our feature performs in a concrete server library. In the feature, we want to use the log function. > > When we try to use the log function from the math.h header, OpenSSL won't compile with the statement that 'log' is a reference to an undefined function. The BigNum library from OpenSSL does also not seem to offer a log function. > > We suspect that the compile error comes from the fact that OpenSSL is C90 compatible but are unsure. Does anyone know how to compute the logarithm of a number in OpenSSL? > > Thanks, > Niklas > 
The BN_num_bits() approximation is exactly what we need. We need it to
compute the depth of a node in a binary tree of which we only have a sub tree available. Thank you, Niklas On 24.07.2019 23:59, Dr Paul Dale wrote: > I’m wondering why you need the log function? > If you’re measuring performance, could the analysis tool perform the logarithm? > > A first order approximation to log_2(n) where n is a BIGNUM would be BN_num_bits(n). > > > Pauli 
Free forum by Nabble  Edit this page 