<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Matt,<br>
<br>
I'm able resolve for AES and DES errors, I replaced with function but few parameter are filled with NULL, please suggest its correct way of doing <br>
<br>
The below is the actual source code I'm trying to change<br>
<a href="https://github.com/digsrc/wpa_supplicant/blob/master/src/crypto/crypto_openssl.c" id="LPNoLPOWALinkPreview">https://github.com/digsrc/wpa_supplicant/blob/master/src/crypto/crypto_openssl.c</a><br>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1"></div>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
trying to upgrade this function in the above file <span style="color:rgb(130, 80, 223);font-family:ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;font-size:12px;background-color:rgb(255, 255, 255);display:inline !important">des_encrypt <span style="background-color:rgb(255, 255, 255);display:inline !important">aes_wrap <span style="background-color:rgb(255, 255, 255);display:inline !important">aes_unwrap</span></span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style=""><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><font face="Calibri, Arial, Helvetica, sans-serif">I
 called below function for both DES AES<br>
<br>
In <span style="color:rgb(130, 80, 223);font-family:ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;font-size:12px;background-color:rgb(255, 255, 255);display:inline !important">
des_encrypt</span>:I changed below code<br>
</font></span></span></span></div>
<div style=""><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><font face="Calibri, Arial, Helvetica, sans-serif"><br>
</font></span></span></span></div>
<div style=""><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><font face="Calibri, Arial, Helvetica, sans-serif">int
 clen = 16;<br>
evp_encrypt_wrapper((unsigned char *)clear, <span style="color: rgb(200, 38, 19); background-color: rgb(255, 255, 0);">
clen</span>, (unsigned char *)pkey, <span style="color: rgb(200, 38, 19); background-color: rgb(255, 255, 0);">
NULL</span>, (unsigned char *)cypher, EVP_des_ecb());<br>
<br>
In <span style="color:rgb(130, 80, 223);font-family:ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;font-size:12px;background-color:rgb(255, 255, 255);display:inline !important">
aes_wrap</span>:<span style="font-size:14px;background-color:rgb(255, 255, 255);display:inline !important">I changed below code</span></font></span></span></span></div>
<div style=""><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><font face="Calibri, Arial, Helvetica, sans-serif"><br>
</font></span></span></span></div>
<div style=""><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><font face="Calibri, Arial, Helvetica, sans-serif">evp_encrypt_wrapper((unsigned
 char *)plain, <span style="background-color: rgb(255, 255, 0);">n * 8</span>, (unsigned char *)kek,
<span style="background-color: rgb(255, 255, 0);">NULL</span>, (unsigned char *)cipher, aes_wrap_get_evp_cipher(kek_len << 3));<br>
</font></span></span></span></div>
<div style=""><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="background-color: rgb(255, 255, 255); display: inline !important;"><font face="Calibri, Arial, Helvetica, sans-serif"><br>
Please suggest how do I manage <span style="color:rgb(130, 80, 223);font-family:ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;font-size:12px;background-color:rgb(255, 255, 255);display:inline !important">inputLen
</span><span style="background-color: rgb(255, 255, 255); display: inline !important;"><span style="font-size: 14px;">and</span><font color="#8250df" face="ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace"><span style="font-size: 12px;"> iv </span></font><span style="color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255); display: inline !important;">parameter</span></span><br>
<br>
</font></span></span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color:rgb(130, 80, 223);font-family:ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;font-size:12px;background-color:rgb(255, 255, 255);display:inline !important"><span style="background-color:rgb(255, 255, 255);display:inline !important"><span style="background-color:rgb(255, 255, 255);display:inline !important">int
 evp_encrypt_wrapper(unsigned char *input, unsigned int inputLen, unsigned char *key, unsigned char *iv, unsigned char *output, const EVP_CIPHER *type)
