I've generated an RSA symmetric key pair on a device using SecKeyGeneratePair()
on a device. I have SecKeyRef
struct pointers for each key. So, how do I save a SecKeyRef
to disk? Or even transmit it (I also imagine there are issues with correct encoding too)? Apple's 'Certificate, Key, and Trust Services' Guide notes
You can send your public key to anyone, who can then use it to encrypt data.
I'd like to save the private key especially; so I can use it on deployed devices to decrypt data encrypted with the public key.
P.S. I don't mind if the resulting data for each key is DER-encoded ASN.1 or base-64; I just need to figure out how to pull the key out of a SecKeyRef
. I'm also well-aware of the non-existence of OS X's SecKeychainItemExport()
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…