Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PKCS#5 AES-256-CBC encrypted private keys #50

Closed
wants to merge 1 commit into from

Conversation

@nahuel
Copy link
Contributor

nahuel commented May 31, 2018

Add support for parsing PKCS#5 private keys encrypted with AES-256-CBC.
Previous to this fix only 128 bits keys were supported:

openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:6553 -outform pem -out key.priv
openssl rsa -aes128 -in key.priv -passout pass:pass -out key128.priv.crypt
openssl rsa -aes256 -in key.priv -passout pass:pass -out key256.priv.crypt
// this also worked ok before this patch:
sshpk.parsePrivateKey(fs.readFileSync('key128.priv.crypt'), 'pem', { passphrase : 'pass'})
// this not, but now is ok:
sshpk.parsePrivateKey(fs.readFileSync('key256.priv.crypt'), 'pem', { passphrase : 'pass'})  
Add support for parsing PKCS#5 private keys encrypted with AES-256-CBC. 
Previous to this fix only 128 bits keys were supported:

openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:6553 -outform pem -out key.priv
openssl rsa -aes128 -in key.priv -passout pass:pass -out key128.priv.crypt
openssl rsa -aes256 -in key.priv -passout pass:pass -out key256.priv.crypt

sshpk.parsePrivateKey(fs.readFileSync('key128.priv.crypt'), 'pem', { passphrase : 'pass'})  // this also worked ok before this patch
sshpk.parsePrivateKey(fs.readFileSync('key256.priv.crypt'), 'pem', { passphrase : 'pass'})  // this not, but now is ok
@codecov-io
Copy link

codecov-io commented May 31, 2018

Codecov Report

Merging #50 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   86.16%   86.19%   +0.02%     
==========================================
  Files          24       24              
  Lines        3680     3680              
==========================================
+ Hits         3171     3172       +1     
+ Misses        509      508       -1
Impacted Files Coverage Δ
lib/utils.js 79.23% <ø> (ø) ⬆️
lib/signature.js 88.88% <0%> (+0.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6edb37c...0b23fd3. Read the comment docs.

joyent-automation pushed a commit that referenced this pull request Oct 11, 2018
Reviewed by: Alex Wilson <alex.wilson@joyent.com>
@arekinath
Copy link
Contributor

arekinath commented Oct 11, 2018

Merged as 53e23fe, will be in the next release. Thanks!

@arekinath arekinath closed this Oct 11, 2018
This was referenced Oct 12, 2018
Turbo87 added a commit to Turbo87/igc-parser that referenced this pull request Oct 15, 2018
Bumps [sshpk](https://github.com/joyent/node-sshpk) from 1.13.1 to 1.15.1. **This update includes security fixes.**
<details>
<summary>Vulnerabilities fixed</summary>

*Sourced from [The Sonatype OSS Index](https://ossindex.sonatype.org/vuln/fc393f9f-282f-4bc9-953b-d7e4b48352e9).*

> **CWE-400: Uncontrolled Resource Consumption ('Resource Exhaustion')**
> The software does not properly restrict the size or amount of resources that are requested or influenced by an actor, which can be used to consume more resources than intended.
> 
> Affected versions: <1.14.1

*Sourced from The GitHub Vulnerability Alert Database.*

> **CVE-2018-3737**
> See https://nvd.nist.gov/vuln/detail/CVE-2018-3737.
> 
> Affected versions: < 1.13.2

*Sourced from [The Node Security Working Group](https://github.com/nodejs/security-wg/blob/master/vuln/npm/401.json).*

> **Denial of Service**
> `sshpk` is vulnerable to ReDoS when parsing crafted invalid public keys
> 
> Affected versions: <=1.13.1

</details>
<details>
<summary>Release notes</summary>

*Sourced from [sshpk's releases](https://github.com/joyent/node-sshpk/releases).*

> ## v1.14.1
>  * Remove all remaining usage of jodid25519 (abandoned dep)
>  * Add support for DNSSEC key format
>  * Add support for Ed25519 keys in PEM format (according to draft-curdle-pkix)
>  * Fixes for X.509 encoding issues (asn.1 NULLs in RSA certs, cert string type mangling)
>  * Performance issues parsing long SSH public keys
</details>
<details>
<summary>Commits</summary>

- [`2ab4f2a`](joyent/node-sshpk@2ab4f2a) joyent/node-sshpk#56 md5 fingerprints not quite right
- [`026ef47`](joyent/node-sshpk@026ef47) joyent/node-sshpk#53 stop using optional deps to fix webpack
- [`53e23fe`](joyent/node-sshpk@53e23fe) joyent/node-sshpk#50 Support PKCS#5 AES-256-CBC encrypted private keys
- [`6b68d49`](joyent/node-sshpk@6b68d49) joyent/node-sshpk#54 want API for accessing x509 extensions
- [`1088992`](joyent/node-sshpk@1088992) joyent/node-sshpk#52 Buffer no longer performs length check for hex strings i...
- [`6ec6f9d`](joyent/node-sshpk@6ec6f9d) joyent/node-sshpk#38 want support for more obscure DN OIDs
- [`1cc4c99`](joyent/node-sshpk@1cc4c99) joyent/node-sshpk#51 package.json repository does not point to Joyent
- [`175758a`](joyent/node-sshpk@175758a) joyent/node-sshpk#46 Use Buffer.(from|alloc) instead of deprecated Buffer API
- [`6edb37c`](joyent/node-sshpk@6edb37c) Release 1.14.0
- [`46065d3`](joyent/node-sshpk@46065d3) joyent/node-sshpk#44 Performance issues parsing long SSH public keys
- Additional commits viewable in [compare view](joyent/node-sshpk@v1.13.1...v1.15.1)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=sshpk&package-manager=npm_and_yarn&previous-version=1.13.1&new-version=1.15.1)](https://dependabot.com/compatibility-score.html?dependency-name=sshpk&package-manager=npm_and_yarn&previous-version=1.13.1&new-version=1.15.1)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

Dependabot will **not** automatically merge this PR because it includes a minor update to a production dependency.

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>
This was referenced Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.