title: Saving SecKeyRef device generated public/private key pair on disk
body: <p>I've generated an RSA symmetric key pair on a device using <code>SecKeyGeneratePair()</code> on a device. I have <code>SecKeyRef</code> struct pointers for each key. So, how do I save a <code>SecKeyRef</code> 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</p>
  
  <blockquote>
    <p>You can send your public key to anyone, who can then use it to encrypt data.</p>
  </blockquote>
  
  <p>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>
  
  <p>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 <code>SecKeyRef</code>. I'm also well-aware of the non-existence of OS X's <code>SecKeychainItemExport()</code>.</p>