<div>{</div>
<div>    EVP_CIPHER_CTX *ctx = NULL;</div>
<div>    int len = 0;</div>
<div>    int outputLen = 0;</div>
<div><br>
</div>
<div>    do</div>
<div>    {</div>
<div>        /* Create and initialize the context */</div>
<div>        if(!(ctx = EVP_CIPHER_CTX_new()))</div>
<div>        {</div>
<div>            break;</div>
<div>        }</div>
<div><br>
</div>
<div>        /*</div>
<div>         * Initialize the encryption operation.</div>
<div>         */</div>
<div>        if(1 != EVP_EncryptInit_ex2(ctx, type, key, iv, NULL))</div>
<div>        {</div>
<div>            break;</div>
<div>        }</div>
<div><br>
</div>
<div>        /*</div>
<div>         * Provide the message to be encrypted, and obtain the encrypted output.</div>
<div>         * EVP_EncryptUpdate can be called multiple times if necessary</div>
<div>         */</div>
<div>        if(1 != EVP_EncryptUpdate(ctx, output, &outputLen, input, inputLen))</div>
<div>        {</div>
<div>            break;</div>
<div>        }</div>
<div><br>
</div>
<div>        /*</div>
<div>         * Finalize the encryption. Further output bytes may be written at</div>
<div>         * this stage.</div>
<div>         */</div>
<div>        if(1 != EVP_EncryptFinal_ex(ctx, output + outputLen, &len))</div>
<div>        { </div>
<div>            break;</div>
<div>        }</div>
<div><br>
</div>
<div>        outputLen += len;</div>
<div>    }while(false);</div>
<div><br>
</div>
<div>    /* Clean up */</div>
<div>    if(ctx) </div>
<div>        EVP_CIPHER_CTX_free(ctx);</div>
<div><br>
</div>
<div>    return outputLen;</div>
}<br>
</span></span></span></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Matt Caswell <matt@openssl.org><br>
<b>Sent:</b> Monday, December 6, 2021 7:19 PM<br>
<b>To:</b> Shivakumar Poojari <Shivakumar.Poojari@rbbn.com>; openssl-users@openssl.org <openssl-users@openssl.org><br>
<b>Cc:</b> Amballi, Kishor <kamballi@rbbn.com>; Bhattacharjee, Debapriyo (c) <dbhattacharjee@rbbn.com>; Kumar Mishra, Sanjeev <Sanjeev.Kumar-Mishra@rbbn.com><br>
<b>Subject:</b> [EXTERNAL] Re: Need Replacement for Deprecated function</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
<br>
On 06/12/2021 12:26, Shivakumar Poojari wrote:<br>
> Hi All,<br>
> <br>
> We are upgrading our code to openssl 3.0.<br>
> <br>
> Need Replacement for below Deprecated function.<br>
> <br>
> DSE:<br>
> DES_set_key();<br>
> DES_ecb_encrypt();<br>
> <br>
> AES:<br>
> AES_set_encrypt_key();<br>
> AES_set_decrypt_key();<br>
> AES_wrap_key();<br>
> AES_unwrap_key();--- perivously i upgraded AES function with EVP related <br>
> function but wrap/unwraper is something new.<br>
> <br>
<br>
All the DES and AES functions are just replaced by the EVP functions. <br>
 From the migration guide:<br>
