We have a simple C#9/WPF app that we're releasing on .NET 5 Core on which we need to introduce licensing. From what I'm reading, one of the most common patterns to do so is asymmetric encryption, aka public/private key encryption.
From what I understand, you as the developer encrypt the customer's licensing info using a private key which only you know, save the results to a file or send it in an email to the customer. Then upon app launch, you use the public key--which you ship along with your application--to verify that no one has tampered with the license file. Makes sense.
They also always say you don't need to worry about protecting your public key because it can only be used to decrypt data generated from your private key, which you have safe and protected.
My question is... what's to stop someone from just replacing the public key stored within the app with their own?
In other words, couldn't a user use your public key to decrypt the license file, make any changes they want, then using their own public/private key set, re-encrypt it, then simply replace your public key with theirs using nothing more than a simple resource editor or binary/hex editor?
My thinking is you would also somehow have to hash your public key to ensure it hasn't been tampered with either because if you can't validate the app is using the expected public key, then that defeats the entire system.