How to decrypt file / api response

we’re trying to decrypt API response in elixir, but failed, got segmentation fault error. kindly help us to fix the issue

:crypto.block_decrypt(:des_ecb, des_key, Base.decode64!(ciphertext))

here is the working Node-js script

var res_text = CryptoJS.DES.decrypt(response, CryptoJS.enc.Utf8.parse(des_key),{
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    }).toString(CryptoJS.enc.Utf8)

I think you need to be a lot more specific here…

ciphertext size, des_key size, Erlang/OTP version, OpenSSL version, Operating system, etc.

Also: I was unable to find :des_ecb in the allowed ciphers, though I wouldn’t expect a segfault because of that…

1 Like

des_ecb present in cipher_no_iv category.

sample data:
https://drive.google.com/file/d/1Bf3I8cQVfj3DjGeNadJ_85oXZsHlR-uH/view?usp=sharing

OS: ubuntu, Erlang/OTP 22

Can you change cryptographic primitives used there? As using ECB in the real world is, not the brightest idea. In general there is everything wrong with that encryption:

  • DES is old and unsafe cipher that shouldn’t be used anymore
  • ECB is the worst mode possible
  • There is no authentication of the data, so it is not tamper-proof

About the issue, it seems like there is bug in crypto library from OTP.

we added JavaScript interface to elixir funtion node-js, thank you…