API Connect

API Connect

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.  HMAC 256 Not working .

    Posted Thu March 09, 2023 01:25 PM
    Edited by mayur gharat Thu March 09, 2023 01:26 PM

    We have used below code for HMAC but getting  error as 256 bit require in datap[ower 
    as per client requirement key should be "TEIFHEW" but same is  working online js complier but on datapower not working .


    const crypto = require('crypto');

    const secret = Buffer.from('TEIFHEW');
     
    // Calling createHmac method

    const hash = crypto.createHmac('sha256', secret).update('mayur').digest('base64');
     session.output.write(hash)
    // Displays output
    console.log(hash);



    ------------------------------
    mayur gharat
    ------------------------------



  • 2.  RE: HMAC 256 Not working .

    This message was posted by a user wishing to remain anonymous
    Posted Fri March 17, 2023 01:28 PM
    This post was removed


  • 3.  RE: HMAC 256 Not working .

    Posted Fri March 17, 2023 03:20 PM

    Hi Mayur, 

    it seems like the issue is that there is no padding for the key - you need to provide a 32 byte key. the folks here have used stuff like 

    var encryptionKey = crypto.randomBytes(32);

    you could also potentially create a crypto key object on the device and point to a text like 0x123 for a 256 bit key then reference the name of the object in the script.



    ------------------------------
    Gabriel Marte Blanco
    Austin TX
    ------------------------------



  • 4.  RE: HMAC 256 Not working .

    Posted Sun March 19, 2023 08:39 AM

    Hi ,

     I can understand that key should be 256 bit but as per client requirement we need to use  keys as 7 digit like "TEIFHEW" , do we have an option to work this on datapower as same is working in  other js compiler .

    Regards ,

    mayur 



    ------------------------------
    mayur gharat
    ------------------------------