Hi,
We are planning to make use of openssl crypto library in multithreaded
environment.
We call OpenSSL_add_all_algorithms() before creating threads and will create
BIO, EVP_KEY, SHA256 , SHA1 and RSA object in each thread and makes use of
the following functions:
SHA1_Init BIO_new_mem_buf EVP_PKEY_get1
RSA_size
SHA1_Final BIO_free EVP_PKEY_free
RSA_PKCS1_PADDING
SHA1_Update BIO_write EVP_cleanup
RSA_free
SHA256_Init BIO_flush
RSA_verify
SHA256_Final BIO_new
SHA256_Update BIO_s_mem
We found in the openssl website that "OpenSSL can safely be used in
multi-threaded applications provided that at least two callback functions
are set, locking_function and threadid_func." And from FAQ, its stated that
"Openssl is thread safe with limitations [ SSL connections may not be used
concurrently in many threads]" .
So, can someone let us know that the functions mentioned above are MT safe
without implementing the two callback functions.
Thanks in advance,
Deiva Shanmugam
--001636e0ae4d6b05a9047324b732
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<span style=3D"font-family: arial,helvetica,sans-serif;">Hi,</span><br styl=
e=3D"font-family: arial,helvetica,sans-serif;"><br style=3D"font-family: ar=
ial,helvetica,sans-serif;"><span style=3D"font-family: arial,helvetica,sans=
-serif;"></span><span style=3D"font-size: 10pt; font-family: "Courier =
New";"><span style=3D"font-family: arial,helvetica,sans-serif;">We are=
planning to make use of openssl crypto library in multithreaded environmen=
t.<br>
<br></span></span><span style=3D"font-size: 10pt; font-family: "Courie=
r New";"><span style=3D"font-family: arial,helvetica,sans-serif;">We c=
all OpenSSL_add_all_algorithms() before creating threads and</span></span><=
span style=3D"font-size: 10pt; font-family: "Courier New";"><span=
style=3D"font-family: arial,helvetica,sans-serif;"> will create BIO, EVP_K=
EY, SHA256 , SHA1 and RSA object in each thread and makes use of the follow=
ing functions:<br>
<br>SHA1_Init=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 BIO_new_mem_b=
uf=A0=A0=A0 =A0=A0=A0 EVP_PKEY_get1=A0=A0=A0 =A0=A0=A0 RSA_size<br>SHA1_Fin=
al=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0 BIO_free=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 EVP_PKEY_free=A0=A0=A0 =
=A0=A0=A0=A0 RSA_PKCS1_PADDING<br>SHA1_Update=A0=A0=A0 =A0=A0=A0=A0 BIO_wri=
te=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0 EVP_cleanup=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0 RSA_free<br>
SHA256_Init=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0 BIO_flush=A0=A0=A0 =A0=A0=A0 =A0=
=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0 RSA_verify<br>SHA256_Final=A0=A0=A0=A0=A0=A0=A0 BIO_new=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 <b=
r>SHA256_Update=A0=A0=A0 BIO_s_mem<br></span><br style=3D"font-family: aria=
l,helvetica,sans-serif;">
<span style=3D"font-family: arial,helvetica,sans-serif;"></span><span style=
=3D"font-family: arial,helvetica,sans-serif;">We</span> </span><span style=
=3D"font-family: arial,helvetica,sans-serif;">found in the openssl website =
that=A0 "</span><meta http-equiv=3D"Content-Type" content=3D"text/html=
; charset=3Dutf-8"><meta name=3D"ProgId" content=3D"Word.Document"><meta na=
me=3D"Generator" content=3D"Microsoft Word 9"><meta name=3D"Originator" con=
tent=3D"Microsoft Word 9"><link style=3D"font-family: arial,helvetica,sans-=
serif;" rel=3D"File-List" href=3D"file:///C:/DOCUME%7E1/dshanmug/LOCALS%7E1=
/Temp/msoclip1/01/clip_filelist.xml"><style>
<!--
/* Font Definitions */
@font-face
{font-family:"Arial Unicode MS";
panose-1:2 11 6 4 2 2 2 2 2 4;
mso-font-charset:128;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1 -369098753 63 0 4129023 0;}
@font-face
{font-family:"\@Arial Unicode MS";
panose-1:2 11 6 4 2 2 2 2 2 4;
mso-font-charset:128;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1 -369098753 63 0 4129023 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
h2
{margin-right:0in;
mso-margin-top-alt:auto;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
mso-outline-level:2;
font-size:18.0pt;
font-family:"Arial Unicode MS";
font-weight:bold;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
p
{margin-right:0in;
mso-margin-top-alt:auto;
mso-margin-bottom-alt:auto;
margin-left:0in;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Arial Unicode MS";}
code
{mso-ascii-font-family:"Arial Unicode MS";
mso-fareast-font-family:"Arial Unicode MS";
mso-hansi-font-family:"Arial Unicode MS";
mso-bidi-font-family:"Arial Unicode MS";}
pre
{margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 41=
2.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
font-size:10.0pt;
font-family:"Arial Unicode MS";}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style><span style=3D"font-size: 10pt; font-family: "Courier New"=
;;"><span style=3D"font-family: arial,helvetica,sans-serif;">OpenSSL
can safely be used in multi-threaded
applications provided that at least two callback functions are set,
locking_function and threadid_func." And from FAQ, its stated that
"Openssl is thread safe with limitations [ SSL connections may not be
used concurrently in many threads]" .<br><br>So, can someone let us kn=
ow that the functions mentioned above are MT safe without implementing the =
two callback functions.<br><br>Thanks in advance,<br>Deiva Shanmugam<br>
</span></span>
--001636e0ae4d6b05a9047324b732--
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openss...@openssl.org
Automated List Manager majo...@openssl.org
> Hi,
>
> We are planning to make use of openssl crypto library in multithreaded
> environment.
>
> We call OpenSSL_add_all_algorithms() before creating threads and will create
> BIO, EVP_KEY, SHA256 , SHA1 and RSA object in each thread and makes use of
> the following functions:
>
> SHA1_Init BIO_new_mem_buf EVP_PKEY_get1
> RSA_size
> SHA1_Final BIO_free EVP_PKEY_free
> RSA_PKCS1_PADDING
> SHA1_Update BIO_write EVP_cleanup
> RSA_free
> SHA256_Init BIO_flush
> RSA_verify
> SHA256_Final BIO_new
> SHA256_Update BIO_s_mem
>
> We found in the openssl website that "OpenSSL can safely be used in
> multi-threaded applications provided that at least two callback functions
> are set, locking_function and threadid_func." And from FAQ, its stated that
> "Openssl is thread safe with limitations [ SSL connections may not be used
> concurrently in many threads]" .
>
> So, can someone let us know that the functions mentioned above are MT safe
> without implementing the two callback functions.
>
Use of SHA* functions directly is not recommended, you should use EVP instead.
You need the callbacks for almost any usage because the locks are used to
maintain the error queue which is used by just about every subsection of
OpenSSL.
Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
Hi,
Thanks for the response, steve.
So, irrepective of creating the openssl object per thread or globally for
all threads, callback functions should be implemented to make the
application thread safe?
Thanks,
Deiva Shanmugam
--00c09f8de204d2a4fc047332ddad
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,<br><br>Thanks for the response, steve.<br><br>So, irrepective of creati=
ng the openssl object=A0 per thread or globally for all threads,=A0 callbac=
k functions should be implemented to make the application thread safe?<br><=
br>
Thanks,<br>Deiva Shanmugam<br><br><div class=3D"gmail_quote">On Wed, Sep 9,=
2009 at 8:35 PM, Dr. Stephen Henson <span dir=3D"ltr"><<a href=3D"mailt=
o:st...@openssl.org">st...@openssl.org</a>></span> wrote:<br><blockquote=
class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); =
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class=3D"h5">On Wed, Sep 09, 2009, deiva shanmugam wro=
te:<br>
<br>
> Hi,<br>
><br>
> We are planning to make use of openssl crypto library in multithreaded=
<br>
> environment.<br>
><br>
> We call OpenSSL_add_all_algorithms() before creating threads and will =
create<br>
> BIO, EVP_KEY, SHA256 , SHA1 and RSA object in each thread and makes us=
e of<br>
> the following functions:<br>
><br>
> SHA1_Init =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 BIO_new_mem_buf =A0 =A0 =A0 =
=A0EVP_PKEY_get1<br>
> RSA_size<br>
> SHA1_Final =A0 =A0 =A0 =A0 =A0 =A0 BIO_free =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 EVP_PKEY_free<br>
> =A0 =A0 =A0RSA_PKCS1_PADDING<br>
> SHA1_Update =A0 =A0 =A0 =A0 BIO_write =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 EVP_cleanup<br>
> =A0 =A0 =A0 RSA_free<br>
> SHA256_Init =A0 =A0 =A0 =A0 =A0 =A0BIO_flush<br>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 RSA_verify<br>
> SHA256_Final =A0 =A0 =A0 =A0BIO_new<br>
> SHA256_Update =A0 =A0BIO_s_mem<br>
><br>
> We found in the openssl website that =A0"OpenSSL can safely be us=
ed in<br>
> multi-threaded applications provided that at least two callback functi=
ons<br>
> are set, locking_function and threadid_func." And from FAQ, its s=
tated that<br>
> "Openssl is thread safe with limitations [ SSL connections may no=
t be used<br>
> concurrently in many threads]" .<br>
><br>
> So, can someone let us know that the functions mentioned above are MT =
safe<br>
> without implementing the two callback functions.<br>
><br>
<br>
</div></div>Use of SHA* functions directly is not recommended, you should u=
se EVP instead.<br>
<br>
You need the callbacks for almost any usage because the locks are used to<b=
r>
maintain the error queue which is used by just about every subsection of<br=
>
OpenSSL.<br>
<br>
Steve.<br>
<font color=3D"#888888">--<br>
Dr Stephen N. Henson. OpenSSL project core developer.<br>
Commercial tech support now available see: <a href=3D"http://www.openssl.or=
g" target=3D"_blank">http://www.openssl.org</a><br>
______________________________________________________________________<br>
OpenSSL Project =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 <a href=3D"http://www.openssl.org" target=3D"_blank">http://www.openss=
l.org</a><br>
User Support Mailing List =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<a href=3D=
"mailto:openss...@openssl.org">openss...@openssl.org</a><br>
Automated List Manager =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
<a href=3D"mailto:majo...@openssl.org">majo...@openssl.org</a><br>
</font></blockquote></div><br>
--00c09f8de204d2a4fc047332ddad--
> Hi,
>
> Thanks for the response, steve.
>
> So, irrepective of creating the openssl object per thread or globally for
> all threads, callback functions should be implemented to make the
> application thread safe?
>
Yes: the error queue requires it and just about every part of OpenSSL uses the
error queue.
I am always very concerned when I read questions like this. The
documentation says to implement the callbacks. Therefore you must
do so.
I have often be called in to sort bugs out which have turned out to
be caused by programmers taking shortcuts. It's just not worth
it.
Mark.
No offense, but that's what the mailing list is for. Granted, a
search might have yielded the answer as well... but if anything, the
question should make you feel good because it's one mess you won't be
cleaning up.
Ben
No offense, but I disagree. This list is for questions specific to OpenSSL
programming, not for questions like "should I do what the documentation say=
s".
Asking such a question shows a fundamental misunderstanding on correct prog=
ramming
techniques. Unfortunately this is all too common IME.
Mark
It's OK, you can be wrong. Whether you like it or not, that question
was about OpenSSL programming. The documentation for this project is
not always up to date on these and other issues and it's reasonable to
ask for clarification or confirmation.
Ben