Skip to content

crypto.privateDecrypt - padding issue #9588

@rensrongen

Description

@rensrongen
  • Version: v7+
  • Platform: Win10x64
  • Subsystem: crypto

crypto.privateDecrypt does not accept RSA_PKCS1_OAEP_PADDING and RSA_PKCS1_PADDING option.

Using either of them produces the following error:

Error: error:0408F090:rsa routines:PKEY_RSA_CTRL:illegal or unsupported padding mode

It does accept RSA_NO_PADDING, but when I decrypt an sha256 signature, it will produce a 256 character string, the final 64 characters contained the actual hash.

For example, I have to do the following to successfully decrypt and read the sha256 signature:

var signature = Crypto.publicDecrypt(
            {
                'key': SessionManager.PublicKey, //buffer
                'padding': Constants.RSA_NO_PADDING
            },
            Buffer.from(ciphertext, 'hex')
        ).toString().substr(192);

Everything works as expected when using privateDecrypt.

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