2

I have an RSA base class that has been initialized using ImportParameters. In some cases only the public key will be loaded. How can I determine if the given RSA object is populated with only public key, or populated with the private key? RSACryptoServiceProvider provided a IsPublicOnly (or similar method).

As per (implement RSA in .NET core), I have switch from RSACryptoServiceProvider to RSA base class which has resolved runtime exceptions when hosted in an Azure app service.

  • Interesting, I don't see any good way to do this. You could always attempt to `ExportParameters(true)` and catch the Exception to indicate a public-key only instance. – President James K. Polk Jun 12 '20 at 01:17
  • I'd rather create a signature and catch the exception there than to expose the private key. – Maarten Bodewes Jun 12 '20 at 07:20
  • The real question is why do you want to know? If it’s so you can create a signature, or decrypt, just try those operations and they’ll fail if there’s no private key. – bartonjs Jun 15 '20 at 19:53

0 Answers0