-5

My question is about RSA Private Encrypt, not just about signing. And yes, I understand the differences between signing, private-key encryption and public-key encryption.

Now I need to encrypt using the private RSA key and decrypt using the public key. Not vice versa, and not signing.

So, my question is not about whether can I encrypt with the private key, it's about QT libraries, that can do this.

Need to use it with QT windows.

Keys in PEM format (base64)

President James K. Polk
  • 40,516
  • 21
  • 95
  • 125
psy21d
  • 43
  • 1
  • 8
  • This isn't possible using standard public/private key crytography. You may be confusing it with digital signing. See here: https://stackoverflow.com/questions/454048/what-is-the-difference-between-encrypting-and-signing-in-asymmetric-encryption – Andrew M Jan 26 '18 at 09:13
  • 2
    Possible duplicate of [What is the difference between encrypting and signing in asymmetric encryption?](https://stackoverflow.com/questions/454048/what-is-the-difference-between-encrypting-and-signing-in-asymmetric-encryption) – Andrew M Jan 26 '18 at 09:14
  • To give you a great answer, it might help us if you have a glance at [ask] if you haven't already. It might be also useful if you could provide a [mcve]. – Mat Jan 26 '18 at 09:30
  • NO! I no need just signing, I need to encrypt by private key. Signing is another function. – psy21d Jan 26 '18 at 09:58
  • @psy21d one does not encrypt with the private key. That's not the way the algorithm has been designed. You encrypt with the public, and decrypt with the private. – UKMonkey Jan 26 '18 at 10:05
  • @UKMonkey Why it is not designed? At all? In any libraries? – psy21d Jan 26 '18 at 10:11
  • not at all, anywhere. Read the duplicate link! – UKMonkey Jan 26 '18 at 10:13
  • 1
    Because everyone has your public key (it's public) everyone can read your message if you encrypt it with your private key. So there is no point in encrypting the whole message (with your private key) just to prove you were the sender. – Richard Critten Jan 26 '18 at 10:34
  • @Richard Critten yes I understand that fact. But I need this way. – psy21d Jan 26 '18 at 18:34
  • @Mat I just look any library that do what I need. – psy21d Jan 26 '18 at 18:38

1 Answers1

4

Why not openssl?

int RSA_public_encrypt(int flen, unsigned char *from,
    unsigned char *to, RSA *rsa, int padding);
int RSA_private_decrypt(int flen, unsigned char *from,
    unsigned char *to, RSA *rsa, int padding);
int RSA_private_encrypt(int flen, unsigned char *from,
    unsigned char *to, RSA *rsa,int padding);
int RSA_public_decrypt(int flen, unsigned char *from, 
    unsigned char *to, RSA *rsa,int padding);
Ermat Kiyomov
  • 151
  • 1
  • 3