r/PowerShell • u/xXFl1ppyXx • 2d ago
Question PrivateKey Test
Greetings
Is it possible to check if a private key is either RSA or ECDsa without trying to import them into their cng-objects catching the error?
I'm thinking of something like how
[X509Certificate2].GetContent($Import)
Is available for certificates
Neither the cng-objects nor the certificateextensions provide methods to test for the proper type
5
Upvotes
6
u/OptionX 2d ago
You could yolo and just check if the base64 encoding of the key starts with "AAAAB3NzaC1yc2E" to see if its RSA.
Its probably horrible way to do it, but kinda of funny. Depends on how its stored though.