Hi @Steve Linn ,@Gabriel Marte Blanco and All,
Iam facing ans issue while doing encryption from shared secret key.
Consider my shared secret key is "fY6edUre" which is in datapower and we are doing symmetric encryption in API Connect using AES256-CBC Algorithm using gateway script , getting the below error
GatewayScript processing Error 'Error: When using the 'aes256-cbc' algorithm, the key length shall be 256 bits In file 'gatewayscript:///modules/crypto.js' line:486, stack:Error: When using the 'aes256-cbc' algorithm, the key length shall be 256 bits at Object.createCipheriv (gatewayscript:///modules/crypto.js:486:11) at Object.<anonymous> (temporary:///js/framework_sandbox_csb_1.0.0_gatewayscript_0.js:22:23) at Script.execute (gatewayscript:///datapower.js:158:24) at Object.<anonymous> (gatewayscript:///datapower.js:585:55)'
below java code is solving this issue
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
PBEKeySpec spec = new PBEKeySpec(TOKEN.toCharArray(), saltBytes, 65536, 256);
SecretKey tmp = factory.generateSecret(spec);
SecretKey secret = new SecretKeySpec(tmp.getEncoded(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
please guide us to achieve the same in gateway script.
Thanks in Advance.
------------------------------
Manasa G
------------------------------