Having trouble decrypting in C# something encrypted on iPhone using RSA

后端 未结 4 1346
轻奢々
轻奢々 2021-02-03 13:00

I\'ve spent two days on this so far and combed through every source at my disposal, so this is the last resort.

I have an X509 certificate whose public key I have stored

4条回答
  •  感情败类
    2021-02-03 13:41

    Well... the first step (as you say you have done) is to encrypt the same messages with the same initialization vectors using both the iPhone and the C# implementation. You should get the same output. You said you didn't, so there is a problem.

    This means either:

    • The iPhone implementation of RSA is incorrect.
    • The .NET implementation of RSA is incorrect.
    • The key files are different (or being interpreted differently).

    I would suggest the first two are unlikely, however they are remotely possible.

    You state: "Installed .cer file in different cert store and server-encrypted string roundtripped just fine"... this doesn't prove anything: all this proves is that given a particular random set of numbers you can encrypt/decrypt successfully on one platform. You are not guaranteeing that both platforms are seeing the same set of random numbers.

    So I suggest you take it down to the lowest level possible here. Inspect the direct (byte array) inputs and outputs of the encryption on both platforms. If with the exact same (binary) inputs you don't get the same output, then you have a platform problem. I think this is unlikely, so I'm guessing you will find that the IVs are being interpreted differently.

提交回复
热议问题