<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=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<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:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:"var\(--ff-mono\)";}
@font-face
{font-family:inherit;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
span.EmailStyle23
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
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="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Bala,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-IN">To fill the below struct do I need to extract Publickey exponent , Private key exponent etc.<o:p></o:p></span></p>
<p class="MsoNormal">[Arek] – yes, you need to convert keys into big-endian unsigned integer.<o:p></o:p></p>
<p class="MsoNormal">In the file “test_cryptodev_rsa_test_vectors.h” there are few examples.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Arek<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Balakrishnan K <Balakrishnan.K1@tatacommunications.com>
<br>
<b>Sent:</b> Wednesday, May 25, 2022 12:08 PM<br>
<b>To:</b> Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>; users@dpdk.org<br>
<b>Subject:</b> RE: how to use crypto openssl PMD for asymmetric encryption and decryption<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-IN">Hi Arek,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> I have public and private key with me which can be used for encryption/decryption.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">To fill the below struct do I need to extract Publickey exponent , Private key exponent etc.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">The reason why I am asking is, in openssl for encryption we will use key directly with the exposed API.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">Example :<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span lang="EN-IN" style="font-size:10.0pt;font-family:inherit;border:none windowtext 1.0pt;padding:0in">RSA_private_encrypt(strlen(msg), (unsigned char *)msg, encrypted, rsa, RSA_PKCS1_PADDING);</span><span lang="EN-IN" style="font-size:10.0pt;font-family:"var\(--ff-mono\)""><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">Here in dpdk the rsa struct looks different .<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">Thanks in advance.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">struct rte_crypto_rsa_xform {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">rte_crypto_param n;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> /**< n - Modulus<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> * Modulus data of RSA operation in Octet-string network<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> * byte order format.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> rte_crypto_param e;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> /**< e - Public key exponent<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> * Public key exponent used for RSA public key operations in Octet-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> * string network byte order format.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> enum rte_crypto_rsa_priv_key_type key_type;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> __extension__<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> union {<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> rte_crypto_param d;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> /**< d - Private key exponent<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> * Private key exponent used for RSA<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> * private key operations in<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> * Octet-string network byte order format.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> struct rte_crypto_rsa_priv_key_qt qt;<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> /**< qt - Private key in quintuple format */<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"> };<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">};<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">Bala <o:p></o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Balakrishnan K <br>
<b>Sent:</b> 24 May 2022 17:42<br>
<b>To:</b> Kusztal, ArkadiuszX <<a href="mailto:arkadiuszx.kusztal@intel.com">arkadiuszx.kusztal@intel.com</a>>;
<a href="mailto:users@dpdk.org">users@dpdk.org</a><br>
<b>Subject:</b> RE: how to use crypto openssl PMD for asymmetric encryption and decryption<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-IN">Hi </span>Arek,<o:p></o:p></p>
<p class="MsoNormal"> Thanks for the detailed explanation.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Bala <o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Kusztal, ArkadiuszX <<a href="mailto:arkadiuszx.kusztal@intel.com">arkadiuszx.kusztal@intel.com</a>>
<br>
<b>Sent:</b> 24 May 2022 14:44<br>
<b>To:</b> Balakrishnan K <<a href="mailto:Balakrishnan.K1@tatacommunications.com">Balakrishnan.K1@tatacommunications.com</a>>;
<a href="mailto:users@dpdk.org">users@dpdk.org</a><br>
<b>Subject:</b> RE: how to use crypto openssl PMD for asymmetric encryption and decryption<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<pre>I should use <o:p></o:p></pre>
<pre>debug_hexdump(stdout, "encrypted message", asym_op->rsa.cipher.data,<o:p></o:p></pre>
<pre> asym_op->rsa.cipher.length);<o:p></o:p></pre>
<pre>to check the encrypted message for the input given?<o:p></o:p></pre>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Yes, currently it works this way. The same way output for decryption will be placed in asym_op->rsa.message.data and input in asym_op->rsa.cipher.data.<o:p></o:p></p>
<p class="MsoNormal">More explanations can be found in rte_crypto_asym.h file<o:p></o:p></p>
<p class="MsoNormal"><a href="https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoc.dpdk.org%2Fapi%2Fstructrte__crypto__rsa__op__param.html&data=05%7C01%7CBalakrishnan.K1%40tatacommunications.com%7Ce6515989e89645c02e1c08da3d65bae8%7C202104622c5e4ec8b3e20be950f292ca%7C0%7C0%7C637889804388693411%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ryyU80ir4srb%2FgVCbhJGjdN6klL5F1ELfney9NjhEs0%3D&reserved=0">https://doc.dpdk.org/api/structrte__crypto__rsa__op__param.html</a>.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Balakrishnan K <<a href="mailto:Balakrishnan.K1@tatacommunications.com">Balakrishnan.K1@tatacommunications.com</a>>
<br>
<b>Sent:</b> Tuesday, May 24, 2022 7:24 AM<br>
<b>To:</b> Kusztal, ArkadiuszX <<a href="mailto:arkadiuszx.kusztal@intel.com">arkadiuszx.kusztal@intel.com</a>>;
<a href="mailto:users@dpdk.org">users@dpdk.org</a><br>
<b>Subject:</b> RE: how to use crypto openssl PMD for asymmetric encryption and decryption<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-IN">Hi </span>Arek,<o:p></o:p></p>
<p class="MsoNormal"> Thanks for quick response.<o:p></o:p></p>
<p class="MsoNormal">I am using resulted output vector to verify the encrypted message.<o:p></o:p></p>
<pre><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">I thought the encrypted data will be in the asym_op->rsa.message.data after rte_cryptodev_enqueue_burst and rte_cryptodev_enqueue_burst call with operation type RTE_CRYPTO_ASYM_OP_ENCRYPT.<o:p></o:p></span></pre>
<pre><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">So ,I checked the hex_dump of asym_op->rsa.message.data.<o:p></o:p></span></pre>
<pre><o:p> </o:p></pre>
<pre>Code snippet:<o:p></o:p></pre>
<pre>asym_op = result_op->asym;<o:p></o:p></pre>
<pre>debug_hexdump(stdout, "encrypted message", asym_op->rsa.message.data,<o:p></o:p></pre>
<pre> asym_op->rsa.message.length);<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre><span lang="EN-IN" style="font-size:9.0pt;font-family:Consolas;color:#404040">Encrypted data will be placed in </span>asym_op->rsa.cipher.data after crypto operation is my understanding is correct ?<o:p></o:p></pre>
<pre>I should use <o:p></o:p></pre>
<pre>debug_hexdump(stdout, "encrypted message", asym_op->rsa.cipher.data,<o:p></o:p></pre>
<pre> asym_op->rsa.cipher.length);<o:p></o:p></pre>
<pre>to check the encrypted message for the input given?<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Regards,<o:p></o:p></pre>
<pre>Bala <o:p></o:p></pre>
<pre><span lang="EN-IN" style="font-size:9.0pt;font-family:Consolas;color:#404040"><o:p> </o:p></span></pre>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Kusztal, ArkadiuszX <<a href="mailto:arkadiuszx.kusztal@intel.com">arkadiuszx.kusztal@intel.com</a>>
<br>
<b>Sent:</b> 23 May 2022 18:15<br>
<b>To:</b> Balakrishnan K <<a href="mailto:Balakrishnan.K1@tatacommunications.com">Balakrishnan.K1@tatacommunications.com</a>>;
<a href="mailto:users@dpdk.org">users@dpdk.org</a><br>
<b>Subject:</b> RE: how to use crypto openssl PMD for asymmetric encryption and decryption<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-IN"><o:p> </o:p></span></p>
<div style="border:dotted #003333 1.0pt;padding:10.0pt 10.0pt 10.0pt 10.0pt">
<p style="background:#CFD3D6"><b><span style="font-size:7.5pt;color:red">CAUTION</span></b><span style="font-size:7.5pt;color:red">: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender
and know the content is safe. <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal">Hi Bala,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Ciphertext will be written into asym_op->rsa.cipher.data (not message.data) by the PMD, here you are using same address for both hex dumps.<o:p></o:p></p>
<p class="MsoNormal">Although there is a bug in debug_hexdump in this function which may cause this confusion.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Plus, the test you are referring is PWCT test (Pairwise conditional test) -> it will encrypt, then decrypt.<o:p></o:p></p>
<p class="MsoNormal">Please take a look into this comment in queue_ops_rsa_enc_dec function:<o:p></o:p></p>
<p class="MsoNormal">/* Use the resulted output as decryption Input vector*<o:p></o:p></p>
<p class="MsoNormal">So above this line there is an encryption part.<o:p></o:p></p>
<p class="MsoNormal">Below is decryption. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Arek<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Balakrishnan K <<span lang="EN-IN"><a href="mailto:Balakrishnan.K1@tatacommunications.com"><span lang="EN-US">Balakrishnan.K1@tatacommunications.com</span></a></span>>
<br>
<b>Sent:</b> Monday, May 23, 2022 1:33 PM<br>
<b>To:</b> <span lang="EN-IN"><a href="mailto:users@dpdk.org"><span lang="EN-US">users@dpdk.org</span></a></span><br>
<b>Subject:</b> how to use crypto openssl PMD for asymmetric encryption and decryption<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi All,<o:p></o:p></p>
<p class="MsoNormal"> I am new to dpdk. Planning to use openssl crypto PMD for encrypting/decrypting the packets.<o:p></o:p></p>
<p class="MsoNormal">Couldn’t find much documents on openssl PMD for <b>asymmetric</b> encryption/decryption.<o:p></o:p></p>
<p class="MsoNormal">Any one please point me in the right document.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have tried to run the test cases wrote for asymmetric crypto using openssl virtual PMD.<o:p></o:p></p>
<p class="MsoNormal">But the output of particular test case is same after the encryption done.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">File : app/test/test_cryptodev_asym.c<o:p></o:p></p>
<p class="MsoNormal">Test executable: ./app/test/dpdk-test<o:p></o:p></p>
<p class="MsoNormal">Test case : test_rsa_enc_dec<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><b>Input given to encryption: <o:p></o:p></b></p>
<p class="MsoNormal">message at [0x1894e60], len=20<o:p></o:p></p>
<p class="MsoNormal">00000000: F8 BA 1A 55 D0 2F 85 AE 96 7B B6 2F B6 CD A8 EB | ...U./...{./....<o:p></o:p></p>
<p class="MsoNormal">00000010: 7E 78 A0 50 | ~x.P<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b>After processing the output also looks like same :<o:p></o:p></b></p>
<p class="MsoNormal">encrypted message exist at [0x1894e60], len=20<o:p></o:p></p>
<p class="MsoNormal">00000000: F8 BA 1A 55 D0 2F 85 AE 96 7B B6 2F B6 CD A8 EB | ...U./...{./....<o:p></o:p></p>
<p class="MsoNormal">00000010: 7E 78 A0 50<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Bala <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>