Hello,
I'm trying to port some crypto code over to communicate with a closed-source server that has the private key to decrypt the data I send (I only have the public key).
The code should encrypt a random session key with the public key of the server, but the server seems to reject it (for some reason I can't find out).
I have it working in C# and JavaScript though. Are there any differences between the code in C#, JavaScript and Go?
C#:
var rsa = new System.Security.Cryptography.RSACryptoServiceProvider();
rsa.ImportParameters(keyParameters);
var result = rsa.Encrypt(sessionKey, true);
JavaScript (on NodeJS using the 'ursa' library): var result = publicKey.encrypt(sessionKey);
(where the publicKey is already a parsed ursa Public Key)
And Go:
result, err := rsa.EncryptOAEP(crc32.New(crc32.IEEETable), rand.Reader, publicKey, sessionKey, nil)
They all seem equivalent, but as said before, the Go one is rejected. I have verified that all three keys are the same.
I'm using Go 1.1.1 on Windows 7 64bit.