RSA and Base64 in iOS and Mac OS Help

is RSA crypt implementation in Xojo same for iOS and Mac OS from implementation part under the hood?

Mean, can I use PK key pair which is made on Mac OS app, in iOS app and vice verse and make encryption/decryption using it?

This means also that RSAEncryption and RSADecryption should be same on both systems, right?

If someone have some experience please let me know since that is missing in documentation.

Thanks in advance.

Getting to the meat of your question, the keys generated by Xojo’s Crypto library are not vulnerable to the ROCA exploit, according to the online tests. In the classic framework, Xojo uses Crypto++. I cannot comment on the Xojo.Crypto module nor any differences between iOS and macOS however. I would assume they are the same, or at least not vulnerable, as the exploit appears to affect keys generated by a specific hardware vendor.

Hi Thom,

For start I just want to use Public Key in iOS App which is made on Mac OS App, then do encryption and send back encrypted data to Mac OS app and at the end to do data decryption using private key in Mac OS app.

Base64 encoding is issue for now… but will see since I also noticed that even if you want to encode text with CrLf and/or EndOfLine pointer after decoding such text you are getting ‘?’ symbol (so called replacement character) for that byte/bytes (Cr + Lf). EndOfLine depends on OS.

Beside this Base64 isn’t same on iOS and MacOS native from Xojo so guess some tweaking should take a place…

Since I’m new to Xojo will see this days if is possible to sort it out.

Oh. There I go assuming.

Ok, so to solve one of your problems, you can pull some iOS-compatible Base64 encoding from https://github.com/thommcgrath/Beacon/blob/master/Project/Modules/Beacon.xojo_code

As for your other questions, yes the encryption between iOS and macOS are compatible with each other.

I need for both OS and for iOS and for Mac OS to be same padded and encoded otherwise if encoding is different then it want work well. Also when your putting memory block to base64 encoding character escaping should be handled well.
I’m using Kem’s Base64 encode/decode for iOS since for now it’s working well but only for iOS apps.

Still remaining to combine all this :slight_smile:

Thanks for ‘Beacon’. Will test it tomorrow performance as well and will compare it with Kem’s one.

Oh Beacon is just an open source app you are welcome to pull code from. It’s probably not an app you want to use yourself.

I would consider this to be a feedback issue. BASE64 encoding is not at the whim of the platform or language, it is an industry defined algoritm and the same string in Windows, macOS, iOS or Linux should produce the exact same results.

Note when I say “same string”, I mean same string, with same EOL characters…

FYI…
the string

in BASE64 is

This is IDENTICAL in Xojo DESKTOP and SWIFT
in Swift it uses the built in iOS Base64 translators, showing that there should be ZERO difference

So if “Xojo for iOS” returns a different result than above, then the implementation of BASE64 for “Xojo for iOS” is incorrect

Hello Dave,

Yea I agree with you and it’s nice to see that we are on same page.

Last night I also noticed that on Mac OS kind app (so no iOS app) when your using base64 encoding functions which comes with Xojo also will make a bit issue.

On Mac OS when I try to catch which encoding is in use in multiline textbox control - it say UTF-8 which is also on iOS.

For example:
Simply add classic multi-line textbox control and enter some text where you have CrLf or EndOfLine termination or even some of non alpha-numeric character but which are in ASCII 0-255 range.
Maybe will produce defective encoding and decoding after it by replacing them with ‘?’ symbol (so called replacement character) for that byte/bytes.
So if you have for example CrLf and before or after it ’ character, in base64 decoding you will get ‘?’ characters rather then before or after CrLf Plus ’ character in front or after. ???

Only what I will say different then you Dave is that result must be a SAME not IDENTICAL since every byte should be same which represents encoded data on any platform for same encoding… Am I right or maybe I’m wrong?


UPDATE
Screen shot for Mac OS app using internal native Xojo Base64 functions

When you make same thing on online tool for base64 encoding/decoding everything is working.

Last time I looked there was no native Base64 offered in iOS by Xojo. Has this changed?

However iOS DOES have native Base64 operations, which I used for my comparision…
my point was that what ever BASE64 code is being used is incorrect if it is not returning the same results

perhaps this is a language difference… but “the same” and “identical” mean the same thing
each byte in the encoded value is exactly equal in all cases, which was true in my test.