CyberChef icon indicating copy to clipboard operation
CyberChef copied to clipboard

Bug report: CMAC doesn't assume hex-only input as hex

Open dccutrig opened this issue 2 years ago • 1 comments

Describe the bug When I use CyberChef for various encryption schemes, it seems to accurately calculate results when compared to several other calculators. Utilizing CMAC, it does not generate the correct output. The issue appears to be that CMAC doesn't seem to assume hex encoding of input, whereas other schemes do.

To Reproduce Steps to reproduce the behaviour or a link to the recipe / input used to cause the bug:

(https://gchq.github.io/CyberChef/#recipe=CMAC(%7B'option':'Hex','string':'ff9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f9'%7D,'AES')&input=MDJDMDAwMDAxODAwMDAwQzA4MDEwMDAwMDAwRjAwMTEyMjMzNDQ1NTY2Nzc4ODk5QUFCQkNDRERFRUZG)

Expected behaviour I would expect, having worked with AES-GCM that I would not need to add a 'from_hex' to the recipe:

(https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')CMAC(%7B'option':'Hex','string':'ff9f9284cf599eac3b119905a7d18851e7e374cf63aea04358586b0f757670f9'%7D,'AES')&input=MDJDMDAwMDAxODAwMDAwQzA4MDEwMDAwMDAwRjAwMTEyMjMzNDQ1NTY2Nzc4ODk5QUFCQkNDRERFRUZG)

The output from this link matches pycryptodome and CryptoJS, as well as libgcrypt.

Additional context It just seems an inconsistency given other schemes. Sometimes in large Unit Tests I'll include a single CyberChef link for others to examine as a sanity check, or as an external validation of code I'm writing. In this instance my code wasn't matching cyberchef, and based on assumptions made due to previous usage, I thought my code was wrong.

Edit: Wrong Expected Behavior Link

dccutrig avatar Aug 31 '23 15:08 dccutrig

@dccutrig, hmm, why would it? Could you name an example operation which would magically assume the input is hex when it's a valid hex?

zb3 avatar Apr 01 '24 12:04 zb3