browserify / browserify/crypto-browserify

signature creation with des-ede3-cbc encrypted private key resulting in error

Open
#191 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
681
Forks
209
PR merge metrics
No merged PRs in 30d

Description

Hi there!

i'm currently having an issue with my ede3-cbc encrypted private key and signature creation.
i use the crypto modules to sign a string - this is being used in a node environment and working perfectly fine.
Unfortunately i cannot use the nodeJS environment for a specific call in a seperate system. So i need to use the browserified-version of it.

Unfortunately this is always ending in the following error:
algo is undefined

This is the part where the error occurs:
```
function decrypt (data, password) {
var salt = data.algorithm.decrypt.kde.kdeparams.salt
var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10)
var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')]
var iv = data.algorithm.decrypt.cipher.iv
var cipherText = data.subjectPrivateKey
var keylen = parseInt(algo.split('-')[1], 10) / 8
var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1')
var cipher = ciphers.createDecipheriv(algo, key, iv)
var out = []
out.push(cipher.update(cipherText))
out.push(cipher.final())
return Buffer.concat(out)
}
```

the array aesid holds the following values
`aes{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}`

which means my algorithm 1.2.840.113549.3.7 is not available.

Is this even supported? Or am i doing something horribly wrong? :D

The code i use for creation is:
```
let signer = crypto.createSign(this.algorithm).update(this.stringToSign);
return signer.sign({
key: this.privateKey,
padding: this.signaturePadding,
saltLength: this.saltLength,
passphrase: this.privateKeyPassPhrase
}, 'base64');
}
```
thanks in advance!

Best regards
Pascal

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.