The Apple documentation on certificates and keys says that public keys can be sent to other users. This is of course their whole point. Without going into a sidetrack about man in the middle attacks, I'd like to know how this is supposed to work.
I use base64 encoding to send public keys in email between devices. Upon arrival, they don't work, and the receiving app throws exceptions when I try to use them. The base64 code and the key generation and retrieval code have both been tested exhaustively in another app and they work. Here is the problem in a nutshell:
(1) all the key API use SecKeyRef keys.
(2) a SecKeyRef obviously contains pointers, it comes out with different bits at certain offsets every time I retrieve the keypair from the keychain
(3) if I retrieve the key as a CFDataRef, which is supposed to be "flat," I get a markedly different beast, always with the same values, and a lot of zero padding (capital A in base64).
(4) an imported CFDataRef doesn't work
I don't ask this without doing a lot of research, reading, and testing and I concede I'm stumped, does anyone know how to exchange public keys? I've written Windows apps for years that do this. A certificate chain is a very large hammer for what I need to do here.
Thanks.