I’m having a bit annoying thing which comes today.

When I want to decrypt encoded64 data using RSADecrypt on MacOS based app I’m getting bellow error message when I’m using encrypted data as input value made on iOS based app.

When I put same RSA KEY PAIR on iOS app (encode64 data in and then translated to memoryblock) on iOS app encryption and decryption using same PKI key pair is working.

Also, when I’m using RSA PublicKey which comes from iOS based app on MacOS based app also decryption works well on iOS based app.

Only issue and error comes when I want to decrypt data which was encrypted on iOS device before using MacOS based app PublicKey from PKI set.

Error Message:

RSA/OAEP-MGF1(SHA-1): ciphertext length of 513 doesn’t match the required length of 512 for this key

Keep in mind that same PKI set (private and public key) are working on:

  • MacOS app to MacOS App encryption/decryption and
  • iOS app to iOS app encryption/decryption
    but not when you encrypt data using MacOS app PublicKey on iOS based app and then want to decrypt it on MacOS App using RSA PrivateKey which belongs to same key pair of MacOS App

Funny is also that in other ways everything works fine.

Any ideas?


Why not use EncodeHex and DecodeHex? For ios look in the Xojo.Core.MemoryBlock docs

Hello Derk,
Using Hex is at first place bigger in size using it for safe data transport.
Base64 nice fits for web so this should work well and that wasn’t issue.
I believe that something else is issue and not what kind of encoding your using it to transfer data between app’s.