DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Decrypt the encrypted response from Java

    Posted Mon October 31, 2022 11:44 AM
    Hi,

    1. Java service encrypting the data and returning secretKey in the response
    2. Provided the private key file to decrypt the data
    3. In Data Power configured the below code.

    <xsl:variable name="RSAAlg" select="'http://www.w3.org/2001/04/xmlenc#rsa-1_5'"/>
    <xsl:variable name="privateKey" select="'name:crypto-key-pass'"/>
    <xsl:variable name="secretKeyEncrypted" select="//*[local-name()='secretKey']"/>

    <xsl:variable name="secretKeyDecrypted">
    <xsl:value-of select="dp:decrypt-key($secretKeyEncrypted,$privateKey,$RSAAlg)"/>
    </xsl:variable>

    <xsl:variable name="encryptedtext" select="//*[local-name()='companyType']"/>

    <xsl:variable name="vDecrypt">
    <xsl:value-of select="dp:decrypt-data($vAlgorithm,$secretKeyDecrypted,$encryptedtext)"/>
    </xsl:variable>

    Code is failed with below error.

    *RSA decryption failed*

    Ephemeral key decryption failed: *RSA decryption failed*

    Could you please help on the below issue


    ------------------------------
    vijendhar soma
    ------------------------------


  • 2.  RE: Decrypt the encrypted response from Java

    Posted Mon October 31, 2022 12:28 PM
    Your XSLT is certainly by the book.  The only thing I can think of is the content of the encrypted secret key itself.

    Can you build out a sample rule that does the encrypt on DataPower followed by the decrypt, and then compare the content of the secretKey between what Datapower does and what Java does?

    ------------------------------
    Joseph Morgan
    ------------------------------



  • 3.  RE: Decrypt the encrypted response from Java

    Posted Mon April 17, 2023 09:51 AM

    Thanks for sharing this valuable information.

    1. Java service encrypting the data and returning secretKey in the response
    2. Provided the private key file to decrypt the data
    3. In Data Power configured the below code.

    <xsl:variable name="RSAAlg" select="'http://www.w3.org/2001/04/xmlenc#rsa-1_5'"/>
    <xsl:variable name="privateKey" select="'name:crypto-key-pass'"/>
    <xsl:variable name="secretKeyEncrypted" select="//*[local-name()='secretKey']"/>

    <xsl:variable name="secretKeyDecrypted">
    <xsl:value-of select="dp:decrypt-key($secretKeyEncrypted,$privateKey,$RSAAlg)"/>
    </xsl:variable>

    <xsl:variable name="encryptedtext" select="//*[local-name()='companyType']"/>

    <xsl:variable name="vDecrypt">
    <xsl:value-of select="dp:decrypt-data($vAlgorithm,$secretKeyDecrypted,$encryptedtext)"/>
    </xsl:variable>

    Code is failed with java development services below error.

    *RSA decryption failed*

    Ephemeral key decryption failed: *RSA decryption failed*

    Could you please help on the below issue



    ------------------------------
    Jack sully
    ------------------------------



  • 4.  RE: Decrypt the encrypted response from Java

    Posted Thu April 20, 2023 02:44 AM

    Hi,

    The error messages don't necessarily give enough information to debug these things. in addition to what Joseph suggested verify that your encryptedtext - variable really contains only the encrypted text part, for example adding the text node match to your xpath:

    <xsl:variable name="encryptedtext" select="//*[local-name()='companyType']/text()"/>



    ------------------------------
    Hermanni Pernaa
    ------------------------------