Encrypt debug info

I’m trying to encrypt the debug info when compiling by using the following command:

ERL_COMPILER_OPTIONS='[encrypt_debug_info]' mix compile

As suggested in the Erlang docs, .erlang.crypt is set to [{debug_info, des3_cbc, [], "%>7}|pc/DM6Cga*68$Mw]L#&_Gejr]G^"}].

When I decompile the .beam files using The BEAMdasm disassembler, I do not see any difference whatsoever between the encrypted and the not encrypted files. Am I missing anything?

Thanks!

Is that disassembler picking up the key from .erlang.crypt? Does it still work if you move that file?

1 Like

Is that disassembler picking up the key from .erlang.crypt? Does it still work if you move that file?

yes, it does pick it up. If I remove it, I get ** (CompileError) mix.exs: no crypto key supplied.

To clarify, I meant remove the key after compiling with encryption enabled - something like this:

  • set up .erlang.crypt
  • run ERL_COMPILER_OPTIONS='[encrypt_debug_info]' mix compile
  • remove .erlang.crypt
  • start up the editor and try to use the disassembler

I just tried: the disassembled files look exactly like the one I get without encryption.

There should be a chunk in the .beam file called Dbgi (if it was compiled with debug_info). That is the chunk that gets encrypted by using encrypt_debug_info. None of the other chunks are encrypted. There is no way to encrypt the contents of any other chunk in a .beam file. So if your goal is to encrypt the code that the compiler emits there is no way to do that using the Erlang compiler. You will need to use some external tool.

2 Likes

beamdasm is a disassembler, that means it just converts the bytes to readable “beam assembler” using written Mnemonics, rather than raw bytes.

It does not look at the debug info at all.

2 Likes