-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
crypto.createCipheriv('aes-256-ctr', …) fails with Unknown cipher
#24864
Comments
@joewalker Can you provide a reproduction with ssh2 module? |
import crypto from "node:crypto";
import { Buffer } from "node:buffer";
var algorithm = "aes-256-ctr",
password = "d6F3Efeq",
key = Buffer.from("5ebe2294ecd0e0f08eab7690d2a6ee69", "hex"),
iv = Buffer.from("26ae5cc854e36b6bdfca366848dea6bb", "hex");
function encrypt(text) {
const cipher = crypto.createCipheriv("aes-128-cbc", key, iv);
var crypted = cipher.update(text, "utf8", "hex");
crypted += cipher.final("hex");
return crypted;
}
function decrypt(text) {
var decipher = crypto.createDecipheriv("aes-128-cbc", key, iv);
var dec = decipher.update(text, "hex", "utf8");
dec += decipher.final("utf8");
return dec;
}
var hw = encrypt("hello world");
// outputs hello world
console.log(decrypt(hw)); Seems to work with |
@littledivy in your example you don't ever use the If you update the code to use aes-256-ctr then deno v2 throws
|
Oh nice catch! |
|
Support for aes-256-ctr is definitely needed. |
yikes is this still not supported. |
same for |
Ah well 3 days into deno land and I'm turning back, fun while it lasted |
Node's docs for
So maybe Deno implicitly supports "aes-256-ctr" and "aes-256-cbc" (etc.) as long as they are available with the local OpenSSL? That's just an optimistic guess. I don't even use Deno, I ended up here while researching something else 🙂 |
Version: Deno 1.45.5
Usage context: Trying to port code from nodejs which uses ssh2.
The ssh2 library is attempting to decode an ssh private key.
The failure appears to come from Deno's
cipher.ts
:In this case
op_node_create_decipheriv
is called withcipher=aes-256-ctr
.The text was updated successfully, but these errors were encountered: