GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [v24.x backport] crypto, test, and tooling fixes by panva · Pull Request #66970 · nodejs/node

[v24.x backport] crypto, test, and tooling fixes #66970

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.

Sign up for GitHub

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

Closed
panva wants to merge 11 commits into nodejs:v24.x-staging from panva:backport-v24-20261024

Uh oh!

There was an error while loading. Please reload this page.

Closed

[v24.x backport] crypto, test, and tooling fixes #66970

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit Hold shift + click to select a range
b36ce76
tools: use self-repository references
panva Sep 13, 2026
b6709c1
crypto: use current FIPS state for availability
panva Sep 23, 2026
d0c0275
crypto: use internal random buffer bounds
panva Sep 22, 2026
f233bab
test: reduce expensive crypto test variants
panva Sep 25, 2026
2b7a132
crypto: separate conversion from validation
panva Sep 22, 2026
9194871
crypto: use backend cSHAKE and KMAC
panva Sep 23, 2026
ec18142
crypto: improve random synchronous number generation performance
mertcanaltin Oct 3, 2026
2559033
test: scope Blob WPT failures to big-endian
panva Sep 26, 2026
8ec2cb9
test: honor allowed WPT promise rejections
panva Sep 26, 2026
138ed26
crypto: remove KEM key locking
panva Sep 30, 2026
4afe009
crypto: remove key export and metadata locks
panva Sep 30, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
crypto: improve random synchronous number generation performance
Instead of creating a RandomBytesJob object, it calls CSPRNG()
directly now.

Assisted-by: Claude Code
Signed-off-by: Mert Can Altin <[email protected]>
PR-URL: #66348
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Signed-off-by: Filip Skokan <[email protected]>
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@mertcanaltin @panva
mertcanaltin authored and panva committed Oct 28, 2026
commit ec181427475e3331e462ea8cbc9ad24fb06aba39

There are no files selected for viewing

12 changes: 2 additions & 10 deletions 12 lib/internal/crypto/random.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const {
CheckPrimeJob,
kCryptoJobAsync,
kCryptoJobSync,
randomFillSync: randomFillSyncImpl,
secureBuffer,
} = internalBinding('crypto');

Expand Down Expand Up @@ -184,16 +185,7 @@ function randomFillSync(buf, offset = 0, size) {
if (size === 0)
return buf;

const job = new RandomBytesJob(
kCryptoJobSync,
buf,
offset,
size);

const err = job.run()[0];
if (err)
throw err;

randomFillSyncImpl(buf, offset, size);
return buf;
}

Expand Down
33 changes: 33 additions & 0 deletions 33 src/crypto/crypto_random.cc
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,46 @@ MaybeLocal<Value> CheckPrimeTraits::EncodeOutput(Environment* env,
}

namespace Random {
static void RandomFillSync(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
CHECK(IsAnyBufferSource(args[0])); // Buffer to fill
CHECK(args[1]->IsUint32()); // Offset
CHECK(args[2]->IsUint32()); // Size

ArrayBufferOrViewContents<unsigned char> in(args[0]);

const uint32_t byte_offset = args[1].As<Uint32>()->Value();
const uint32_t size = args[2].As<Uint32>()->Value();
CHECK_GE(byte_offset + size, byte_offset); // Overflow check.
CHECK_LE(byte_offset + size, in.size()); // Bounds check.

env->PrintSyncTrace();
if (ERR_peek_error() != 0) ERR_clear_error();
if (ncrypto::CSPRNG(in.data() + byte_offset, size)) {
if (ERR_peek_error() != 0) ERR_clear_error();
return;
}

CryptoErrorStore errors;
errors.Capture();
if (errors.Empty()) {
errors.Insert(NodeCryptoError::DERIVING_BITS_FAILED);
}
Local<Value> exception;
if (errors.ToException(env).ToLocal(&exception)) {
env->isolate()->ThrowException(exception);
}
}

void Initialize(Environment* env, Local<Object> target) {
SetMethod(env->context(), target, "randomFillSync", RandomFillSync);
RandomBytesJob::Initialize(env, target);
RandomPrimeJob::Initialize(env, target);
CheckPrimeJob::Initialize(env, target);
}

void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(RandomFillSync);
RandomBytesJob::RegisterExternalReferences(registry);
RandomPrimeJob::RegisterExternalReferences(registry);
CheckPrimeJob::RegisterExternalReferences(registry);
Expand Down
23 changes: 23 additions & 0 deletions 23 test/parallel/test-crypto-randomfillsync-trace-sync-io.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const { spawnSync } = require('child_process');

// randomFillSync() should be reported by --trace-sync-io when it runs after
// the first event loop turn.

if (process.argv[2] === 'child') {
setImmediate(() => {
require('crypto').randomFillSync(Buffer.alloc(16));
});
return;
}

const { stderr, status } = spawnSync(process.execPath,
['--trace-sync-io', __filename, 'child'],
{ encoding: 'utf8' });
assert.strictEqual(status, 0);
assert.match(stderr, /WARNING: Detected use of sync API[\s\S]*randomFillSync/);
1 change: 1 addition & 0 deletions 1 typings/internalBinding/crypto.d.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ export interface CryptoBinding {
privateEncrypt: InternalCryptoBinding.PublicKeyCipher;
publicDecrypt: InternalCryptoBinding.PublicKeyCipher;
publicEncrypt: InternalCryptoBinding.PublicKeyCipher;
randomFillSync(buf: ArrayBufferLike | ArrayBufferView, offset: number, size: number): void;
resetRootCertStore(): void;
secureBuffer(length: number): Uint8Array | undefined;
secureHeapUsed(): bigint | undefined;
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.