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

NPM package openpgp Is broken due to: Unknown cipher aes-256-cfb #26875

Closed
b-snel opened this issue Nov 14, 2024 · 0 comments · Fixed by #27466
Closed

NPM package openpgp Is broken due to: Unknown cipher aes-256-cfb #26875

b-snel opened this issue Nov 14, 2024 · 0 comments · Fixed by #27466
Labels
bug Something isn't working correctly crypto Related to node:crypto or WebCrypto node compat

Comments

@b-snel
Copy link

b-snel commented Nov 14, 2024

Version: Deno 2.0.6

I've found that the openpgp npm module is broken (either when trying to generate a key, decrypt using a key, etc). I've tried various versions of Deno and openpgp but it looks like they all return the same error:
error: Uncaught (in promise) TypeError: Error generating keypair: Unknown cipher aes-256-cfb at new Cipheriv (ext:deno_node/internal/crypto/cipher.ts:40:21) at new createCipheriv (node:crypto:29:10)

The strange thing is that cipher is available node:crypto, as I can see it via:
import { getCiphers } from 'node:crypto' console.log((getCiphers()).find((c) => c === 'aes-256-cfb'))

result:
aes-256-cfb

This all looks like it's coming from deno_node/internal/crypto/cipher.ts https://github.com/denoland/deno/blob/main/ext/node/polyfills/internal/crypto/cipher.ts

Here is the full script to reproduce:

import * as openpgp from 'npm:openpgp@6.0.0'
import { getCiphers } from 'node:crypto'
console.log((getCiphers()).find((c) => c === 'aes-256-cfb'))
;(async () => {
  const { privateKey, publicKey } = await openpgp.generateKey({
    type: 'rsa',
    rsaBits: 4096,
    userIDs: [{
      name: 'Testy McTestface',
      email: 'testy@test.com',
    }],
    passphrase: 'asdfasdfasdfasdfasdf',
    format: 'armored',
  })
  Deno.writeTextFileSync('testy_private.key', privateKey)
  Deno.writeTextFileSync('testy_public.key', publicKey)
})()

This is something that worked with node 22. Not sure if it should be brought up with ya'll or openpgp, but I was on the verge of transitioning to deno until this broke. Sad :(

Thanks for your help!

@nathanwhit nathanwhit added bug Something isn't working correctly node compat crypto Related to node:crypto or WebCrypto labels Nov 14, 2024
kt3k added a commit that referenced this issue Dec 26, 2024
Currently we only supports 7 ciphers (`aes-(128|192|256)-ecb` and
`aes-(128|256)-(cbc|gcm)`) in `node:crypto`, but `crypto.getCiphers`
returns other supported cipher names. That confuses `npm:openpgp`
package and causes #26875.

This PR makes `getCiphers` return actually supported cipher names.

With this change, the example given in #26875 can create private and
public key files.

closes #26875
dsherret pushed a commit that referenced this issue Jan 9, 2025
Currently we only supports 7 ciphers (`aes-(128|192|256)-ecb` and
`aes-(128|256)-(cbc|gcm)`) in `node:crypto`, but `crypto.getCiphers`
returns other supported cipher names. That confuses `npm:openpgp`
package and causes #26875.

This PR makes `getCiphers` return actually supported cipher names.

With this change, the example given in #26875 can create private and
public key files.

closes #26875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly crypto Related to node:crypto or WebCrypto node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants