crypto.verify accepted types mismatch documentation (and crypto.sign) · Issue #62903 · nodejs/node · GitHub
Skip to content

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

@ChALkeR

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

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