<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Texte de bulles Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.TextedebullesCar
        {mso-style-name:"Texte de bulles Car";
        mso-style-priority:99;
        mso-style-link:"Texte de bulles";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        font-variant:normal !important;
        color:windowtext;
        text-transform:none;
        font-weight:normal;
        font-style:normal;}
p.BalloonText, li.BalloonText, div.BalloonText
        {mso-style-name:"Balloon Text";
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hi Phil,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>> "… or is the encrypted length put into the encrypted information so an EVP call is available to retrieve it?"<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>It is NOT the case.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>May not be the answer you expected :<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>The encrypted length is length of clear text + size of 1 cipher block  if padding is enabled.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><a href="https://www.openssl.org/docs/crypto/EVP_EncryptInit.html">https://www.openssl.org/docs/crypto/EVP_EncryptInit.html</a><o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>> "is calling OpenSSL_add_all_algorithms (or OpenSSL_add_all_ciphers) and the corresponding EVP_cleanup call necessary for each encrypt and  decrypt ?"<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>NO, and It should NOT, especially in multi-threaded applications  :<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>"A typical application will call OpenSSL_add_all_algorithms() initially and EVP_cleanup() before exiting."<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><a href="https://www.openssl.org/docs/crypto/OpenSSL_add_all_algorithms.html">https://www.openssl.org/docs/crypto/OpenSSL_add_all_algorithms.html</a><o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Also : <a href="https://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption">https://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption</a><o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Hope this helps,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Michel.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De :</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> openssl-users [mailto:openssl-users-bounces@openssl.org] <b>De la part de</b> Philip Bellino<br><b>Envoyé :</b> jeudi 26 mars 2015 15:53<br><b>À :</b> openssl-users@openssl.org<br><b>Objet :</b> [openssl-users] Encryption length, OpenSSL_add_all_algorithms, and OpenSSL_add_all_ciphers questions<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>I am using OpenSSL-1.0.2a EVP routines to encrypt and decrypt passwords<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>with cipher des_ede3_cbc as follows:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>encrypt routines:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_CIPHER_CTX_init<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_EncryptInit_ex<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_EncryptUpdate<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_EncryptFinal_ex<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_CIPHER_CTX_cleanup<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>decrypt routines:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_CIPHER_CTX_init<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_DecryptInit_ex<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_DecryptUpdate<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_DecryptFinal_ex<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>EVP_CIPHER_CTX_cleanup<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>similar to examples found here:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>http://www.openssl.org/docs/crypto/EVP_CIPHER_CTX_init.html#EXAMPLES<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Passwords are encrypted and stored when created, and decrypted<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>at a later time to compare against the password<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>given upon login. None of the examples show determining the length<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>of the encrypted information via an EVP call in order to pass<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>that information to the decryption routines. Should I assume it<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>is incumbent upon the coder to store the encrypted length when<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>storing the encrypted password, for retrieval later? Or is the encrypted<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>length put into the encrypted information so an EVP call is available to<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>retrieve it? I believe from all the information I see that it is the former.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Please confirm this for me.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Also, is calling OpenSSL_add_all_algorithms (or OpenSSL_add_all_ciphers)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>and the corresponding EVP_cleanup call necessary for each encrypt and<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>decrypt? My encryption and decryption seem to be working without calling<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>those routines but after seeing them used (for examples in test/evp_test.c), I don't understand why.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Any insight that can be shared would be most appreciated.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Thank you.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:#7F7F7F'>Phil Bellino<o:p></o:p></span></b></p><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;color:#7F7F7F'>Principal Software Engineer</span></b><b><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:#7F7F7F'> </span></b><b><span lang=EN-US style='font-size:10.0pt;color:#5A4099'>| </span></b><b><span lang=EN-US style='font-size:10.0pt;color:#7F7F7F'>MRV Communications Inc.<o:p></o:p></span></b></p><p class=MsoNormal><span lang=EN-US style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:#7F7F7F'>300 Apollo Drive </span><b><span lang=EN-US style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:#8064A2'>|  </span></b><span lang=EN-US style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:#7F7F7F'>Chelmsford, MA 01824 <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:#7F7F7F'>Phone: 978-674-6870</span><span lang=EN-US style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:teal'>  </span><b><span lang=EN-US style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:#8064A2'>|   </span></b><span lang=EN-US style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:#7F7F7F'>Fax: 978-674-6799<o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt'><span lang=EN-US><a href="www.mrv.com"><span style='font-size:9.0pt;color:#7F7F7F'>www.mrv.com</span></a></span><span lang=EN-US style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:#7F7F7F'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt'><img border=0 width=188 height=25 id="Picture_x0020_3" src="cid:image001.png@01D0680D.BC4115F0" alt=MRV-email><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;font-family:"Times New Roman","serif"'><a href="http://www.mrv.com/landing/video-datasheet-mrvs-optidriver-platform"><span style='border:solid windowtext 1.0pt;padding:0cm;text-decoration:none'><img border=0 width=100 height=100 id="_x0000_i1026" src="cid:~WRD000.jpg" alt="Image supprimée par l'expéditeur. E-Banner"></span></a><br> <o:p></o:p></span></p><div><p style='line-height:8.0pt;background:white'><span lang=EN-US style='font-size:8.0pt;font-family:"Arial","sans-serif";color:#B8B9C8'>The contents of this message, together with any attachments, are intended only for the use of the person(s) to whom they are addressed and may contain confidential and/or privileged information. If you are not the intended recipient, immediately advise the sender, delete this message and any attachments and note that any distribution, or copying of this message, or any attachment, is prohibited.<o:p></o:p></span></p></div></div></body></html>