<br>
"Low-level encryption functions such as AES_encrypt(3) and <br>
AES_decrypt(3) have been informally discouraged from use for a long <br>
time. Applications should instead use the high level EVP APIs <br>
EVP_EncryptInit_ex(3), EVP_EncryptUpdate(3), and EVP_EncryptFinal_ex(3) <br>
or EVP_DecryptInit_ex(3), EVP_DecryptUpdate(3) and EVP_DecryptFinal_ex(3)."<br>
<br>
<br>
The wrap/unwrap functionality is the same but you use the "wrap" ciphers:<br>
<br>
<a href="https://clicktime.symantec.com/3YBoRtRxfsEzqu7jB1kQRdi6H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman7%2FEVP_CIPHER-AES.html">https://clicktime.symantec.com/3YBoRtRxfsEzqu7jB1kQRdi6H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman7%2FEVP_CIPHER-AES.html</a><br>
<br>
The following "wrap" ciphers are supported:<br>
<br>
"AES-128-WRAP", "AES-192-WRAP", "AES-256-WRAP", "AES-128-WRAP-PAD", <br>
"AES-192-WRAP-PAD", "AES-256-WRAP-PAD", "AES-128-WRAP-INV", <br>
"AES-192-WRAP-INV", "AES-256-WRAP-INV", "AES-128-WRAP-PAD-INV", <br>
"AES-192-WRAP-PAD-INV" and "AES-256-WRAP-PAD-INV"<br>
<br>
<br>
> DH:<br>
> DH_new();<br>
> DH_set0_pqg();<br>
> DH_generate_key();<br>
> DH_get0_key();<br>
> DH_free();<br>
> DH_set0_key();<br>
> DH_size();<br>
> DH_compute_key();<br>
<br>
All the DH functions are replaced by the EVP key exchange functionality.<br>
<br>
In particular see this page:<br>
<br>
<a href="https://clicktime.symantec.com/3QwQe8oMQp2ycuXi1g6n3276H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman7%2FEVP_KEYEXCH-DH.html">https://clicktime.symantec.com/3QwQe8oMQp2ycuXi1g6n3276H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman7%2FEVP_KEYEXCH-DH.html</a><br>
<br>
and<br>
<br>
<a href="https://clicktime.symantec.com/3HxeDKVhVDjB4zstTvgpdpJ6H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman3%2FEVP_PKEY_derive.html">https://clicktime.symantec.com/3HxeDKVhVDjB4zstTvgpdpJ6H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman3%2FEVP_PKEY_derive.html</a><br>
<br>
<br>
> <br>
> HMAC:<br>
> HMAC_CTX_new();compiler suggestion EVP_MAC_CTX_new();<br>
> HMAC_Init_ex();<br>
> HMAC_CTX_free();compiler suggestion EVP_MAC_CTX_free();<br>
> HMAC_Update();compiler suggestion EVP_MAC_update();<br>
> HMAC_Final();compiler suggestion EVP_MAC_final();<br>
<br>
Use the EVP_MAC functions. In particular see:<br>
<br>
<a href="https://clicktime.symantec.com/3E4wr8pyUbGoHvQV24ZcU176H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman3%2FEVP_MAC.html">https://clicktime.symantec.com/3E4wr8pyUbGoHvQV24ZcU176H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman3%2FEVP_MAC.html</a><br>
<br>
and<br>
<br>
<a href="https://clicktime.symantec.com/3Jt5BYvGZ2j2MurnueNjzss6H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman7%2FEVP_MAC-HMAC.html">https://clicktime.symantec.com/3Jt5BYvGZ2j2MurnueNjzss6H2?u=https%3A%2F%2Fwww.openssl.org%2Fdocs%2Fman3.0%2Fman7%2FEVP_MAC-HMAC.html</a><br>
<br>
Matt<br>
<br>
<br>
> <br>
> I'm not able to find proper replacement, Please help me out<br>
> <br>
> Thanks,<br>
> Shiva Kumar<br>
> <br>
> Notice: This e-mail together with any attachments may contain <br>
> information of Ribbon Communications Inc. and its Affiliates that is <br>
> confidential and/or proprietary for the sole use of the intended <br>
> recipient. Any review, disclosure, reliance or distribution by others or <br>
> forwarding without express permission is strictly prohibited. If you are <br>
> not the intended recipient, please notify the sender immediately and <br>
> then delete all copies, including any attachments.<br>
</div>
</span></font></div>
<br clear="both">
Notice: This e-mail together with any attachments may contain information of Ribbon Communications Inc. and its Affiliates that is confidential and/or proprietary for the sole use of the intended recipient. Any review, disclosure, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and then delete all copies, including any attachments.<BR>
</body>
</html>