-
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
fix(ext/node): implement aes-128-ctr
, aes-192-ctr
, and aes-256-ctr
#27630
Conversation
aes-128-ctr
and aes-256-ctr
aes-128-ctr
and aes-256-ctr
I confirmed this works in the same way as Node.js. Nice work! import crypto from "node:crypto";
import { Buffer } from "node:buffer";
var algorithm = "aes-128-ctr",
key = Buffer.from("5ebe2294ecd0e0f08eab7690d2a6ee69", "hex"),
iv = Buffer.from("26ae5cc854e36b6bdfca366848dea6bb", "hex");
function encrypt(text) {
const cipher = crypto.createCipheriv(algorithm, key, iv);
var crypted = cipher.update(text, "utf8", "hex");
crypted += cipher.final("hex");
return crypted;
}
function decrypt(text) {
var decipher = crypto.createDecipheriv(algorithm, key, iv);
var dec = decipher.update(text, "hex", "utf8");
dec += decipher.final("utf8");
return dec;
}
var hw = encrypt("hello world");
console.log(hw);
console.log(decrypt(hw));
This seems fine to me. Node.js seems throwing @nathanwhit Can you add some simple test cases? |
@kt3k added tests, including for invalid key/iv length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
aes-128-ctr
and aes-256-ctr
aes-128-ctr
, aes-192-ctr
, and aes-256-ctr
…tr` (#27630) Fixes #24864 Need to add some tests, also unsure about the right counter size (went with 128 bit to be safe) --------- Co-authored-by: Yoshiya Hinosawa <[email protected]>
Fixes #24864
Need to add some tests, also unsure about the right counter size (went with 128 bit to be safe)