I am trying to encrypt my symmetric key using the public key in an x509certificate. I am using x509certificate2.getPublicKey() to get the public key in form of byte array.
However, i have generated my symmetric key for RC4 using pinvoke CryptGenKey api which is essentially an IntPtr.
Also, I know that inside a certificate there is a field called keyAlgorithm. I need to encrypt the session key with this same algorithm so that client can easily decrypt it (remember, i have no control over the client code so this behaviour cannot be changed).
Could someone please help as to how I can encrypt my RC4 session key using the public key in the certificate (preferably in managed code).
View Complete Post