Skip to content

require('crypto') & DES inconsistent #9024

Description

@igalco
  • Version: v6.7.0
  • Platform: Darwin 16.0.0 Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:20 PDT 2016; root:xnu-3789.1.32~3/RELEASE_X86_64 x86_64
  • Subsystem: OpenSSL 0.9.8zh 14 Jan 2016

Hello,

I have an issue with the standard crypto package in node js.
The output do not always return the correct answer when using the DES algorithm.

Exemple :

var crypto = require('crypto');

var key = new Buffer("0131517010204061", "hex");
var buffer = new Buffer("1daae21c126127e4", "hex");

for (var i = 0; i < 10; i++) {

    var cipher = crypto.createCipheriv('des', key, Buffer.alloc(0));
    cipher.setAutoPadding(false);
    var crypted = cipher.update(buffer);
    // cipher.final(); is missing because we are only encrypting 1 block of data                                                                                                                       

    console.log("[iteration:%d] key=%s + data=%s => %s", i, key.toString("hex"), buffer.toString("hex"), crypted.toString("hex"));
}

result :
[iteration:0] key=0131517010204061 + data=1daae21c126127e4 => 959f39b6951d75e6
[iteration:1] key=0131517010204061 + data=1daae21c126127e4 => 959f39b6951d75e6
[iteration:2] key=0131517010204061 + data=1daae21c126127e4 => 959f39b6951d75e6
[iteration:3] key=0131517010204061 + data=1daae21c126127e4 => 959f39b6951d75e6
[iteration:4] key=0131517010204061 + data=1daae21c126127e4 => a3201c51a48d3df8
[iteration:5] key=0131517010204061 + data=1daae21c126127e4 => 959f39b6951d75e6
[iteration:6] key=0131517010204061 + data=1daae21c126127e4 => a3201c51a48d3df8
[iteration:7] key=0131517010204061 + data=1daae21c126127e4 => 7971aa42de5e626b
[iteration:8] key=0131517010204061 + data=1daae21c126127e4 => b37129ad8d2b91be
[iteration:9] key=0131517010204061 + data=1daae21c126127e4 => 959f39b6951d75e6

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.questionIssues asking questions about Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions