Topic
  • 1 reply
  • Latest Post - ‏2013-01-09T10:27:50Z by HermannSW
msmps
msmps
193 Posts

Pinned topic symmetric key

‏2013-01-08T21:42:53Z |
How to generate a symmetric aes key which is compatible on Java and datapower both.
And this key needs to be generated off the appliance
Updated on 2013-01-09T10:27:50Z at 2013-01-09T10:27:50Z by HermannSW
  • HermannSW
    HermannSW
    4728 Posts

    Re: symmetric key

    ‏2013-01-09T10:27:50Z  
    Hello Robert,

    > How to generate a symmetric aes key which is compatible on Java and datapower both.
    > And this key needs to be generated off the appliance
    >
    Not sure how Java needs the keys.
    But keys are random byte sequences of 128/192/256 bits.
    For DataPower cyrpto operations the (binary) key data has to be base64-encoded.
    Below stylesheet does create them for you using dp:random-bytes(_):
    
    $ cat [12][2495]?.xml <n>128</n> <n>144</n> <n>192</n> <n>256</n> $ $ coproc2 random-aes.xsl 128.xml http:
    //dp3-l3:2223 ; echo xAlGQ2ZYdg0fOoYQlrjWHw== $ $ coproc2 random-aes.xsl 144.xml http:
    //dp3-l3:2223 -s | xpath++ "//faultstring/text()" -   ------------------------------------------------------------------------------- Illegal block size 144, allowed values are 128/192/256 (from client) $ $ coproc2 random-aes.xsl 192.xml http:
    //dp3-l3:2223 ; echo ghh1i6EU7hkZ9NyrL4ZY9TO/0xxgDQz0 $ $ coproc2 random-aes.xsl 256.xml http:
    //dp3-l3:2223 ; echo 5gNWI6JWz9cACNOJB60stQq2uneDfOWORoaH7wPV/bs= $ $ cat random-aes.xsl <xsl:stylesheet version=
    "1.0" xmlns:xsl=
    "http://www.w3.org/1999/XSL/Transform" xmlns:dp=
    "http://www.datapower.com/extensions" extension-element-prefixes=
    "dp" > <xsl:output omit-xml-declaration=
    "yes" />   <xsl:variable name=
    "block-sizes"> <bs>128</bs><sl>/</sl><bs>192</bs><sl>/</sl><bs>256</bs> </xsl:variable>   <xsl:template match=
    "/"> <xsl:
    
    if test=
    "not(. = $block-sizes/*)"> <dp:reject>Illegal block size <xsl:value-of select=
    "."/>, allowed values are <xsl:value-of select=
    "$block-sizes"/> </dp:reject> </xsl:if>   <xsl:value-of select=
    "dp:random-bytes(. div 8)"/> </xsl:template> </xsl:stylesheet> $
    


     
    Hermann<myXsltBlog/> <myXsltTweets/>