Skip to content

crypto.verify accepted types mismatch documentation (and crypto.sign) #62903

Description

@ChALkeR
Image

https://github.com/nodejs/node/blob/HEAD/lib/internal/crypto/sig.js#L268

> const { privateKey, publicKey } = require('crypto').generateKeyPairSync('rsa', { modulusLength: 2048 })
> require('crypto').sign('SHA256', new ArrayBuffer(32), privateKey)
> require('crypto').verify('SHA256', new ArrayBuffer(32), publicKey, _)
Uncaught:
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be an instance of Buffer, TypedArray, or DataView. Received an instance of ArrayBuffer
    at Object.verifyOneShot [as verify] (node:internal/crypto/sig:261:11) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Documentation: https://nodejs.org/api/crypto.html#cryptoverifyalgorithm-data-key-signature-callback
Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions