[openssl-dev] [eng_rdrand] alloc and free

Catalin Vasile cata.vasile at nxp.com
Sun Jan 24 13:47:13 UTC 2016



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

In message <DB5PR04MB1302BB3B91A8955DC8BB1DCFEEC30 at DB5PR04MB1302.eurprd04.prod.outlook.com> on Thu, 21 Jan 2016 10:57:19 +0000, Catalin Vasile <cata.vasile at 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         levitte at openssl.org
OpenSSL Project         http://www.openssl.org/~levitte/
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


More information about the openssl-dev mailing list