gchq / gchq/CyberChef

MDC2 OpenSSL support Node Crypto-Module

Open
#1,397 0 comments 0 reactions 0 assignees View on GitHub
operation
Dominant language
JavaScript
Stars
35.8k
Forks
4.1k
Avg merge
2d 26m
Merged PRs (30d)
33

Description

Not actually a feature request. Trying to create my own operation with the inbuild Node Crypto-Module (OpenSSL). For our customers we need to calculate an MDC2. Downloaded and configured OpenSSL and enabled MDC2 since its deprecated and has do be done manually. Works like it should, I was able to calculate and MDC2 with OpenSSL.

**Reference OpenSSL:**
printf "\x7C\x63\xDF\xF8\xB9\x32\x52\xAD\x92\x52\x45\x86\xCD\xE6\xAB\x8F" | openssl dgst -provider legacy -mdc2
Result: e93704fcfa79987cfe1d2148e8d23024

Next Step, calculate an MDC2 with Node via Crypto:

export NODE_OPTIONS=--openssl-legacy-provider <--Needs to be done to use OpenSSL legacy functions

**test.js**
```
#!/usr/bin/env node
const crypto = require("crypto");
console.log(String(crypto.createHash("mdc2").update("test").digest("hex")));
```
Result: c2dd499827c00a40f3e5cfaa22bd4db4

Since everything works like it should, I tried to implement this into CyberChef. Created my own operation as described in the documentation.

**Gruntfile.js: (added --openssl-legacy-provider)**
`const nodeFlags = "--openssl-legacy-provider --experimental-modules --experimental-json-modules --experimental-specifier-resolution=node --no-warnings --no-deprecation";`

**MDC2.mjs:**
```
run(input, args) {
const crypto = require("crypto");
return String(crypto.createHash("mdc2").update(input).digest("hex"));
}
```

Output CyberChef:
MDC2 - Error in http://localhost:8080/modules/Crypto.js line 3205 > eval on line 5.

Message: mdc2 is not supported (we accept pull requests)

If I change MDC2 to MD5 it works perfectly fine, but not with MDC2 / MD4. Ist there any hidden switch or something?

Contributor guide

Open the contributing guide

Research direction

Start with the unsupported-hash error in Crypto.js at line 3205, then compare the working MD5 operation with the MDC2.mjs example and the Node behavior shown in test.js. Check whether the Gruntfile.js Node flags affect the runtime used by CyberChef. Done means an MDC2 operation produces the expected digest instead of the unsupported-algorithm error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cryptography
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.