1.) Created a Public Key and a Private Key in Datapower 2.) Confirmation.. Action completed successfully. Generated private key in "cert:///spp378_self_signed-privkey.pem" Generated Certificate Signing Request in "temporary:///spp378_self_signed.csr" Generated Self-Signed Certificate in "cert:///spp378_self_signed-sscert.pem" and exported a copy in "temporary:///spp378_self_signed-sscert.pem" Generated a Crypto Key object named "spp378_self_signed" and a Crypto Certificate object named "spp378_self_signed" 3.) Screen Shots of the Public and Private Keys 4.) Encrypt XSL Basically, I’m forming a “SessionId” by concatenating 3 values from the Header and encrypting using the dp:encrypt-key using the Public Key <xsl:stylesheet version="1.0" encoding= "UTF-8" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp"> <xsl:template match="OfficePassword"> <xsl:variable name="mobileDeviceId"> <xsl:value-of select="dp:http-request-header('MobileDeviceId')"/> </xsl:variable> <xsl:variable name="loginUser"> <xsl:value-of select="dp:http-request-header('LoginUser')"/> </xsl:variable> <xsl:variable name="ipAddress"> <xsl:value-of select="dp:http-request-header('IPAddress')"/> </xsl:variable> <xsl:variable name="algorithm" select="'http://www.w3.org/2001/04/xmlenc#rsa-1_5'"/> <xsl:element name="SessionId"> <xsl:value-of select="string(concat($mobileDeviceId, '|', $loginUser, '|', $ipAddress))"/> </xsl:element> The above is modified to <xsl:variable name="SessionId"> <xsl:value-of select="string(concat($mobileDeviceId, ',',$loginUser, ',',$ipAddress))" /> </xsl:variable> <xsl:element name="EncryptedSessionId"> <xsl:copy-of select="dp:encrypt-key($SessionId, 'name:spp378_self_signed', $algorithm, 'base64')"/> </xsl:element> </xsl:template> <xsl:template match="*"> <xsl:element name="{local-name()}"> <xsl:apply-templates/> </xsl:element> </xsl:template> </xsl:stylesheet> 5.) Decrypt XSL Here, the output of the previous encryption is given as an input to this XSL. <xsl:stylesheet version="1.0" encoding= "UTF-8" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp"> <xsl:template match="OfficePassword"> <xsl:element name="PrintOfficePassword"> <xsl:value-of select="." /> </xsl:element> <xsl:variable name="algorithm" select="'http://www.w3.org/2001/04/xmlenc#rsa-1_5'" /> <xsl:element name="DecryptedSessionId"> <xsl:copy-of select="dp:decode(dp:decrypt-key($PrintOfficePassword, 'name:spp378_self_signed', $algorithm),'base-64')"/> </xsl:element> </xsl:template> <xsl:template match="*"> <xsl:element name="{local-name()}"> <xsl:apply-templates/> </xsl:element> </xsl:template> </xsl:stylesheet> These are the results from the execution on 04/20/2015 <SessionId>psr75,abc1,127.0.0.1</SessionId> <EncryptedSessionId>dYJF4xuMd8gXBpybaiRW6lWOXdXhni4MBcHRXh7c9PgsZEGMcafcyIx/Na8btYNYrcyvHRVDjhxCyUCJm7otiKyMpfPTAhIdstZwHf3r+uObL 5OZ7LgcS1AEZfc59Yw6dpqP2bZ0SHDP6mE7SNyPADbnmTwskQdd0TsVeZ5CbJuNv+uLIi1RUo2RkRZkJGW6OLKaxQAuzpMQQGe6o2DW9nLRMbxJyrurPBn AZwdgo01EM0z2IHFkzeT3JbKQzMWfTET3IMIBxvw7FgQCRi5gh+XYxNkippGq12pKbrfs/rW+oUM1Z+13BijwVrG96JGJOB2uSxc5YKkBpa12nf4DIFdXOQRLfAZy pv9Yuckzka9Nv711LlJKnDxaKeaKG3kiotXlYwstrF88AfbO5OwBrO/CQ5B8sO3jMSHaO/NCCmz33UUATc1S/DaP2BDsefSkQXbaIRBhDWuFPg3KpjJeDbWOwtz mZ97+QtBRaipSVa/Nz41kk55Sl9Spmx3jBCXhIXGMW0WPz4vMuIEtdYgR/lHaJY1qo2yr4B/MOJVTWFqgupbvbKPq0YpEyHcqFr5Wnv2rwrROZHUWTYvuTNKoD a+ikR5Ux2wf0qrRoF4pWb0jF8fD9j8xC5unoTbGzeMP8JMCWLMTFY2+uTL5lxmGyR0BX6fTMUi8LqxMZFIYQ8U=</EncryptedSessionId> <DecryptedSessionId>psr77/abc3/127/0/3/1</DecryptedSessionId> 6.) Encrypted Session Id, <EncryptedSessionId>TUVvPn+g9kcTqNWnKoXmLcNS2mDHcDwtTHEsQW+FX40ib5IjwFlNJvy6+qcUWhxbETIczz61DSZA8hPi8NFU s11veG63T4J0/xpNnVIVqmZDwnyJOfIcIKjFS1bW/xU1OffrMirld30Z2wn2tXYk/WVT8TOsb3c6MW5ydAbyslA=</EncryptedSessi onId> 7.) Trying to decrypt by passing the EncryptedSessionId from the previous step 8.) Error from the System log 10:40: xmlfire war 20 wall n AM xmlfirewall (PKI_Decrypt): Generated error to 0.0.0.0 on URL: <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><env:Fault><faultcode>env:Client</f aultcode><faultstring>Internal Error (from client)</faultstring></env:Fault></env:Body></env:Envelope> 10:40: multiste err 20 p or AM xmlfirewall (PKI_Decrypt): Dynamic Execution Error 10:40: multiste err 20 p or AM 10:40: 20 xslt AM err or xmlfirewall (PKI_Decrypt): request PKI_Decrypt_request #1 xform: 'Transforming INPUT with local:///pki_decrypt.xsl results stored in PIPE' failed: Valid base64 passed to dp:decode resulted in non UTF8: 'n/IoN//B19d7WquXBKVnrt9eLH97oEyNVV75OZ9UZQKeOBH5ugTguA6mCn9ct+bsFXQ3serxTvMS/L y6ARt7U4c=' xmlfirewall (PKI_Decrypt): Processing of 'local:///pki_decrypt.xsl' stopped: Valid base64 passed to dp:decode resulted in non UTF8: 'n/IoN//B19d7WquXBKVnrt9eLH97oEyNVV75OZ9UZQKeOBH5ugTguA6mCn9ct+bsFXQ3serxTvMS/L y6ARt7U4c='