________________________________________
From: openssl-dev <openssl-dev-boun...@openssl.org> on behalf of Richard 
Levitte <levi...@openssl.org>
Sent: Friday, January 22, 2016 2:20 AM
To: openssl-dev@openssl.org
Subject: Re: [openssl-dev] [eng_rdrand] alloc and free

In message 
<db5pr04mb1302bb3b91a8955dc8bb1dcfee...@db5pr04mb1302.eurprd04.prod.outlook.com>
 on Thu, 21 Jan 2016 10:57:19 +0000, Catalin Vasile <cata.vas...@nxp.com> said:

cata.vasile> ENGINE_load_rdrand() creates a new engine, it adds
cata.vasile> it/registers it and then frees it. Looking further into
cata.vasile> these functions, the registration does NOT create a new
cata.vasile> object and then copy the data into it, so the
cata.vasile> registration is based on an object that it's later
cata.vasile> released.

Welllll....  not quite!  Pointers to engines aren't merely pointers,
they are more like handles and have reference counters.  So, the
called `ENGINE *toad = ENGINE_rdrand()' will create the reference to a
new ENGINE object, that is correct.  Three lines later, the call
`ENGINE_add(toadd)' will create a new reference to the same object, by
incrementing the reference counter, and will store the pointer to the
object in OpenSSL's internal list.  The following call
`ENGINE_free(toadd)' simply decrements the reference counter (from 2
to 1) but does not actually free the object (that would require
another ENGINE_free).

Does that make it clearer? 
Absolutely clear
For further info, may I suggest you do
`perldoc doc/crypto/engine.pod', and most specifically read the
section titled "Reference counting and handles"?
Thanks for the reference.

Cheers,
Richard

--
Richard Levitte         levi...@openssl.org
OpenSSL Project         http://www.openssl.org/~levitte/
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev

Reply via email to