Skip to content

crypto.privateDecrypt cannot decrypt message #22792

Description

@Nolaan
  • Version: v8.11.3
  • Platform: Linux x86_64
  • Subsystem:

I'm trying to encrypt/decrypt data using a rsa key but the process fails somehow with this message :

Error: error:04099079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1:oaep decoding error

Code :

varchildProcess=require('child_process');varcrypto=require('crypto');varpk;varmess_chiffre;varsign=function(){varbuf=newBuffer("Coucou c'est relou!!!");varsig=crypto.privateEncrypt(pk,buf);mess_chiffre=sig.toString('hex');console.log("Signed : ",mess_chiffre);};vardecrypt=function(){varbuff=newBuffer(mess_chiffre,'hex')console.log('Buffer : ',buff)console.log('decrypting withh pk: ')console.log(pk)varmess=crypto.privateDecrypt(pk,buff)console.log(mess)};childProcess.exec('openssl rsa -in private.key',{},function(err,stdout,stderr){if(err)throwerr;pk=stdout;// Save in memory for later usesign();decrypt();});

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.docIssues and PRs related to the documentations.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions