I want to implement simple software protection mechanism. This is how it would look like:
My question is - is there any problem for me using the private key for encryption and public for decryption (since usually it is other way around)?
You don't encrypt with a private key. You sign the message with one. One of the biggest misconceptions that I have seen here is that you can perform authentication of message by encrypting with a private key, and verified by decrypting with a public key. The problems are many, here are a few:
You don't decrypt with a public key. If some message can be recovered by using some publicly available information, it is not encryption.
BECAUSE, the goal of encryption is confidentiality. You encrypt the data so that only the one that owns a legitimate key can read it. It does not necessarily care about authentication or unforgeability. Digital signatures, on the other hand does not care about hiding any information and are designed to be unforgeable under chosen message attacks etc. (which means the attacker is assumed to be able to get signatures for messages of her choice from the legitimate owner) while encryption goes for semantic security (IND-CPA) or IND-CCA, (the attacker being unable to distinguish between ciphertexts of different plaintexts). One does not automatically imply the another.
Not all schemes allow both signatures and encryption schemes in similar ways but the question was about RSA so I will leave it here. But you should know that RSA encryption and RSA signatures are not the same algorithms even though they share the mathematical core
Beware. Private and public keys are theorically equivalent, so nothing prevents you for using the private key to encrypt (and have it to be publicly knows) and the public key to decrypt (and try to keep it secure).
But real life implementations do make a strong difference. It is common that the public key can be computed from the private one! That means that if you give someone else a private key, they will also know the public one, which somehow defeates the whole process of crypting.
That means that you must use your private key to prove that you are the author/sender of some data (you sign it) or the repipient public key to encrypt that piece of data (only the recipient will be able to decrypt).
using the private key for encryption and public for decryption
is a head-scratcher, because the public key is public (known to everyone), so anyone would be able to decrypt the ciphertext. Perhaps you are referring to digital signing, where the signature is made using the private key, and anyone can verify the signature using the public key.ACTIVATION_STRING
. And if I havePrivateKEY2
on the DESKTOP APP side (and usePublicKEY1
for encryption on SERVER side), I read that they could recover public key from it (PublicKEY1
) and then dore-encryption
after modification ofACTIVATION_STRING
?PublicKEY1
above, should bePublicKEY2