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

fix(ext/node): add aes256 algorithm support #22198

Merged
merged 5 commits into from
Feb 1, 2024

Conversation

iuioiua
Copy link
Contributor

@iuioiua iuioiua commented Jan 31, 2024

Please excuse any silly mistakes. I have little experience with the Node compatibility layer and crypto.

Towards #21804

CC @littledivy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I come up with test data for the corresponding createDecipheriv() test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how the test vectors were generated for createDecipheriv().

I think this should work:

# Encrypts null 10byte plaintext using zeroed key and IV and hex encodes it.
echo 0000000000 \
 | openssl enc -e -aes256 -K 0000000000000000000000000000000000000000000000000000000000000000 -iv 00000000000000000000000000000000 \
 | xxd -p

Add the output of the command as the input in the 'aes256' createDecipheriv test

@kt3k Do you know how they were created?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've used the same API of Node.js to create them

Copy link
Contributor Author

@iuioiua iuioiua Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it using:

const { createCipheriv } = require('node:crypto');

const cipher = createCipheriv("aes256", zeros(32), zeros(16));
const input = cipher.update(zeros(90), undefined, "hex") + cipher.final("hex");

@iuioiua iuioiua requested a review from littledivy February 1, 2024 01:36
Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@littledivy littledivy merged commit 6512be4 into denoland:main Feb 1, 2024
15 checks passed
@iuioiua iuioiua deleted the node-aes256 branch February 1, 2024 03:50
littledivy pushed a commit that referenced this pull request Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants