<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RSA Encryption using C in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/RSA-Encryption-using-C/m-p/868901#M8647</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am trying to create a function for a dll that takes in a char* to a string and encrypts the string. I am not sure why I get a ippStscontextMatchErr when I send in my context to the ippsRSASetkey function. I am following the steps stated in the user manual for cryptography:&lt;BR /&gt;&lt;BR /&gt;"The application code for conducting a typical RSA encryption must perform the following&lt;BR /&gt;sequence of operations, starting with building of a crypto system:&lt;BR /&gt;&lt;BR /&gt;1. Call the function RSAGetSize to get the size required to configure IppsRSAState&lt;BR /&gt;context.&lt;BR /&gt;&lt;BR /&gt;2. Ensure that the required memory space is properly allocated. With the allocated memory,&lt;BR /&gt;call the RSAInit function to initialize the context for the RSA encryption.&lt;BR /&gt;&lt;BR /&gt;3. Keep calling the RSASetKey to set up RSA public key (n, e).&lt;BR /&gt;&lt;BR /&gt;4. Invoke the RSAEncrypt function with the established RSA public key to encode the&lt;BR /&gt;plaintext into the respective ciphertext.&lt;BR /&gt;&lt;BR /&gt;5. Free the memory allocated for the IppsRSAState context by calling the operating&lt;BR /&gt;system memory free service function."&lt;BR /&gt;&lt;BR /&gt;This is what I did prior to the error:&lt;BR /&gt;&lt;BR /&gt;void __declspec(dllexport) RSAEncyrption(char* myString, unsigned char* encrypted)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;int pSize, bitsN, bitsP;&lt;BR /&gt;IppsRSAState *pCtx;&lt;BR /&gt;IppsBigNumState *pY, *pBN, *pE;&lt;BR /&gt;&lt;BR /&gt;bitsN = 128;&lt;BR /&gt;bitsP = 64;&lt;BR /&gt;&lt;BR /&gt;//allocate space for cyphertext (not sure if its&lt;BR /&gt;//the same way as the AES IPP&lt;BR /&gt;pY = (IppsBigNumState *)malloc(strlen(myString))&lt;BR /&gt;&lt;BR /&gt;//get the size required to configure IppsRSAState context&lt;BR /&gt;ippsRSAGetSize(bitsN, bitsP, IppRSApublic, &amp;amp;pSize);&lt;BR /&gt;&lt;BR /&gt;//allocate memory&lt;BR /&gt;pCtx = (IppsRSAState *)malloc(sizeof(Ipp8u)*pSize);&lt;BR /&gt;&lt;BR /&gt;//init key&lt;BR /&gt;ippsRSAInit(bitsN, bitsP, IppRSApublic, pCtx);&lt;BR /&gt;&lt;BR /&gt;pBN = (IppsBigNumState *)malloc(sizeof(Ipp8u)*pSize);&lt;BR /&gt;pE = (IppsBigNumState *)malloc(sizeof(Ipp8u)*pSize);&lt;BR /&gt;&lt;BR /&gt;ippsRSASetKey(pBN, IppRSAkeyN, pCtx);&lt;BR /&gt;ippsRSASetKey(pE, IppRSAkeyE, pCtx);&lt;BR /&gt;&lt;BR /&gt;//not sure if I can just pass in a char* like the AES IPP &lt;BR /&gt;ippsRSAEncrypt((IppsBigNumState*)myString, pY, pCtx);&lt;BR /&gt;&lt;BR /&gt;memcpy(encrypted, pY, strlen(myString));&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So all in all, the call to ippsRSASetkey throws a return value of -17 which says that the context parameter does not match the operation. I am confused as I thought the ippsRSAinit function takes care of the context (pCtx).&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated. Thanks.&lt;BR /&gt;</description>
    <pubDate>Tue, 31 Mar 2009 21:10:28 GMT</pubDate>
    <dc:creator>bqduong</dc:creator>
    <dc:date>2009-03-31T21:10:28Z</dc:date>
    <item>
      <title>RSA Encryption using C</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/RSA-Encryption-using-C/m-p/868901#M8647</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am trying to create a function for a dll that takes in a char* to a string and encrypts the string. I am not sure why I get a ippStscontextMatchErr when I send in my context to the ippsRSASetkey function. I am following the steps stated in the user manual for cryptography:&lt;BR /&gt;&lt;BR /&gt;"The application code for conducting a typical RSA encryption must perform the following&lt;BR /&gt;sequence of operations, starting with building of a crypto system:&lt;BR /&gt;&lt;BR /&gt;1. Call the function RSAGetSize to get the size required to configure IppsRSAState&lt;BR /&gt;context.&lt;BR /&gt;&lt;BR /&gt;2. Ensure that the required memory space is properly allocated. With the allocated memory,&lt;BR /&gt;call the RSAInit function to initialize the context for the RSA encryption.&lt;BR /&gt;&lt;BR /&gt;3. Keep calling the RSASetKey to set up RSA public key (n, e).&lt;BR /&gt;&lt;BR /&gt;4. Invoke the RSAEncrypt function with the established RSA public key to encode the&lt;BR /&gt;plaintext into the respective ciphertext.&lt;BR /&gt;&lt;BR /&gt;5. Free the memory allocated for the IppsRSAState context by calling the operating&lt;BR /&gt;system memory free service function."&lt;BR /&gt;&lt;BR /&gt;This is what I did prior to the error:&lt;BR /&gt;&lt;BR /&gt;void __declspec(dllexport) RSAEncyrption(char* myString, unsigned char* encrypted)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;int pSize, bitsN, bitsP;&lt;BR /&gt;IppsRSAState *pCtx;&lt;BR /&gt;IppsBigNumState *pY, *pBN, *pE;&lt;BR /&gt;&lt;BR /&gt;bitsN = 128;&lt;BR /&gt;bitsP = 64;&lt;BR /&gt;&lt;BR /&gt;//allocate space for cyphertext (not sure if its&lt;BR /&gt;//the same way as the AES IPP&lt;BR /&gt;pY = (IppsBigNumState *)malloc(strlen(myString))&lt;BR /&gt;&lt;BR /&gt;//get the size required to configure IppsRSAState context&lt;BR /&gt;ippsRSAGetSize(bitsN, bitsP, IppRSApublic, &amp;amp;pSize);&lt;BR /&gt;&lt;BR /&gt;//allocate memory&lt;BR /&gt;pCtx = (IppsRSAState *)malloc(sizeof(Ipp8u)*pSize);&lt;BR /&gt;&lt;BR /&gt;//init key&lt;BR /&gt;ippsRSAInit(bitsN, bitsP, IppRSApublic, pCtx);&lt;BR /&gt;&lt;BR /&gt;pBN = (IppsBigNumState *)malloc(sizeof(Ipp8u)*pSize);&lt;BR /&gt;pE = (IppsBigNumState *)malloc(sizeof(Ipp8u)*pSize);&lt;BR /&gt;&lt;BR /&gt;ippsRSASetKey(pBN, IppRSAkeyN, pCtx);&lt;BR /&gt;ippsRSASetKey(pE, IppRSAkeyE, pCtx);&lt;BR /&gt;&lt;BR /&gt;//not sure if I can just pass in a char* like the AES IPP &lt;BR /&gt;ippsRSAEncrypt((IppsBigNumState*)myString, pY, pCtx);&lt;BR /&gt;&lt;BR /&gt;memcpy(encrypted, pY, strlen(myString));&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So all in all, the call to ippsRSASetkey throws a return value of -17 which says that the context parameter does not match the operation. I am confused as I thought the ippsRSAinit function takes care of the context (pCtx).&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated. Thanks.&lt;BR /&gt;</description>
      <pubDate>Tue, 31 Mar 2009 21:10:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/RSA-Encryption-using-C/m-p/868901#M8647</guid>
      <dc:creator>bqduong</dc:creator>
      <dc:date>2009-03-31T21:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: RSA Encryption using C</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/RSA-Encryption-using-C/m-p/868902#M8648</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;the main problem of code snippet you provide is that it does not use ippsBigNumber data type (just casting of memory buffer to ippsBigNumber type is not enoughand is notcorrect). Please refer to IPP documentation for more details.&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;ippsRSAEncrypt((IppsBigNumState*)myString, pY, pCtx); &lt;STRONG&gt;&lt;EM&gt;[gres] &lt;/EM&gt;&lt;/STRONG&gt;Both "myString" and "Y" are not ippsBigNumState. That is why "ippStscontextMatchErr" is detected&lt;/P&gt;
&lt;BR /&gt;Regards,&lt;BR /&gt; Vladimir</description>
      <pubDate>Mon, 06 Apr 2009 15:20:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/RSA-Encryption-using-C/m-p/868902#M8648</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2009-04-06T15:20:49Z</dc:date>
    </item>
  </channel>
</rss>

